test(community): add a test that edits a community

Fixes #6756
This commit is contained in:
Jonathan Rainville 2022-08-03 16:16:43 -04:00
parent 1b6fc3b266
commit 44cf440a05
9 changed files with 117 additions and 11 deletions

View File

@ -32,6 +32,22 @@ class CommunityScreenComponents(Enum):
EDIT_CHANNEL_MENU_ITEM = "edit_Channel_StatusMenuItemDelegate"
COMMUNITY_COLUMN_VIEW = "mainWindow_communityColumnView_CommunityColumnView"
class CommunitySettingsComponents(Enum):
EDIT_COMMUNITY_SCROLL_VIEW = "communitySettings_EditCommunity_ScrollView"
EDIT_COMMUNITY_BUTTON = "communitySettings_EditCommunity_Button"
EDIT_COMMUNITY_NAME_INPUT = "communitySettings_EditCommunity_Name_Input"
EDIT_COMMUNITY_DESCRIPTION_INPUT = "communitySettings_EditCommunity_Description_Input"
EDIT_COMMUNITY_COLOR_PICKER_BUTTON = "communitySettings_EditCommunity_ColorPicker_Button"
SAVE_BUTTON = "communitySettings_Save_Button"
BACK_TO_COMMUNITY_BUTTON = "communitySettings_BackToCommunity_Button"
COMMUNITY_NAME_TEXT = "communitySettings_CommunityName_Text"
COMMUNITY_DESCRIPTION_TEXT = "communitySettings_CommunityDescription_Text"
COMMUNITY_LETTER_IDENTICON = "communitySettings_Community_LetterIdenticon"
class CommunityColorPanelComponents(Enum):
HEX_COLOR_INPUT = "communitySettings_ColorPanel_HexColor_Input"
SAVE_COLOR_BUTTON = "communitySettings_SaveColor_Button"
class CreateOrEditCommunityChannelPopup(Enum):
COMMUNITY_CHANNEL_NAME_INPUT: str = "createOrEditCommunityChannelNameInput_TextEdit"
COMMUNITY_CHANNEL_DESCRIPTION_INPUT: str = "createOrEditCommunityChannelDescriptionInput_TextEdit"
@ -60,10 +76,10 @@ class StatusCommunityScreen:
click_obj_by_name(CreateOrEditCommunityChannelPopup.COMMUNITY_CHANNEL_BUTTON.value)
# TODO check if this function is needed, it seems to do the same as verify_chat_title in StatusChatScreen
def verify_channel_name(self, communityChannelName: str):
verify_text_matching(CommunityScreenComponents.CHAT_IDENTIFIER_CHANNEL_NAME.value, communityChannelName)
def verify_channel_name(self, community_channel_name: str):
verify_text_matching(CommunityScreenComponents.CHAT_IDENTIFIER_CHANNEL_NAME.value, community_channel_name)
def edit_community_channel(self, communityChannelName: str, newCommunityChannelName: str):
def edit_community_channel(self, new_community_channel_name: str):
[bannerLoaded, _] = is_loaded_visible_and_enabled(MainUi.MODULE_WARNING_BANNER.value)
if (bannerLoaded):
time.sleep(5) # Wait for the banner to disappear otherwise the click might land badly
@ -73,6 +89,39 @@ class StatusCommunityScreen:
# Select all text in the input before typing
wait_for_object_and_type(CreateOrEditCommunityChannelPopup.COMMUNITY_CHANNEL_NAME_INPUT.value, "<Ctrl+a>")
type(CreateOrEditCommunityChannelPopup.COMMUNITY_CHANNEL_NAME_INPUT.value, newCommunityChannelName)
type(CreateOrEditCommunityChannelPopup.COMMUNITY_CHANNEL_NAME_INPUT.value, new_community_channel_name)
click_obj_by_name(CreateOrEditCommunityChannelPopup.COMMUNITY_CHANNEL_BUTTON.value)
time.sleep(0.5)
def edit_community(self, new_community_name: str, new_community_description: str, new_community_color: str):
click_obj_by_name(CommunityScreenComponents.COMMUNITY_HEADER_BUTTON.value)
click_obj_by_name(CommunitySettingsComponents.EDIT_COMMUNITY_BUTTON.value)
# Select all text in the input before typing
wait_for_object_and_type(CommunitySettingsComponents.EDIT_COMMUNITY_NAME_INPUT.value, "<Ctrl+a>")
type(CommunitySettingsComponents.EDIT_COMMUNITY_NAME_INPUT.value, new_community_name)
wait_for_object_and_type(CommunitySettingsComponents.EDIT_COMMUNITY_DESCRIPTION_INPUT.value, "<Ctrl+a>")
type(CommunitySettingsComponents.EDIT_COMMUNITY_DESCRIPTION_INPUT.value, new_community_description)
scroll_obj_by_name(CommunitySettingsComponents.EDIT_COMMUNITY_SCROLL_VIEW.value)
time.sleep(1)
scroll_obj_by_name(CommunitySettingsComponents.EDIT_COMMUNITY_SCROLL_VIEW.value)
time.sleep(1)
click_obj_by_name(CommunitySettingsComponents.EDIT_COMMUNITY_COLOR_PICKER_BUTTON.value)
wait_for_object_and_type(CommunityColorPanelComponents.HEX_COLOR_INPUT.value, "<Ctrl+a>")
type(CommunityColorPanelComponents.HEX_COLOR_INPUT.value, new_community_color)
click_obj_by_name(CommunityColorPanelComponents.SAVE_COLOR_BUTTON.value)
click_obj_by_name(CommunitySettingsComponents.SAVE_BUTTON.value)
time.sleep(0.5)
# Validation
verify_text_matching(CommunitySettingsComponents.COMMUNITY_NAME_TEXT.value, new_community_name)
verify_text_matching(CommunitySettingsComponents.COMMUNITY_DESCRIPTION_TEXT.value, new_community_description)
obj = get_obj(CommunitySettingsComponents.COMMUNITY_LETTER_IDENTICON.value)
test.verify(obj.color.name == new_community_color, "Community color was not changed correctly")
def go_back_to_community(self):
click_obj_by_name(CommunitySettingsComponents.BACK_TO_COMMUNITY_BUTTON.value)

View File

@ -16,3 +16,23 @@ msgDelegate_channelIdentifierNameText_StyledText = {"container": chatMessageList
createOrEditCommunityChannelNameInput_TextEdit = {"container": statusDesktop_mainWindow_overlay, "objectName": "createOrEditCommunityChannelNameInput", "type": "TextEdit", "visible": True}
createOrEditCommunityChannelDescriptionInput_TextEdit = {"container": statusDesktop_mainWindow_overlay, "objectName": "createOrEditCommunityChannelDescriptionInput", "type": "TextEdit", "visible": True}
createOrEditCommunityChannelBtn_StatusButton = {"container": statusDesktop_mainWindow_overlay, "objectName": "createOrEditCommunityChannelBtn", "type": "StatusButton", "visible": True}
# Community settings
communitySettings_EditCommunity_Button = {"container": statusDesktop_mainWindow, "objectName": "communityOverviewSettingsEditCommunityButton", "type": "StatusButton"}
communitySettings_BackToCommunity_Button = {"container": statusDesktop_mainWindow, "objectName": "communitySettingsBackToCommunityButton", "type": "StatusBaseText", "visible": True}
communitySettings_CommunityName_Text = {"container": statusDesktop_mainWindow, "objectName": "communityOverviewSettingsCommunityName", "type": "StatusBaseText", "visible": True}
communitySettings_CommunityDescription_Text = {"container": statusDesktop_mainWindow, "objectName": "communityOverviewSettingsCommunityDescription", "type": "StatusBaseText", "visible": True}
communitySettings_Community_Identicon = {"container": statusDesktop_mainWindow, "objectName": "communityOverviewSettingsPanelIdenticon", "type": "StatusSmartIdenticon", "visible": True}
communitySettings_Community_LetterIdenticon = {"container": communitySettings_Community_Identicon, "objectName": "statusSmartIdenticonLetter", "type": "StatusLetterIdenticon", "visible": True}
# Community Edit:
communitySettings_EditCommunity_ScrollView = {"container": statusDesktop_mainWindow, "objectName": "communityEditPanelScrollView", "type": "StatusScrollView", "visible": True}
communitySettings_EditCommunity_Name_Input = {"container": communitySettings_EditCommunity_ScrollView, "objectName": "editCommunityNameInput", "type": "TextEdit"}
communitySettings_EditCommunity_Description_Input = {"container": communitySettings_EditCommunity_ScrollView, "objectName": "editCommunityDescriptionInput", "type": "TextEdit"}
communitySettings_EditCommunity_ColorPicker_Button = {"container": communitySettings_EditCommunity_ScrollView, "objectName": "editCommunityColorPicker", "type": "CommunityColorPicker"}
communitySettings_Save_Button = {"container": statusDesktop_mainWindow, "objectName": "settingsDirtyToastMessageSaveButton", "type": "StatusButton", "visible": True}
# Community color popup:
communitySettings_ColorPanel_HexColor_Input = {"container": statusDesktop_mainWindow_overlay, "objectName": "communityColorPanelHexInput", "type": "TextEdit"}
communitySettings_SaveColor_Button = {"container": statusDesktop_mainWindow_overlay, "objectName": "communityColorPanelSelectColorButton", "type": "StatusButton", "visible": True}

View File

@ -29,10 +29,19 @@ def step(context, community_name):
def step(context, community_channel_name, community_channel_description, method):
_statusCommunityScreen.create_community_channel(community_channel_name, community_channel_description, method)
@When("the admin edits a community channel named |any| to the name |any|")
def step(context, community_channel_name, new_community_channel_name):
_statusCommunityScreen.edit_community_channel(community_channel_name, new_community_channel_name)
@When("the admin edits the current community channel to the name |any|")
def step(context, new_community_channel_name):
_statusCommunityScreen.edit_community_channel(new_community_channel_name)
@Then("the user lands on the community channel named |any|")
def step(context, community_channel_name):
_statusCommunityScreen.verify_channel_name(community_channel_name)
@When("the admin edits the current community to the name |any| and description |any| and color |any|")
def step(context, new_community_name, new_community_description, new_community_color):
_statusCommunityScreen.edit_community(new_community_name, new_community_description, new_community_color)
@When("the admin goes back to the community")
def step(context):
_statusCommunityScreen.go_back_to_community()

View File

@ -47,10 +47,21 @@ Feature: Status Desktop community
Then the user lands on the community named myCommunity
When the admin creates a community channel named test-channel, with description My description with the method bottom_menu
Then the user lands on the community channel named test-channel
When the admin edits a community channel named <community_channel_name> to the name <new_community_channel_name>
When the admin edits the current community channel to the name <new_community_channel_name>
Then the user lands on the community channel named <new_community_channel_name>
Examples:
| community_channel_name | community_channel_description | new_community_channel_name |
| test-channel | Community channel description tested 1 | new-test-channel |
Scenario Outline: Admin edits a community
When the user creates a community named myCommunity, with description My community description, intro Community Intro and outro Community Outro
Then the user lands on the community named myCommunity
When the admin edits the current community to the name <new_community_name> and description <new_community_description> and color <new_community_color>
When the admin goes back to the community
Then the user lands on the community named <new_community_name>
Examples:
| new_community_name | new_community_description | new_community_color |
| myCommunityNamedChanged | Cool new description 123 | #ff0000 |

View File

@ -23,6 +23,7 @@ import "../../../CommunitiesPortal/panels"
StatusScrollView {
id: root
objectName: "communityEditPanelScrollView"
property alias name: nameInput.text
property alias description: descriptionTextInput.text
@ -56,27 +57,32 @@ StatusScrollView {
CommunityNameInput {
id: nameInput
input.edit.objectName: "editCommunityNameInput"
Layout.fillWidth: true
Component.onCompleted: nameInput.input.forceActiveFocus(Qt.MouseFocusReason)
}
CommunityDescriptionInput {
id: descriptionTextInput
input.edit.objectName: "editCommunityDescriptionInput"
Layout.fillWidth: true
}
CommunityLogoPicker {
id: logoPicker
objectName: "editCommunityLogoPicker"
Layout.fillWidth: true
}
CommunityBannerPicker {
id: bannerPicker
objectName: "editCommunityBannerPicker"
Layout.fillWidth: true
}
CommunityColorPicker {
id: colorPicker
objectName: "editCommunityColorPicker"
onPick: Global.openPopup(pickColorComponent)
Layout.fillWidth: true
@ -100,6 +106,7 @@ StatusScrollView {
CommunityTagsPicker {
id: tagsPicker
objectName: "editCommunityTagsPicker"
onPick: Global.openPopup(pickTagsComponent)
Layout.fillWidth: true
@ -141,6 +148,7 @@ StatusScrollView {
CommunityIntroMessageInput {
id: introMessageTextInput
input.edit.objectName: "editCommunityIntroInput"
Layout.fillWidth: true
minimumHeight: 108
maximumHeight: 108
@ -148,6 +156,7 @@ StatusScrollView {
CommunityOutroMessageInput {
id: outroMessageTextInput
input.edit.objectName: "editCommunityOutroInput"
Layout.fillWidth: true
}

View File

@ -53,6 +53,7 @@ StackLayout {
spacing: 16
StatusSmartIdenticon {
objectName: "communityOverviewSettingsPanelIdenticon"
name: root.name
icon {
@ -75,6 +76,7 @@ StackLayout {
StatusBaseText {
id: nameText
objectName: "communityOverviewSettingsCommunityName"
Layout.fillWidth: true
font.pixelSize: 24
color: Theme.palette.directColor1
@ -84,6 +86,7 @@ StackLayout {
StatusBaseText {
id: descriptionText
objectName: "communityOverviewSettingsCommunityDescription"
Layout.fillWidth: true
font.pixelSize: 15
color: Theme.palette.directColor1
@ -93,6 +96,7 @@ StackLayout {
}
StatusButton {
objectName: "communityOverviewSettingsEditCommunityButton"
visible: root.editable
text: qsTr("Edit Community")
onClicked: root.currentIndex = 1

View File

@ -104,6 +104,7 @@ StatusAppTwoPanelLayout {
}
StatusBaseText {
objectName: "communitySettingsBackToCommunityButton"
Layout.alignment: Qt.AlignHCenter
text: "<- " + qsTr("Back to community")
color: Theme.palette.baseColor1

View File

@ -12,10 +12,11 @@ import StatusQ.Popups 0.1
StatusScrollView {
id: root
property string title: qsTr("Community Color")
property string title: qsTr("Community Colour")
property var rightButtons: StatusButton {
text: qsTr("Select Community Color")
objectName: "communityColorPanelSelectColorButton"
text: qsTr("Select Community Colour")
onClicked: root.accepted()
}
@ -58,6 +59,7 @@ StatusScrollView {
StatusInput {
id: hexInput
input.edit.objectName: "communityColorPanelHexInput"
property color newColor: text
// TODO: editingFinished() signal instead of this crutch

View File

@ -117,6 +117,7 @@ Rectangle {
StatusButton {
id: saveChangesButton
objectName: "settingsDirtyToastMessageSaveButton"
enabled: root.active && root.saveChangesButtonEnabled
text: qsTr("Save changes")
onClicked: root.saveChangesClicked()