mirror of
https://github.com/hanzoai/team.git
synced 2026-09-30 01:57:35 +00:00
* 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
127 lines
4.0 KiB
TypeScript
127 lines
4.0 KiB
TypeScript
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
import type {AdminConfig} from '@mattermost/types/config';
|
|
|
|
import * as TIMEOUTS from '../fixtures/timeouts';
|
|
import type {ChainableT} from '../types';
|
|
import {stubClipboard} from '../utils';
|
|
|
|
// SAMLUser interface is based on cypress/tests/fixtures/saml_users.json
|
|
interface SAMLUser {
|
|
username: string;
|
|
password: string;
|
|
email: string;
|
|
firstname: string;
|
|
lastname: string;
|
|
userType: string;
|
|
isGuest?: boolean;
|
|
}
|
|
|
|
interface TestSettings {
|
|
loginButtonText: string;
|
|
siteName: string;
|
|
siteUrl: string;
|
|
teamName: string;
|
|
user: SAMLUser | null;
|
|
}
|
|
|
|
/**
|
|
* checkCreateTeamPage checks that the "create a team" element is visible in the page if user is not a Guest.
|
|
* Otherwise it should not exist.
|
|
* @param {TestSettings} settings - Settings object
|
|
*/
|
|
function checkCreateTeamPage(settings: TestSettings) {
|
|
if (settings.user!.userType === 'Guest' || settings.user!.isGuest) {
|
|
cy.findByText('Create a team').scrollIntoView().should('not.exist');
|
|
} else {
|
|
cy.findByText('Create a team').scrollIntoView().should('be.visible');
|
|
}
|
|
}
|
|
|
|
Cypress.Commands.add('checkCreateTeamPage', checkCreateTeamPage);
|
|
|
|
/**
|
|
* doSamlLogin check that the login page is loaded with the correct settings (siteName) and logs in using SAML.
|
|
* @param {TestSettings} settings - Settings object to perform SAML tests.
|
|
*/
|
|
function doSamlLogin(settings: TestSettings) {
|
|
// # Go to login page
|
|
cy.apiLogout();
|
|
cy.visit('/login');
|
|
cy.checkLoginPage(settings);
|
|
|
|
//click the login button
|
|
return cy.findByText(settings.loginButtonText).should('be.visible').click().wait(TIMEOUTS.ONE_SEC);
|
|
}
|
|
|
|
Cypress.Commands.add('doSamlLogin', doSamlLogin);
|
|
|
|
/**
|
|
* doSamlLogout logs out and checks that it reloads the login page with the correct settings (siteName).
|
|
* @param {TestSettings} settings - Settings object to perform SAML tests.
|
|
*/
|
|
function doSamlLogout(settings: TestSettings) {
|
|
cy.checkLeftSideBar(settings);
|
|
|
|
// # Logout then check login page
|
|
cy.uiLogout();
|
|
return cy.checkLoginPage(settings);
|
|
}
|
|
|
|
Cypress.Commands.add('doSamlLogout', doSamlLogout);
|
|
|
|
/**
|
|
* getInvitePeopleLink gets the invite people link from the invite people modal
|
|
* @param {TestSettings} settings - Settings object to perform SAML tests.
|
|
* @returns {ChainableT<string>} - the invite people link wrapped in a cypress chainable
|
|
*/
|
|
function getInvitePeopleLink(settings: TestSettings) {
|
|
cy.checkLeftSideBar(settings);
|
|
|
|
// # Open team menu and click 'Invite People'
|
|
cy.uiOpenTeamMenu('Invite people');
|
|
|
|
stubClipboard().as('clipboard');
|
|
cy.checkInvitePeoplePage();
|
|
cy.findByTestId('InviteView__copyInviteLink').click();
|
|
return cy.get('@clipboard').its('contents').then((text) => {
|
|
// # Close Invite People modal
|
|
cy.uiClose();
|
|
return cy.wrap(text);
|
|
});
|
|
}
|
|
|
|
Cypress.Commands.add('getInvitePeopleLink', getInvitePeopleLink);
|
|
|
|
/**
|
|
* setTestSettings sets the test settings object based on the AdminConfig
|
|
* @param {string} loginButtonText - The text of the login button
|
|
* @param {AdminConfig} config - The config object
|
|
* @returns {TestSettings} - The settings to use for SAML tests
|
|
*/
|
|
function setTestSettings(loginButtonText: string, config: AdminConfig): ChainableT<TestSettings> {
|
|
return cy.wrap<TestSettings>({
|
|
loginButtonText,
|
|
siteName: config.TeamSettings.SiteName,
|
|
siteUrl: config.ServiceSettings.SiteURL,
|
|
teamName: '',
|
|
user: null,
|
|
});
|
|
}
|
|
|
|
Cypress.Commands.add('setTestSettings', setTestSettings);
|
|
|
|
declare global {
|
|
// eslint-disable-next-line @typescript-eslint/no-namespace
|
|
namespace Cypress {
|
|
interface Chainable {
|
|
checkCreateTeamPage: typeof checkCreateTeamPage;
|
|
doSamlLogin: typeof doSamlLogin;
|
|
doSamlLogout: typeof doSamlLogout;
|
|
getInvitePeopleLink: typeof getInvitePeopleLink;
|
|
setTestSettings: typeof setTestSettings;
|
|
}
|
|
}
|
|
}
|