MM-63669 E2E/Playwright: Move "e2e-tests/playwright/test" to "e2e-tests/playwright" folder (#30647)

* move "e2e-tests/playwright/test" to  "e2e-tests/playwright/test" and expose "ensurePluginsLoaded"

* add test setup, and expose ensurePluginsLoaded and ensureServerDeployment to pw
Этот коммит содержится в:
Saturnino Abril
2025-04-07 22:26:29 +08:00
коммит произвёл GitHub
родитель 62753a1481
Коммит a35a6d7a3a
80 изменённых файлов: 165 добавлений и 154 удалений

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

@@ -0,0 +1,109 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {Page} from '@playwright/test';
import {UserProfile} from '@mattermost/types/users';
import {expect, test, ChannelsPage} from '@mattermost/playwright-lib';
test('MM-63451 should be able to navigate the account settings menu with the keyboard after opening it with the mouse', async ({
pw,
}) => {
// # Create and sign in a new user
const {user} = await pw.initSetup();
// # Log in a user in new browser context
const {page, channelsPage} = await pw.testBrowser.login(user);
// # Visit a default channel page
await channelsPage.goto();
await channelsPage.toBeVisible();
// # Click on the account menu button
await channelsPage.globalHeader.accountMenuButton.click();
await testMenuWithKeyboard(user, page, channelsPage);
});
test('MM-63451 should be able to navigate the account settings menu with the keyboard after opening it with the keyboard', async ({
pw,
}) => {
// # Create and sign in a new user
const {user} = await pw.initSetup();
// # Log in a user in new browser context
const {page, channelsPage} = await pw.testBrowser.login(user);
// # Visit a default channel page
await channelsPage.goto();
await channelsPage.toBeVisible();
// # Focus the account menu button
await channelsPage.globalHeader.accountMenuButton.focus();
await expect(channelsPage.globalHeader.accountMenuButton).toBeFocused();
await page.keyboard.press('Space');
await testMenuWithKeyboard(user, page, channelsPage);
});
async function testMenuWithKeyboard(user: UserProfile, page: Page, channelsPage: ChannelsPage) {
// * Should start focused on the first menu item
await expect(page.getByRole('menuitem', {name: '@' + user.username})).toBeFocused();
// * Should be able to scroll down through the menu with the keyboard
await page.keyboard.press('ArrowDown');
await expect(page.getByRole('menuitem', {name: 'Set custom status'})).toBeFocused();
await page.keyboard.press('ArrowDown');
await expect(page.getByRole('menuitem', {name: 'Online'})).toBeFocused();
await page.keyboard.press('ArrowDown');
await expect(page.getByRole('menuitem', {name: 'Away'})).toBeFocused();
await page.keyboard.press('ArrowDown');
await expect(page.getByRole('menuitem', {name: 'Do not disturb Disables all notifications'})).toBeFocused();
await page.keyboard.press('ArrowDown');
await expect(page.getByRole('menuitem', {name: 'Offline'})).toBeFocused();
await page.keyboard.press('ArrowDown');
await expect(page.getByRole('menuitem', {name: 'Profile'})).toBeFocused();
await page.keyboard.press('ArrowDown');
await expect(page.getByRole('menuitem', {name: 'Log Out'})).toBeFocused();
// * Should be able to scroll back up through the menu with the keyboard
await page.keyboard.press('ArrowUp');
await expect(page.getByRole('menuitem', {name: 'Profile'})).toBeFocused();
await page.keyboard.press('ArrowUp');
await expect(page.getByRole('menuitem', {name: 'Offline'})).toBeFocused();
await page.keyboard.press('ArrowUp');
await expect(page.getByRole('menuitem', {name: 'Do not disturb Disables all notifications'})).toBeFocused();
// * Should be able to move into the submenu by pressing the right arrow
await page.keyboard.press('ArrowRight');
await expect(page.getByRole('menuitem', {name: "Don't clear"})).toBeFocused();
// * Should be able to scroll through the submenu with the keyboard
await page.keyboard.press('ArrowDown');
await expect(page.getByRole('menuitem', {name: '30 mins'})).toBeFocused();
await page.keyboard.press('ArrowDown');
await expect(page.getByRole('menuitem', {name: '1 hour'})).toBeFocused();
await page.keyboard.press('ArrowDown');
await expect(page.getByRole('menuitem', {name: '2 hours'})).toBeFocused();
await page.keyboard.press('ArrowDown');
await expect(page.getByRole('menuitem', {name: 'Tomorrow'})).toBeFocused();
await page.keyboard.press('ArrowDown');
await expect(page.getByRole('menuitem', {name: 'Choose date and time'})).toBeFocused();
// * Should wrap around when you reach the end
await page.keyboard.press('ArrowDown');
await expect(page.getByRole('menuitem', {name: "Don't clear"})).toBeFocused();
await page.keyboard.press('ArrowUp');
await expect(page.getByRole('menuitem', {name: 'Choose date and time'})).toBeFocused();
// * Should be able to close the submenu by pressing the left arrow
await page.keyboard.press('ArrowLeft');
await expect(page.getByRole('menuitem', {name: 'Do not disturb Disables all notifications'})).toBeFocused();
// * Should be able to close the menu by pressing escape
await page.keyboard.press('Escape');
await expect(page.getByRole('menuitem')).toHaveCount(0);
// * Should be focused back on the menu button
await expect(channelsPage.globalHeader.accountMenuButton).toBeFocused();
}

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

@@ -0,0 +1,162 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {expect, test} from '@mattermost/playwright-lib';
test.fixme('Base channel accessibility', async ({pw, axe}) => {
// # Create and sign in a new user
const {user} = await pw.initSetup();
// # Log in a user in new browser context
const {page, channelsPage} = await pw.testBrowser.login(user);
// # Visit a default channel page
await channelsPage.goto();
await channelsPage.toBeVisible();
await channelsPage.centerView.postCreate.postMessage('hello');
// # Analyze the page
// Disable 'color-contrast' to be addressed by MM-53814
const accessibilityScanResults = await axe.builder(page, {disableColorContrast: true}).analyze();
// * Should have no violation
expect(accessibilityScanResults.violations).toHaveLength(0);
});
test('Post actions tab support', async ({pw, axe}) => {
// # Create and sign in a new user
const {user, adminClient} = await pw.initSetup();
const config = await adminClient.getConfig();
const license = await adminClient.getClientLicenseOld();
// # Log in a user in new browser context
const {page, channelsPage} = await pw.testBrowser.login(user);
// # Visit a default channel page
await channelsPage.goto();
await channelsPage.toBeVisible();
await channelsPage.centerView.postCreate.postMessage('hello');
const post = await channelsPage.centerView.getLastPost();
await post.hover();
await post.postMenu.toBeVisible();
// # Open the dot menu
await post.postMenu.dotMenuButton.press('Enter');
// * Dot menu should be visible and have focused
await channelsPage.postDotMenu.toBeVisible();
await expect(channelsPage.postDotMenu.replyMenuItem).toBeFocused();
// # Analyze the page
const accessibilityScanResults = await axe
.builder(page, {disableColorContrast: true})
.include('.MuiList-root.MuiList-padding')
.analyze();
// * Should have no violation
expect(accessibilityScanResults.violations).toHaveLength(0);
// * Should move focus to Forward after arrow down
await channelsPage.postDotMenu.replyMenuItem.press('ArrowDown');
await expect(channelsPage.postDotMenu.forwardMenuItem).toBeFocused();
// * Should move focus to Follow message after arrow down
await channelsPage.postDotMenu.forwardMenuItem.press('ArrowDown');
await expect(channelsPage.postDotMenu.followMessageMenuItem).toBeFocused();
// * Should move focus to Mark as Unread after arrow down
await channelsPage.postDotMenu.followMessageMenuItem.press('ArrowDown');
await expect(channelsPage.postDotMenu.markAsUnreadMenuItem).toBeFocused();
// * Should move focus to Remind after arrow down
await channelsPage.postDotMenu.markAsUnreadMenuItem.press('ArrowDown');
await expect(channelsPage.postDotMenu.remindMenuItem).toBeFocused();
// * Should move focus to Save after arrow down
await channelsPage.postDotMenu.remindMenuItem.press('ArrowDown');
await expect(channelsPage.postDotMenu.saveMenuItem).toBeFocused();
// * Should move focus to Pin to Channel after arrow down
await channelsPage.postDotMenu.saveMenuItem.press('ArrowDown');
await expect(channelsPage.postDotMenu.pinToChannelMenuItem).toBeFocused();
if (config.FeatureFlags['MoveThreadsEnabled'] && license.IsLicensed === 'true') {
// * Should move focus to Move Thread after arrow down
await channelsPage.postDotMenu.pinToChannelMenuItem.press('ArrowDown');
await expect(channelsPage.postDotMenu.moveThreadMenuItem).toBeFocused();
// * Should move focus to Copy Link after arrow down
await channelsPage.postDotMenu.moveThreadMenuItem.press('ArrowDown');
await expect(channelsPage.postDotMenu.copyLinkMenuItem).toBeFocused();
} else {
// * Should move focus to Copy Link after arrow down
await channelsPage.postDotMenu.pinToChannelMenuItem.press('ArrowDown');
await expect(channelsPage.postDotMenu.copyLinkMenuItem).toBeFocused();
}
// * Should move focus to Edit after arrow down
await channelsPage.postDotMenu.copyLinkMenuItem.press('ArrowDown');
await expect(channelsPage.postDotMenu.editMenuItem).toBeFocused();
// * Should move focus to Copy Text after arrow down
await channelsPage.postDotMenu.editMenuItem.press('ArrowDown');
await expect(channelsPage.postDotMenu.copyTextMenuItem).toBeFocused();
// * Should move focus to Delete after arrow down
await channelsPage.postDotMenu.copyTextMenuItem.press('ArrowDown');
await expect(channelsPage.postDotMenu.deleteMenuItem).toBeFocused();
// * Then, should move focus back to Reply after arrow down
await channelsPage.postDotMenu.deleteMenuItem.press('ArrowDown');
await expect(channelsPage.postDotMenu.replyMenuItem).toBeFocused();
// * Should move focus to Delete after arrow uo
await channelsPage.postDotMenu.container.press('ArrowUp');
expect(await channelsPage.postDotMenu.deleteMenuItem).toBeFocused();
// # Set focus to Remind
await channelsPage.postDotMenu.remindMenuItem.focus();
await expect(channelsPage.postDotMenu.remindMenuItem).toBeFocused();
// * Reminder menu should still be hidden
await expect(channelsPage.postReminderMenu.container).toBeHidden();
// # Press arrow right
await channelsPage.postDotMenu.remindMenuItem.press('ArrowRight');
// * Reminder menu should be visible
expect(channelsPage.postReminderMenu.container).toBeVisible();
// * Should have focus on 30 mins after submenu opens
expect(await channelsPage.postReminderMenu.thirtyMinsMenuItem).toBeFocused();
// * Should move focus to 1 hour after arrow down
await channelsPage.postReminderMenu.thirtyMinsMenuItem.press('ArrowDown');
expect(await channelsPage.postReminderMenu.oneHourMenuItem).toBeFocused();
// * Should move focus to 2 hours after arrow down
await channelsPage.postReminderMenu.oneHourMenuItem.press('ArrowDown');
expect(await channelsPage.postReminderMenu.twoHoursMenuItem).toBeFocused();
// * Should move focus to Tomorrow after arrow down
await channelsPage.postReminderMenu.twoHoursMenuItem.press('ArrowDown');
expect(await channelsPage.postReminderMenu.tomorrowMenuItem).toBeFocused();
// * Should move focus to Custom after arrow down
await channelsPage.postReminderMenu.tomorrowMenuItem.press('ArrowDown');
expect(await channelsPage.postReminderMenu.customMenuItem).toBeFocused();
// * Then, should move focus back to 30 mins after arrow down
await channelsPage.postReminderMenu.customMenuItem.press('ArrowDown');
expect(await channelsPage.postReminderMenu.thirtyMinsMenuItem).toBeFocused();
// * Should hide Reminder menu and focus to Remind menu after arrow left
await channelsPage.postReminderMenu.container.press('ArrowLeft');
await expect(channelsPage.postReminderMenu.container).toBeHidden();
await expect(channelsPage.postDotMenu.remindMenuItem).toBeFocused();
// * Should hide Dot menu of Escape
await channelsPage.postDotMenu.container.press('Escape');
await expect(channelsPage.postDotMenu.container).toBeHidden();
});

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

@@ -0,0 +1,79 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {expect, test} from '@mattermost/playwright-lib';
test('/login accessibility quick check', async ({pw, axe}) => {
// Set up the page not to redirect to the landing page
await pw.hasSeenLandingPage();
// # Go to login page
await pw.loginPage.goto();
await pw.loginPage.toBeVisible();
// # Analyze the page
const accessibilityScanResults = await axe.builder(pw.loginPage.page).analyze();
// * Should have no violation
expect(accessibilityScanResults.violations).toHaveLength(0);
});
test('/login accessibility tab support', async ({pw}) => {
// Set up the page not to redirect to the landing page
await pw.hasSeenLandingPage();
// # Go to login page
await pw.loginPage.goto();
await pw.loginPage.toBeVisible();
// * Should have focused at login input on page load
expect(await pw.loginPage.loginInput).toBeFocused();
// * Should move focus to password input after tab
await pw.loginPage.loginInput.press('Tab');
expect(await pw.loginPage.passwordInput).toBeFocused();
// * Should move focus to password toggle button after tab
await pw.loginPage.passwordInput.press('Tab');
expect(await pw.loginPage.passwordToggleButton).toBeFocused();
// * Should move focus to forgot password link after tab
await pw.loginPage.passwordToggleButton.press('Tab');
expect(await pw.loginPage.forgotPasswordLink).toBeFocused();
// * Should move focus to forgot password link after tab
await pw.loginPage.forgotPasswordLink.press('Tab');
expect(await pw.loginPage.signInButton).toBeFocused();
// * Should move focus to about link after tab
await pw.loginPage.signInButton.press('Tab');
expect(await pw.loginPage.footer.aboutLink).toBeFocused();
// * Should move focus to privacy policy link after tab
await pw.loginPage.footer.aboutLink.press('Tab');
expect(await pw.loginPage.footer.privacyPolicyLink).toBeFocused();
// * Should move focus to terms link after tab
await pw.loginPage.footer.privacyPolicyLink.press('Tab');
expect(await pw.loginPage.footer.termsLink).toBeFocused();
// * Should move focus to help link after tab
await pw.loginPage.footer.termsLink.press('Tab');
expect(await pw.loginPage.footer.helpLink).toBeFocused();
// # Move focus to login input
await pw.loginPage.loginInput.focus();
expect(await pw.loginPage.loginInput).toBeFocused();
// * Should move focus to login body after shift+tab
await pw.loginPage.loginInput.press('Shift+Tab');
expect(await pw.loginPage.bodyCard).toBeFocused();
// * Should move focus to create account link after shift+tab
await pw.loginPage.bodyCard.press('Shift+Tab');
expect(await pw.loginPage.createAccountLink).toBeFocused();
// * Should move focus to login body after tab
await pw.loginPage.createAccountLink.press('Shift+Tab');
expect(await pw.loginPage.header.logo).toBeFocused();
});

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

@@ -0,0 +1,61 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {expect, test} from '@mattermost/playwright-lib';
test('/reset_password accessibility quick check', async ({pw, axe}) => {
// Set up the page not to redirect to the landing page
await pw.hasSeenLandingPage();
// # Go to reset password page
await pw.resetPasswordPage.goto();
await pw.resetPasswordPage.toBeVisible();
// # Analyze the page
const accessibilityScanResults = await axe
.builder(pw.resetPasswordPage.page, {disableColorContrast: true})
.analyze();
// * Should have no violation
expect(accessibilityScanResults.violations).toHaveLength(0);
});
test('/reset_password accessibility tab support', async ({pw}) => {
// Set up the page not to redirect to the landing page
await pw.hasSeenLandingPage();
// # Go to reset password page
await pw.resetPasswordPage.goto();
await pw.resetPasswordPage.toBeVisible();
// * Should have focused at email input on page load
expect(await pw.resetPasswordPage.emailInput).toBeFocused();
// * Should move focus to reset button after tab
await pw.resetPasswordPage.emailInput.press('Tab');
expect(await pw.resetPasswordPage.resetButton).toBeFocused();
// * Should move focus to about link after tab
await pw.resetPasswordPage.resetButton.press('Tab');
expect(await pw.resetPasswordPage.footer.aboutLink).toBeFocused();
// * Should move focus to privacy policy link after tab
await pw.resetPasswordPage.footer.aboutLink.press('Tab');
expect(await pw.resetPasswordPage.footer.privacyPolicyLink).toBeFocused();
// * Should move focus to terms link after tab
await pw.resetPasswordPage.footer.privacyPolicyLink.press('Tab');
expect(await pw.resetPasswordPage.footer.termsLink).toBeFocused();
// * Should move focus to help link after tab
await pw.resetPasswordPage.footer.termsLink.press('Tab');
expect(await pw.resetPasswordPage.footer.helpLink).toBeFocused();
// # Move focus to email input
await pw.resetPasswordPage.emailInput.focus();
expect(await pw.resetPasswordPage.emailInput).toBeFocused();
// * Should move focus to back button after shift+tab
await pw.resetPasswordPage.emailInput.press('Shift+Tab');
expect(await pw.resetPasswordPage.header.backButton).toBeFocused();
});

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

@@ -0,0 +1,115 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {expect, test} from '@mattermost/playwright-lib';
test('/signup_user_complete accessibility quick check', async ({pw, axe}) => {
// Set up the page not to redirect to the landing page
await pw.hasSeenLandingPage();
// # Go to reset password page
await pw.signupPage.goto();
await pw.signupPage.toBeVisible();
// # Analyze the page
const accessibilityScanResults = await axe
.builder(pw.signupPage.page, {disableColorContrast: true, disableLinkInTextBlock: true})
.analyze();
// * Should have no violation
expect(accessibilityScanResults.violations).toHaveLength(0);
});
test('/signup_user_complete accessibility tab support', async ({pw}, testInfo) => {
// Set up the page not to redirect to the landing page
await pw.hasSeenLandingPage();
// # Go to reset password page
await pw.signupPage.goto();
await pw.signupPage.toBeVisible();
// * Should have focused at email input on page load
expect(await pw.signupPage.emailInput).toBeFocused();
// * Should move focus to username input after tab
await pw.signupPage.emailInput.press('Tab');
expect(await pw.signupPage.usernameInput).toBeFocused();
// * Should move focus to password input after tab
await pw.signupPage.usernameInput.press('Tab');
expect(await pw.signupPage.passwordInput).toBeFocused();
// * Should move focus to password toggle button after tab
await pw.signupPage.passwordInput.press('Tab');
expect(await pw.signupPage.passwordToggleButton).toBeFocused();
// * Should move focus to newsletter checkbox after tab
await pw.signupPage.passwordToggleButton.press('Tab');
expect(await pw.signupPage.newsLetterCheckBox).toBeFocused();
// * Should move focus to newsletter privacy policy link after tab
await pw.signupPage.newsLetterCheckBox.press('Tab');
expect(await pw.signupPage.newsLetterPrivacyPolicyLink).toBeFocused();
// * Should move focus to newsletter unsubscribe link after tab
await pw.signupPage.newsLetterPrivacyPolicyLink.press('Tab');
expect(await pw.signupPage.newsLetterUnsubscribeLink).toBeFocused();
// * Should move focus to agreement terms of use link after tab
await pw.signupPage.newsLetterUnsubscribeLink.press('Tab');
expect(await pw.signupPage.agreementTermsOfUseLink).toBeFocused();
// * Should move focus to agreement privacy policy link after tab
await pw.signupPage.agreementTermsOfUseLink.press('Tab');
expect(await pw.signupPage.agreementPrivacyPolicyLink).toBeFocused();
// * Should move focus to privacy policy link after tab
await pw.signupPage.footer.aboutLink.press('Tab');
expect(await pw.signupPage.footer.privacyPolicyLink).toBeFocused();
// * Should move focus to terms link after tab
await pw.signupPage.footer.privacyPolicyLink.press('Tab');
expect(await pw.signupPage.footer.termsLink).toBeFocused();
// * Should move focus to help link after tab
await pw.signupPage.footer.termsLink.press('Tab');
expect(await pw.signupPage.footer.helpLink).toBeFocused();
// # Move focus to email input
await pw.signupPage.emailInput.focus();
expect(await pw.signupPage.emailInput).toBeFocused();
// * Should move focus to sign up body after shift+tab
await pw.signupPage.emailInput.press('Shift+Tab');
expect(await pw.signupPage.bodyCard).toBeFocused();
// * Should move focus to sign up body after shift+tab
await pw.signupPage.emailInput.press('Shift+Tab');
expect(await pw.signupPage.bodyCard).toBeFocused();
if (testInfo.project.name === 'ipad') {
// * Should move focus to header back button after shift+tab
await pw.signupPage.bodyCard.press('Shift+Tab');
expect(await pw.signupPage.header.backButton).toBeFocused();
// * Should move focus to log in link after shift+tab
await pw.signupPage.header.backButton.press('Shift+Tab');
expect(await pw.signupPage.loginLink).toBeFocused();
// * Should move focus to header logo after shift+tab
await pw.signupPage.loginLink.press('Shift+Tab');
expect(await pw.signupPage.header.logo).toBeFocused();
} else {
// * Should move focus to log in link after shift+tab
await pw.signupPage.bodyCard.press('Shift+Tab');
expect(await pw.signupPage.loginLink).toBeFocused();
// * Should move focus to header back button after shift+tab
await pw.signupPage.loginLink.press('Shift+Tab');
expect(await pw.signupPage.header.backButton).toBeFocused();
// * Should move focus to header logo after shift+tab
await pw.signupPage.header.backButton.press('Shift+Tab');
expect(await pw.signupPage.header.logo).toBeFocused();
}
});