test(tst_communityPermissions): implement permissions screen validation

This commit is contained in:
Anastasiya S 2023-05-03 19:24:21 +03:00 committed by Anastasiya Semenkevich
parent 6464366c7d
commit 81a79327b6
13 changed files with 181 additions and 8 deletions

View File

@ -63,6 +63,10 @@ class BaseElement:
button or squish.MouseButton.LeftButton
)
@property
def is_enabled(self) -> bool:
return self.object.enabled
def wait_until_appears(self, timeout_msec: int = configs.squish.UI_LOAD_TIMEOUT_MSEC):
assert squish.waitFor(lambda: self.is_visible, timeout_msec), f'Object {self} is not visible'
return self

View File

@ -72,6 +72,17 @@ class CommunitySettingsComponents(Enum):
MEMBERS_TAB_MEMBERS_LISTVIEW = "communitySettings_MembersTab_Members_ListView"
MEMBER_KICK_BUTTON = "communitySettings_MembersTab_Member_Kick_Button"
MEMBER_CONFIRM_KICK_BUTTON = "communitySettings_KickModal_Kick_Button"
class CommunityPermissionsComponents(Enum):
WELCOME_SCREEN_TITLE = "communityPermissions_welcome_title"
WELCOME_SCREEN_IMAGE = "communityPermissions_welcome_image"
WELCOME_SCREEN_SETTINGS_TITLE = "communityPermissions_welcome_settings_title"
WELCOME_SCREEN_SETTINGS_SUBTITLE = "communityPermissions_welcome_settings_subtitle"
WELCOME_SCREEN_SETTINGS_CHECKLIST_ELEMENT1 = "communityPermissions_welcome_settings_checkList_element1"
WELCOME_SCREEN_SETTINGS_CHECKLIST_ELEMENT2 = "communityPermissions_welcome_settings_checkList_element2"
WELCOME_SCREEN_SETTINGS_CHECKLIST_ELEMENT3 = "communityPermissions_welcome_settings_checkList_element3"
ADD_NEW_PERMISSION_BUTTON = "communityPermissions_welcome_settings_add_new_permission"
class CommunityColorPanelComponents(Enum):
HEX_COLOR_INPUT = "communitySettings_ColorPanel_HexColor_Input"
@ -155,7 +166,7 @@ class StatusCommunityScreen:
click_obj_by_name(CommunityScreenComponents.COMMUNITY_EDIT_CATEGORY_MENU_ITEM.value)
def verify_community_name(self, communityName: str):
verify_text_matching(CommunityScreenComponents.COMMUNITY_HEADER_NAME_TEXT.value, communityName)
verify_text_matching(CommunityScreenComponents.COMMUNITY_HEADER_NAME_TEXT.value, communityName)
def verify_community_overview_name(self, communityName: str):
verify_text_matching(CommunitySettingsComponents.COMMUNITY_NAME_TEXT.value, communityName)
@ -465,4 +476,43 @@ class StatusCommunityScreen:
def verify_option_exists(self, option:str):
if option=="Permissions":
title = get_obj(CommunitySettingsComponents.PERMISSIONS_BUTTON.value).title
verify_text(option, str(title))
verify_text(option, str(title))
def select_community_settings_option(self, option:str):
if option=="Permissions":
click_obj_by_name(CommunitySettingsComponents.PERMISSIONS_BUTTON.value)
def verify_permission_screen_title(self, option:str):
if option=="Permissions":
title = get_obj(CommunityPermissionsComponents.WELCOME_SCREEN_TITLE.value).text
verify_text(option, str(title))
def verify_welcome_permission_image(self):
path = get_obj(CommunityPermissionsComponents.WELCOME_SCREEN_IMAGE.value).source.path
verify_text_contains(str(path), "permissions2_3")
def verify_welcome_settings_title(self):
verify_equals(get_obj(CommunityPermissionsComponents.WELCOME_SCREEN_SETTINGS_TITLE.value).text, "Permissions")
def verify_welcome_settings_subtitle(self):
verify_equals(get_obj(CommunityPermissionsComponents.WELCOME_SCREEN_SETTINGS_SUBTITLE.value).text, "You can manage your community by creating and issuing membership and access permissions")
def verify_welcome_settings_checklist(self, list: list):
checklist = []
checklist.append(get_obj(CommunityPermissionsComponents.WELCOME_SCREEN_SETTINGS_CHECKLIST_ELEMENT1.value).text)
checklist.append(get_obj(CommunityPermissionsComponents.WELCOME_SCREEN_SETTINGS_CHECKLIST_ELEMENT2.value).text)
checklist.append(get_obj(CommunityPermissionsComponents.WELCOME_SCREEN_SETTINGS_CHECKLIST_ELEMENT3.value).text)
# Check if the lists are of equal length
if len(checklist) != len(list):
return False
# Check if the lists have the same elements in the same order
for i in range(len(checklist)):
if checklist[i] != list[i]:
return False
def verify_add_permission_button_enabled(self):
assert BaseElement(str(CommunityPermissionsComponents.ADD_NEW_PERMISSION_BUTTON.value)).is_enabled
button_title = get_obj(CommunityPermissionsComponents.ADD_NEW_PERMISSION_BUTTON.value).text
verify_equals("Add new permission", str(button_title))

View File

@ -63,6 +63,10 @@ def step(context: any, settings_type:str):
def step(context: any, settings_type:str):
_settingsScreen.toggle_experimental_feature(settings_type)
@Given("the user opens the community named \"|any|\"")
def step(context, community_name:str):
_settingsScreen.open_community(community_name)
#########################
### ACTIONS region:
#########################

View File

@ -81,3 +81,13 @@ communitySettings_EditCommunity_ColorPicker_Button = {"container": communitySett
# Community color popup:
communitySettings_ColorPanel_HexColor_Input = {"container": statusDesktop_mainWindow_overlay, "objectName": "communityColorPanelHexInput", "type": "TextEdit", "visible": True}
communitySettings_SaveColor_Button = {"container": statusDesktop_mainWindow_overlay, "objectName": "communityColorPanelSelectColorButton", "type": "StatusButton", "visible": True}
# Community permissions:
communityPermissions_welcome_title = {"container": statusDesktop_mainWindow, "objectName": "welcomeSettingsTitle", "type": "StatusBaseText", "visible": True}
communityPermissions_welcome_image = {"container": statusDesktop_mainWindow, "objectName": "welcomeSettingsImage", "type": "Image", "visible": True}
communityPermissions_welcome_settings_title = {"container": statusDesktop_mainWindow, "objectName": "welcomeSettingsTitle", "type": "StatusBaseText", "visible": True}
communityPermissions_welcome_settings_subtitle = {"container": statusDesktop_mainWindow, "objectName": "welcomeSettingsSubtitle", "type": "StatusBaseText", "visible": True}
communityPermissions_welcome_settings_checkList_element1 = {"container": statusDesktop_mainWindow, "objectName": "checkListText_0", "type": "StatusBaseText", "visible": True}
communityPermissions_welcome_settings_checkList_element2 = {"container": statusDesktop_mainWindow, "objectName": "checkListText_1", "type": "StatusBaseText", "visible": True}
communityPermissions_welcome_settings_checkList_element3 = {"container": statusDesktop_mainWindow, "objectName": "checkListText_2", "type": "StatusBaseText", "visible": True}
communityPermissions_welcome_settings_add_new_permission = {"container": statusDesktop_mainWindow, "objectName": "welcomeSettingsAddNewPermissionButton", "type": "StatusButton", "visible": True}

View File

@ -50,6 +50,14 @@ def step(context, category_name, channel_names):
def step(context: any, settings_type:str):
_settingsScreen.toggle_experimental_feature(settings_type)
@Given("\"|any|\" is clicked in the community sidebar")
def step(context, community_sidebar_option:str):
_statusCommunityScreen.click_sidebar_option(community_sidebar_option)
@Given("\"|any|\" should be an available option in Community Settings")
def step(context, manage_community_option:str):
_statusCommunityScreen.verify_option_exists(manage_community_option)
#########################
### ACTIONS region:
#########################
@ -160,6 +168,10 @@ def step(context, channel):
@When("\"|any|\" is clicked in the community sidebar")
def step(context, community_sidebar_option:str):
_statusCommunityScreen.click_sidebar_option(community_sidebar_option)
@When("\"|any|\" section is selected")
def step(context, section_option:str):
_statusCommunityScreen.select_community_settings_option(section_option)
#########################
@ -225,6 +237,14 @@ def step(context, communityDescription: str):
@Then("the community overview color is \"|any|\"")
def step(context, color: str):
_statusCommunityScreen.verify_community_overview_color(color)
@Then("the heading is \"|any|\"")
def step(context, community_settings_screen_name:str):
_statusCommunityScreen.verify_permission_screen_title(community_settings_screen_name)
@Then("the welcome permission image is present")
def step(context):
_statusCommunityScreen.verify_welcome_permission_image()
@Then("\"|any|\" should be an available option in Community Settings")
def step(context, manage_community_option:str):
@ -234,6 +254,22 @@ def step(context, manage_community_option:str):
def step(context, chat_name:str):
_statusCommunityScreen.check_channel_is_uncategorized(chat_name)
@Then("the welcome permission title is present")
def step(context, ):
_statusCommunityScreen.verify_welcome_settings_title()
@Then("the welcome permission subtitle is present")
def step(context, ):
_statusCommunityScreen.verify_welcome_settings_subtitle()
@Then("the welcome permission settings \"|any|\" is present")
def step(context, list):
_statusCommunityScreen.verify_welcome_settings_checklist(list)
@Then("Add new permission button is present")
def step (context):
_statusCommunityScreen.verify_add_permission_button_enabled()
###########################################################################
### COMMON methods used in different steps given/when/then region:

View File

@ -0,0 +1,31 @@
# -*- coding: utf-8 -*-
# A quick introduction to implementing scripts for BDD tests:
#
# This file contains snippets of script code to be executed as the .feature
# file is processed. See the section 'Behaviour Driven Testing' in the 'API
# Reference Manual' chapter of the Squish manual for a comprehensive reference.
#
# The decorators Given/When/Then/Step can be used to associate a script snippet
# with a pattern which is matched against the steps being executed. Optional
# table/multi-line string arguments of the step are passed via a mandatory
# 'context' parameter:
#
# @When("I enter the text")
# def whenTextEntered(context):
# <code here>
#
# The pattern is a plain string without the leading keyword, but a couple of
# placeholders including |any|, |word| and |integer| are supported which can be
# used to extract arbitrary, alphanumeric and integer values resp. from the
# pattern; the extracted values are passed as additional arguments:
#
# @Then("I get |integer| different names")
# def namesReceived(context, numNames):
# <code here>
#
# Instead of using a string with placeholders, a regular expression can be
# specified. In that case, make sure to set the (optional) 'regexp' argument
# to True.
import names

View File

@ -2,6 +2,6 @@ AUT=nim_status_client
ENVVARS=envvars
LANGUAGE=Python
OBJECTMAPSTYLE=script
TEST_CASES=tst_communityFlows tst_searchFlows tst_communityMessageFlows tst_communityMemberFlows tst_communityAdminFlows tst_communityPermissions
TEST_CASES=tst_communityFlows tst_searchFlows tst_communityMessageFlows tst_communityMemberFlows tst_communityAdminFlows tst_communitySettings tst_communityPermissions
VERSION=3
WRAPPERS=Qt

View File

@ -10,6 +10,15 @@ Background:
And the user lands on the community named "Test-Community"
Scenario: Community permissions is an available option is Community Settings
When "Manage Community" is clicked in the community sidebar
Then "Permissions" should be an available option in Community Settings
Scenario: Welcome Permissions Screen content validation
When "Manage Community" is clicked in the community sidebar
And "Permissions" section is selected
Then the heading is "Permissions"
And the welcome permission image is present
And the welcome permission title is present
And the welcome permission subtitle is present
And the welcome permission settings "<user onboarding checklist>" is present
| Give individual members access to private channels |
| Monetise your community with subscriptions and fees |
| Require holding a token or NFT to obtain exclusive membership rights |
And Add new permission button is present

View File

@ -5,4 +5,4 @@ collectStepDefinitions('./steps', '../shared/steps/', '../../global_shared/steps
def main():
testSettings.throwOnFailure = True
runFeatureFile('test.feature')
runFeatureFile('test.feature')

View File

@ -0,0 +1,15 @@
Feature: Community Settings
Background:
Given A first time user lands on the status desktop and generates new key
And the user signs up with username "tester123" and password "TesTEr16843/!@00"
And the user lands on the signed in app
And the user opens the community portal section
And the user lands on the community portal section
And the user creates a community named "Test-Community", with description "My community description", intro "Community Intro" and outro "Community Outro"
And the user lands on the community named "Test-Community"
Scenario: Community permissions is an available option is Community Settings
When "Manage Community" is clicked in the community sidebar
Then "Permissions" should be an available option in Community Settings

View File

@ -0,0 +1,8 @@
source(findFile('scripts', 'python/bdd.py'))
setupHooks('../../global_shared/scripts/bdd_hooks.py')
collectStepDefinitions('./steps', '../shared/steps/', '../../global_shared/steps/','../../suite_onboarding/shared/steps/')
def main():
testSettings.throwOnFailure = True
runFeatureFile('test.feature')

View File

@ -73,6 +73,7 @@ Item {
}
StatusButton {
objectName: "welcomeSettingsAddNewPermissionButton"
visible: root.headerButtonVisible
text: root.headerButtonText
Layout.preferredHeight: 44

View File

@ -47,6 +47,7 @@ StatusScrollView {
Image {
id: imageItem
objectName: "welcomeSettingsImage"
Layout.preferredWidth: root.imageWidth
Layout.preferredHeight: root.imageHeigth
Layout.alignment: Qt.AlignHCenter
@ -58,6 +59,7 @@ StatusScrollView {
StatusBaseText {
id: titleItem
objectName: "welcomeSettingsTitle"
Layout.fillWidth: true
horizontalAlignment: Text.AlignHCenter
font.pixelSize: 17
@ -67,7 +69,7 @@ StatusScrollView {
StatusBaseText {
id: subtitleItem
objectName: "welcomeSettingsSubtitle"
Layout.fillWidth: true
horizontalAlignment: Text.AlignHCenter
lineHeight: 1.2
@ -94,6 +96,8 @@ StatusScrollView {
Repeater {
id: checkersItems
objectName: "checkListItem"
RowLayout {
Layout.fillWidth: true
spacing: checkersColumn.rowChildSpacing
@ -104,6 +108,7 @@ StatusScrollView {
}
StatusBaseText {
objectName: "checkListText_" + index
Layout.fillWidth: true
Layout.alignment: Qt.AlignVCenter
text: modelData