diff --git a/e2e-tests/playwright/support/ui/components/channels/message_priority.ts b/e2e-tests/playwright/support/ui/components/channels/message_priority.ts new file mode 100644 index 0000000000..90f48c0f91 --- /dev/null +++ b/e2e-tests/playwright/support/ui/components/channels/message_priority.ts @@ -0,0 +1,78 @@ +// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. +// See LICENSE.txt for license information. + +import {expect, Locator} from '@playwright/test'; + +export default class MessagePriority { + readonly container: Locator; + readonly priorityIcon: Locator; + readonly priorityMenu: Locator; + readonly standardPriorityOption: Locator; + readonly priorityDialog: Locator; + readonly dialogHeader: Locator; + + constructor(container: Locator) { + this.container = container; + + // Formatting bar priority icon + this.priorityIcon = container.locator('#messagePriority'); + + // Priority menu that opens when clicking the icon + this.priorityMenu = container.locator('[role="menu"]').filter({hasText: /Message Priority/}); + + // Standard priority option in the menu (id comes from webapp implementation) + this.standardPriorityOption = this.priorityMenu.locator('#menu-item-priority-standard'); + + // Priority dialog elements + this.priorityDialog = container.page().getByRole('dialog'); + this.dialogHeader = this.priorityDialog.locator('h4.modal-title'); + } + + async clickPriorityIcon() { + await this.priorityIcon.waitFor({state: 'visible'}); + await this.priorityIcon.click(); + } + + async verifyPriorityIconVisible() { + await this.priorityIcon.waitFor({state: 'visible'}); + await expect(this.priorityIcon).toBeVisible(); + } + + async verifyStandardPrioritySelected() { + await expect(this.priorityMenu).toBeVisible(); + await expect(this.standardPriorityOption).toHaveAttribute('aria-checked', 'true'); + } + + async verifyPriorityMenuVisible() { + await expect(this.priorityMenu).toBeVisible(); + // Look for beta text in header + await expect(this.priorityMenu.locator('text=Message Priority')).toBeVisible(); + } + + async closePriorityMenu() { + await this.priorityIcon.click(); + await expect(this.priorityMenu).not.toBeVisible(); + } + + async verifyNoPriorityLabel(postText: string) { + const post = this.container.locator(`text=${postText}`); + await expect(post).toBeVisible(); + + // Verify no priority label exists + const priorityLabel = post.locator('[data-testid="post-priority-label"]'); + await expect(priorityLabel).toHaveCount(0); + } + + async verifyPriorityDialog() { + await expect(this.priorityDialog).toBeVisible(); + await expect(this.dialogHeader).toHaveText('Message priority'); + } + + async verifyStandardOptionSelected() { + const standardOption = this.priorityDialog.getByRole('menuitem', {name: 'Standard'}); + await expect(standardOption).toBeVisible(); + await expect(standardOption.locator('svg.StyledCheckIcon-dFKfoY')).toBeVisible(); + } +} + +export {MessagePriority}; diff --git a/e2e-tests/playwright/support/ui/components/channels/post_create.ts b/e2e-tests/playwright/support/ui/components/channels/post_create.ts index f16cd2060a..009494feea 100644 --- a/e2e-tests/playwright/support/ui/components/channels/post_create.ts +++ b/e2e-tests/playwright/support/ui/components/channels/post_create.ts @@ -11,6 +11,7 @@ export default class ChannelsPostCreate { readonly emojiButton; readonly sendMessageButton; readonly scheduleDraftMessageButton; + readonly priorityButton; readonly suggestionList; constructor(container: Locator, isRHS = false) { @@ -26,6 +27,7 @@ export default class ChannelsPostCreate { this.emojiButton = container.getByLabel('select an emoji'); this.sendMessageButton = container.getByTestId('SendMessageButton'); this.scheduleDraftMessageButton = container.getByLabel('Schedule message'); + this.priorityButton = container.getByLabel('Message priority'); this.suggestionList = container.getByTestId('suggestionList'); } @@ -81,6 +83,15 @@ export default class ChannelsPostCreate { await this.scheduleDraftMessageButton.click(); } + /** + * Opens the message priority menu + */ + async openPriorityMenu() { + await expect(this.priorityButton).toBeVisible(); + await expect(this.priorityButton).toBeEnabled(); + await this.priorityButton.click(); + } + /** * Composes and sends a message */ diff --git a/e2e-tests/playwright/support/ui/components/index.ts b/e2e-tests/playwright/support/ui/components/index.ts index 1e48cd79ba..1f7c2375a5 100644 --- a/e2e-tests/playwright/support/ui/components/index.ts +++ b/e2e-tests/playwright/support/ui/components/index.ts @@ -21,6 +21,7 @@ import {PostMenu} from './channels/post_menu'; import {ThreadFooter} from './channels/thread_footer'; import {EmojiGifPicker} from './channels/emoji_gif_picker'; import {GenericConfirmModal} from './channels/generic_confirm_modal'; +import {MessagePriority} from './channels/message_priority'; import {ScheduledDraftMenu} from './channels/scheduled_draft_menu'; import {ScheduledDraftModal} from './channels/scheduled_draft_modal'; @@ -62,6 +63,7 @@ const components = { SystemUsersFilterPopover, SystemUsersFilterMenu, SystemUsersColumnToggleMenu, + MessagePriority, UserProfilePopover, }; @@ -80,4 +82,5 @@ export { PostDotMenu, PostMenu, ThreadFooter, + MessagePriority, }; diff --git a/e2e-tests/playwright/tests/functional/channels/message_priority/standard_priority.spec.ts b/e2e-tests/playwright/tests/functional/channels/message_priority/standard_priority.spec.ts new file mode 100644 index 0000000000..9d76d43e01 --- /dev/null +++ b/e2e-tests/playwright/tests/functional/channels/message_priority/standard_priority.spec.ts @@ -0,0 +1,51 @@ +// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. +// See LICENSE.txt for license information. + +import {expect, test} from '@e2e-support/test_fixture'; +import MessagePriority from '@e2e-support/ui/components/channels/message_priority'; + +test('MM-T5139: Message Priority - Standard message priority and system setting', async ({pw, pages}) => { + // # Setup test environment + const {user} = await pw.initSetup(); + + // # Log in as a user in new browser context + const {page} = await pw.testBrowser.login(user); + + // # Visit default channel page + const channelPage = new pages.ChannelsPage(page); + await channelPage.goto(); + await channelPage.toBeVisible(); + + const messagePriority = new MessagePriority(page.locator('body')); + + // Open menu + await channelPage.centerView.postCreate.openPriorityMenu(); + + // Use messagePriority for dialog interactions + await messagePriority.verifyPriorityDialog(); + await messagePriority.verifyStandardOptionSelected(); + + // # Close menu and post message + await channelPage.centerView.postCreate.priorityButton.click(); + const testMessage = 'This is just a test message'; + await channelPage.postMessage(testMessage); + + // # Verify message posts without priority label + const lastPost = await channelPage.centerView.getLastPost(); + await lastPost.toBeVisible(); + await lastPost.toContainText(testMessage); + await expect(lastPost.container.locator('.post-priority')).not.toBeVisible(); + + // # Open post in RHS and verify + await lastPost.container.click(); + await channelPage.sidebarRight.toBeVisible(); + + // # Get RHS post and verify content + const rhsPost = await channelPage.sidebarRight.getLastPost(); + await rhsPost.toBeVisible(); + await rhsPost.toContainText(testMessage); + await expect(rhsPost.container.locator('.post-priority')).not.toBeVisible(); + + // # Verify RHS formatting bar doesn't have priority button + await expect(channelPage.sidebarRight.postCreate.priorityButton).not.toBeVisible(); +});