Files
Harrison HealeyandGitHub daec1283e5 MM-69003 Mostly share ESLint config between web app and E2E tests (#36767)
* Switch Cypress to use shared ESLint config

* Run --fix in Cypress

* Manually fix remaining lint issues in Cypress

* Switch Playwright to use shared ESLint config

* Run --fix in Playwright

* Manually fix remaining lint issues in Playwright

* Install and cache web app deps during Cypress CI builds

This also caches the types and client package. That isn't needed currently
since it uses prepackaged versions of those, but I imagine we might change
that at some point.

* Run e2e-tests-check when ESLint plugin is updated

* Change E2E test GHA caching to cache all of web app node_modules

* Fix mismatch between cache save and restore

* Try bumping cache keys

* Copy step to install dependencies to server.run_cypress.sh

I don't know how this must've worked before, but if this fixes the issue,
it seems like neither Cypress nor Playwright actually use the cached
depenendencies.

* Try disabling caching entirely for Cypress tests

* Try bypassing makefile?

* Try also manually building dependencies in run_specs.sh

I don't know why this appears to duplicate run_cypress.sh and
run_playwright.sh, both of which are called run_test.sh which
might not be used any more as best I can tell.

* Try installing the web app dependencies in yet another place

* Disable the extra steps in server.prepare.sh specifically for Cypress

* Revert changes to update cache key and disable web app depenedency cache on Cypress builds
2026-06-09 20:50:58 +00:00

105 lines
3.3 KiB
TypeScript

// 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.
// ***************************************************************
import type {
SimpleUser,
} from './helpers';
import {
getPostTextboxInput,
getQuickChannelSwitcherInput,
startAtMention,
verifySuggestionAtChannelSwitcher,
verifySuggestionAtPostTextbox,
} from './helpers';
export function doTestPostextbox(mention: string, ...suggestion: SimpleUser[]) {
getPostTextboxInput();
startAtMention(mention);
verifySuggestionAtPostTextbox(...suggestion);
}
export function doTestQuickChannelSwitcher(mention: string, ...suggestion: SimpleUser[]) {
getQuickChannelSwitcherInput();
startAtMention(mention);
verifySuggestionAtChannelSwitcher(...suggestion);
}
export function doTestUserChannelSection(prefix: string, testTeam: Cypress.Team, testUsers: Record<string, SimpleUser>) {
const thor = testUsers.thor;
const loki = testUsers.loki;
// # Create new channel and add user to channel
const channelName = 'new-channel';
cy.apiCreateChannel(testTeam.id, channelName, channelName).then(({channel}) => {
cy.apiGetUserByEmail(thor.email).then(({user}) => {
cy.apiAddUserToChannel(channel.id, user.id);
});
cy.visit(`/${testTeam.name}/channels/${channel.name}`);
});
// # Start an at mention that should return 2 users (in this case, the users share a last name)
cy.uiGetPostTextBox().
as('input').
clear().
type(`@${prefix}odinson`);
// * Thor should be a channel member
cy.uiVerifyAtMentionInSuggestionList(thor, true);
// * Loki should NOT be a channel member
cy.uiVerifyAtMentionInSuggestionList(loki, false);
}
export function doTestDMChannelSidebar(testUsers: Record<string, SimpleUser>) {
const thor = testUsers.thor;
// # Open of the add direct message modal
cy.uiAddDirectMessage().click({force: true});
// # Type username into input
cy.get('.more-direct-channels').
find('input').
should('exist').
type(thor.username, {force: true});
cy.intercept({
method: 'POST',
url: '/api/v4/users/search',
}).as('searchUsers');
cy.wait('@searchUsers').then((interception) => {
expect(interception.response?.body).to.have.length(1);
});
// * There should only be one result
cy.get('#moreDmModal').find('.more-modal__row').
as('result').
its('length').
should('equal', 1);
// * Result should have appropriate text
cy.get('@result').
find('.more-modal__name').
should('have.text', `@${thor.username} - ${thor.first_name} ${thor.last_name} (${thor.nickname})`);
cy.get('@result').
find('.more-modal__description').
should('have.text', thor.email);
// # Click on the result to add user
cy.get('@result').click({force: true});
// # Click "Go"
cy.uiGetButton('Go').click();
// # Should land on direct message channel for that user
cy.get('#channelHeaderTitle').should('have.text', thor.username + ' ');
}