Files
upstream-mattermost/e2e-tests/cypress/tests/support/common_login_commands.js
upstream-mirror 240db4e2a7
Some checks failed
Server CI / Postgres (shard 0) (push) Has been skipped
Server CI / Postgres (shard 3) (push) Has been skipped
BuildEnv Docker Image / build-image (push) Failing after 4s
BuildEnv Docker Image / build-image-fips (push) Failing after 4s
Migration Review & Release Notes / Generate migration review & release notes (push) Failing after 3s
Server CI / Build Environment (push) Failing after 3s
Server CI / Postgres (shard 1) (push) Has been skipped
Tools CI / check-style (mattermost-govet) (push) Failing after 4s
Server CI / Postgres (shard 2) (push) Has been skipped
Tools CI / check-style (mmgotool) (push) Failing after 3s
Server CI / Elasticsearch v8 Compatibility (push) Has been skipped
Server CI / OpenSearch v2 Compatibility (push) Has been skipped
Server CI / Postgres FIPS (shard 0) (push) Has been skipped
Tools CI / Test (mattermost-govet) (push) Failing after 3s
Server CI / Postgres FIPS (shard 1) (push) Has been skipped
Server CI / Postgres FIPS (shard 2) (push) Has been skipped
Tools CI / Test (mmgotool) (push) Failing after 3s
Server CI / Postgres FIPS (shard 3) (push) Has been skipped
Server CI / Run mmctl tests (push) Has been skipped
Server CI / Run mmctl tests (FIPS) (push) Has been skipped
Server CI / Merge Postgres Test Results (push) Has been skipped
Server CI / Merge Postgres FIPS Test Results (push) Has been skipped
Server CI / Check backport migrations (push) Has been skipped
Server CI / Check generated files (push) Has been skipped
Server CI / check-style (push) Has been skipped
Server CI / Vet API (push) Has been skipped
Server CI / Build mattermost server app (push) Has been skipped
Server CI / Server CI Complete (push) Failing after 2s
Server CI / Server CI Artifacts (push) Has been skipped
Server CI / Sentry Upload (push) Has been skipped
Server CI / Server CI Report (push) Failing after 5m1s
Server CI Nightly Race / Race Detector (push) Has been skipped
CodeQL / Analyze (go) (push) Has been cancelled
CodeQL / Analyze (javascript) (push) Has been cancelled
Webapp CI Cache Warm / Warm Webapp node_modules Cache (push) Has been cancelled
E2E CI Cache Warm / Warm E2E npm Registry Cache (push) Has been cancelled
API / build (push) Has been cancelled
Web App CI / check-types (push) Has been cancelled
Web App CI / check-lint (push) Has been cancelled
Web App CI / check-i18n (push) Has been cancelled
Web App CI / check-external-links (push) Has been cancelled
Web App CI / test (platform) (push) Has been cancelled
Web App CI / test (mattermost-redux) (push) Has been cancelled
Web App CI / test (channels shard 1/4) (push) Has been cancelled
Web App CI / test (channels shard 2/4) (push) Has been cancelled
Web App CI / test (channels shard 3/4) (push) Has been cancelled
Web App CI / test (channels shard 4/4) (push) Has been cancelled
Web App CI / upload-coverage (push) Has been cancelled
Web App CI / build (push) Has been cancelled
YAML Lint / yamllint (push) Has been cancelled
Push mirrored docker images / cd/Push mirrored docker images (push) Has been cancelled
docs-cd / Build and deploy docs (push) Has been cancelled
Docs CI / build (push) Has been cancelled
E2E Cache Warm: Cypress deps / Warm Cypress deps cache (push) Has been cancelled
Scorecards supply-chain security / Scorecard analysis (push) Has been cancelled
Server CI Weekly / Postgres FIPS (push) Has been skipped
Server CI Weekly / Run mmctl tests (FIPS) (push) Has been skipped
Server CI Weekly / Postgres with binary parameters (push) Has been skipped
Server CI Weekly / Build Environment (push) Failing after 1s
Server CI Cache Warm / Warm Go Module and Build Cache (push) Failing after 2s
Server CI Nightly Race / Build Environment (push) Failing after 1s
snapshot of https://github.com/mattermost/mattermost.git (master, 2026-09-16; blobs > 131072B omitted)
2026-09-16 00:29:55 +05:00

130 lines
4.8 KiB
JavaScript

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import * as TIMEOUTS from '../fixtures/timeouts';
Cypress.Commands.add('checkLoginPage', (settings = {}) => {
// # Remove autofocus from login input
cy.get('.login-body-card-title').click();
// * Check elements in the body
cy.get('#input_loginId', {timeout: TIMEOUTS.ONE_MIN}).should('be.visible').and(($loginTextbox) => {
const placeholder = $loginTextbox[0].placeholder;
expect(placeholder).to.match(/Email/);
expect(placeholder).to.match(/Username/);
}).focus();
cy.get('#input_password-input').should('be.visible').and('have.attr', 'placeholder', 'Password');
cy.get('#saveSetting').should('be.visible');
// * Check the title
cy.title().should('include', settings.siteName);
});
Cypress.Commands.add('checkLoginFailed', () => {
// * Check the alert banner
cy.get('.AlertBanner.danger', {timeout: TIMEOUTS.ONE_MIN}).then(() => {
// * Check the login input in error
cy.get('.login-body-card-form-input .Input_fieldset').should('have.class', 'Input_fieldset___error');
// * Check the password input in error
cy.get('.login-body-card-form-password-input.Input_fieldset').should('have.class', 'Input_fieldset___error');
// * Check the Log in button enabled
cy.get('#saveSetting').should('not.be.disabled');
});
});
Cypress.Commands.add('checkGuestNoChannels', () => {
cy.findByText('Your guest account has no channels assigned. Please contact an administrator.').should('be.visible');
});
Cypress.Commands.add('checkMemberNoChannels', () => {
cy.findByText('No teams are available to join. Please create a new team or ask your administrator for an invite.').should('be.visible');
});
Cypress.Commands.add('checkLeftSideBar', (settings = {}) => {
if (settings.teamName != null && settings.teamName.length > 0) {
cy.uiGetLHSHeader().should('contain', settings.teamName);
}
if (settings.user.username.length > 0) {
// * Verify username info
cy.uiOpenUserMenu().findByText(`@${settings.user.username}`);
// # Close status menu
cy.get('body').type('{esc}');
}
if (settings.user.userType === 'Admin' || settings.user.isAdmin) {
// # Check that user is an admin
cy.uiOpenProductMenu().findByText('System Console');
} else {
// # Check that user is not an admin
cy.uiOpenProductMenu().findByText('System Console').should('not.exist');
}
// # Close product switch menu
cy.uiGetProductMenuButton().click();
cy.get('#channel_view').should('be.visible');
});
Cypress.Commands.add('checkInvitePeoplePage', (settings = {}) => {
cy.findByText('Copy invite link', {timeout: TIMEOUTS.ONE_MIN}).should('be.visible');
if (settings.teamName != null && settings.teamName.length > 0) {
const inviteRegexp = new RegExp(`Invite .* to ${settings.teamName}`);
cy.findByText(inviteRegexp).should('be.visible');
}
});
Cypress.Commands.add('checkInvitePeopleAdminPage', (settings = {}) => {
cy.findByText('Members', {timeout: TIMEOUTS.ONE_MIN}).should('be.visible');
cy.findByText('Guests').should('be.visible');
if (settings.teamName != null && settings.teamName.length > 0) {
cy.findByText('Invite people to ' + settings.teamName).should('be.visible');
}
});
Cypress.Commands.add('doLogoutFromSignUp', () => {
cy.checkGuestNoChannels();
cy.findByText('Logout').should('be.visible').click();
});
Cypress.Commands.add('doMemberLogoutFromSignUp', () => {
cy.checkMemberNoChannels();
cy.findByText('Logout').should('be.visible').click();
});
Cypress.Commands.add('skipOrCreateTeam', (settings, userId) => {
cy.wait(TIMEOUTS.FIVE_SEC);
return cy.get('body').then((body) => {
let teamName = '';
// # Create a team if a user is not member of any team
if (body.text().includes('Create a team')) {
teamName = 't' + userId.substring(0, 14);
cy.checkCreateTeamPage(settings);
cy.get('#createNewTeamLink').scrollIntoView().should('be.visible').click();
cy.get('#teamNameInput').should('be.visible').typeWithForce(teamName);
cy.findByText('Next').should('be.visible').click();
cy.findByText('Finish').should('be.visible').click();
}
return cy.wrap(teamName);
});
});
Cypress.Commands.add('checkForLDAPError', () => {
cy.wait(TIMEOUTS.FIVE_SEC);
return cy.get('body').then((body) => {
if (body.text().includes('User not registered on AD/LDAP server.')) {
cy.findByText('Back to Mattermost').should('exist').and('be.visible').click().wait(TIMEOUTS.FIVE_SEC);
return cy.wrap(true);
}
return cy.wrap(false);
});
});