[MM-T5139] Add Standard message priority and system setting test (#29526)

* add Standard message priority and system setting test

* Refactor message priority config and test.

* Refactor to use new priority dialog locators and checks, ensuring default standard option is correctly verified.

* Fix whitespace and formatting in message priority components.

---------

Co-authored-by: Fume <contact@fumedev.com>
Co-authored-by: Mattermost Build <build@mattermost.com>
Этот коммит содержится в:
fume4mattermost
2025-01-08 10:21:09 +03:00
коммит произвёл GitHub
родитель 647c9b6808
Коммит 55a7993a11
4 изменённых файлов: 143 добавлений и 0 удалений

Просмотреть файл

@@ -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};

Просмотреть файл

@@ -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
*/

Просмотреть файл

@@ -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,
};

Просмотреть файл

@@ -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();
});