Files
Jesse HallamandGitHub 5d2a8ba29c Fix flaky E2E tests (Cypress + Playwright) (#36637)
* Fix flaky email sort test by ignoring punctuation in localeCompare

PostgreSQL's en_US.UTF-8 collation ignores hyphens at the primary sort
level, but JS localeCompare() on a C-locale CI runner uses byte order,
causing the expected and actual sort orders to diverge for emails
containing hyphens. Passing ignorePunctuation:true aligns JS collation
with Postgres behavior.

* E2E/Cypress: re-enable CYPRESS_* env var overrides

allowCypressEnv: false was introduced in the v15.13 upgrade (PR #36091)
but broke the existing CYPRESS_adminUsername / CYPRESS_adminPassword
override mechanism that local and CI runners depend on.

* E2E/Cypress: fix MM-T1508 accessibility image test flakiness

The test was failing because the admin user could have a stale
compact display mode preference from a previous spec, causing
post avatars to render with pointer-events: none and blocking
the .status-wrapper click.

Two fixes:
- resetUserPreference() now resets message_display to 'clean'
  so compact mode doesn't leak across spec files
- accessibility_image_spec before() now runs as a fresh user
  with default preferences rather than the shared admin account
2026-05-20 10:46:17 +08:00

86 lines
3.2 KiB
JavaScript

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
// ***************************************************************
// - [#] indicates a test step (e.g. # Go to a page)
// - [*] indicates an assertion (e.g. * Check the title)
// - Use element ID when selecting an element. Create one if none.
// ***************************************************************
// Stage: @prod
// Group: @channels @accessibility
// * Verify the accessibility support in the different images
describe('Verify Accessibility Support in Different Images', () => {
let otherUser;
before(() => {
cy.apiInitSetup().then(({team, offTopicUrl, user}) => {
cy.apiCreateUser({prefix: 'other'}).then(({user: user1}) => {
otherUser = user1;
return cy.apiAddUserToTeam(team.id, otherUser.id);
}).then(() => {
cy.apiLogin(user);
// Visit the Off Topic channel
cy.visit(offTopicUrl);
});
});
});
it('MM-T1508 Accessibility support in different images', () => {
// * Verify image alt in profile image
cy.get('#userAccountMenuButton').within(() => {
cy.findByAltText('user profile image').should('be.visible');
});
// # Upload an image in the post
cy.get('#fileUploadInput').attachFile('small-image.png');
cy.postMessage('Image upload');
// * Verify accessibility in images uploaded in a post
cy.getLastPostId().then((postId) => {
cy.get(`#${postId}_message`).within(() => {
cy.get('img').should('be.visible').should('have.attr', 'aria-label', 'file thumbnail small-image.png');
});
});
// # Post a message as a different user
cy.getCurrentChannelId().then((channelId) => {
const message = `hello from ${otherUser.username}: ${Date.now()}`;
cy.postMessageAs({sender: otherUser, message, channelId});
});
// # Open profile popover
cy.getLastPostId().then((postId) => {
cy.get(`#post_${postId}`).within(() => {
cy.get('.status-wrapper').click();
});
// * Verify image alt in profile popover
cy.get('.user-profile-popover').within(() => {
cy.get('.Avatar').should('have.attr', 'alt', `${otherUser.username} profile image`);
});
});
// # Close the profile popover
cy.get('body').click();
// # Open Settings > Display > Themes
cy.uiOpenSettingsModal('Display').within(() => {
cy.get('#displayButton').click();
cy.get('#displaySettingsTitle').should('exist');
cy.get('#themeTitle').scrollIntoView().should('be.visible');
cy.get('#themeEdit').click();
// * Verify image alt in Theme Images
cy.get('#displaySettings').within(() => {
cy.get('.appearance-section>div').children().each(($el) => {
cy.wrap($el).get('#denim-theme-icon').should('have.text', 'Denim theme icon');
});
});
});
});
});