fix: E2E/Tests related to create account and invite people (#34953)

* fix: e2e tests related to create account and invite people

* fix failed test
This commit is contained in:
sabril 2026-01-20 23:59:47 +08:00 committed by GitHub
parent 28bcb6394b
commit 3ebc90bde0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 44 additions and 32 deletions

View file

@ -151,7 +151,7 @@ describe('Authentication', () => {
['1user', 'te', 'user#1', 'user!1'].forEach((option) => {
cy.get('#input_name').clear().type(option);
cy.findByText('Create Account').click();
cy.findByText('Create account').click();
// * Assert the error is what is expected;
cy.get('.Input___error').scrollIntoView().should('be.visible');
@ -183,7 +183,7 @@ describe('Authentication', () => {
cy.get('#input_name').clear().type(`Test${getRandomId()}`);
cy.findByText('Create Account').click();
cy.findByText('Create account').click();
// * Make sure account was created successfully and we are on the team joining page
cy.findByText('Teams you can join:', {timeout: TIMEOUTS.ONE_MIN}).should('be.visible');
@ -245,7 +245,7 @@ describe('Authentication', () => {
cy.get('#input_name').clear().type(`Test${getRandomId()}`);
cy.findByText('Create Account').click();
cy.findByText('Create account').click();
// * Make sure account was not created successfully
cy.get('.AlertBanner__title').scrollIntoView().should('be.visible');
@ -271,7 +271,7 @@ describe('Authentication', () => {
cy.findByText('Copy invite link').click();
// # Input email, select member
cy.findByLabelText('Add or Invite People').type(`test-${getRandomId()}@mattermost.com{downarrow}{downarrow}{enter}`, {force: true});
cy.findByLabelText('Invite People').type(`test-${getRandomId()}@mattermost.com{downarrow}{downarrow}{enter}`, {force: true});
// # Click invite members button
cy.findByRole('button', {name: 'Invite'}).click({force: true});

View file

@ -78,13 +78,16 @@ describe('Guest Accounts', () => {
// # Click "Save".
cy.findByText('Save').click().wait(TIMEOUTS.ONE_SEC);
// # Get MFA secret
// # Visit a page to trigger MFA setup redirect, then complete MFA setup for admin
cy.visit('/');
cy.url().should('include', 'mfa/setup');
cy.uiGetMFASecret(sysadmin.id).then((secret) => {
adminMFASecret = secret;
});
// # Navigate to Guest Access page.
cy.visit('/admin_console/authentication/guest_access');
cy.url().should('include', '/admin_console/authentication/guest_access');
// # Enable guest accounts.
cy.findByTestId('GuestAccountsSettings.Enabletrue').check();
@ -144,20 +147,20 @@ describe('Guest Accounts', () => {
// # Create an account with Email and Password.
cy.get('#input_name').type(username);
cy.get('#input_password-input').type(username);
cy.findByText('Create Account').click();
cy.findByText('Create account').click();
// * When MFA is enforced for Guest Access, guest user should be forced to configure MFA while creating an account.
cy.url().should('include', 'mfa/setup');
cy.get('#mfa').wait(TIMEOUTS.HALF_SEC).find('.col-sm-12').then((p) => {
cy.get('#mfa').wait(TIMEOUTS.HALF_SEC).find('p.col-sm-12 span').then((p) => {
const secretp = p.text();
const secret = secretp.split(' ')[1];
const token = authenticator.generateToken(secret);
cy.get('#mfa').find('.form-control').type(token);
cy.get('#mfa').find('.btn.btn-primary').click();
cy.findByPlaceholderText('MFA Code').type(token);
cy.findByText('Save').click();
cy.wait(TIMEOUTS.ONE_SEC);
cy.get('#mfa').find('.btn.btn-primary').click();
cy.findByText('Okay').click();
});
cy.apiLogout();
});

View file

@ -106,7 +106,7 @@ describe('Guest Account - Member Invitation Flow', () => {
cy.get('#input_email').type(email);
cy.get('#input_name').type(username);
cy.get('#input_password-input').type('Testing123');
cy.findByText('Create Account').click();
cy.findByText('Create account').click();
// * Verify if user is added to the invited team
cy.uiGetLHSHeader().findByText(testTeam.display_name);

View file

@ -91,7 +91,7 @@ describe('Onboarding', () => {
cy.get('#name').should('be.visible').type(usernameTwo);
cy.get('#password').should('be.visible').type(password);
// # Attempt to create an account by clicking on the 'Create Account' button
// # Attempt to create an account by clicking on the 'Create account' button
cy.get('#createAccountButton').click();
// * Ensure that since the invite was invalidated, the correct error message should be shown
@ -99,7 +99,7 @@ describe('Onboarding', () => {
});
function inviteNewUser(email) {
cy.findByRole('textbox', {name: 'Add or Invite People'}).
cy.findByRole('textbox', {name: 'Invite People'}).
typeWithForce(email).wait(TIMEOUTS.HALF_SEC).
typeWithForce('{enter}');
cy.findByTestId('inviteButton').click();

View file

@ -54,11 +54,6 @@ describe('Signup Email page', () => {
});
it('should match elements, body', () => {
const {
PRIVACY_POLICY_LINK,
TERMS_OF_SERVICE_LINK,
} = FixedCloudConfig.SupportSettings;
// * Check elements in the body
cy.get('.signup-body').should('be.visible');
cy.get('.header-logo-link').should('be.visible');
@ -78,11 +73,15 @@ describe('Signup Email page', () => {
cy.findByText('Your password must be 5-72 characters long.').should('be.visible');
cy.get('#saveSetting').scrollIntoView().should('be.visible');
cy.get('#saveSetting').should('contain', 'Create Account');
cy.get('#saveSetting').should('contain', 'Create account');
cy.get('.signup-body-card-agreement').should('contain', `By proceeding to create your account and use ${config.TeamSettings.SiteName}, you agree to our Terms of Use and Privacy Policy. If you do not agree, you cannot use ${config.TeamSettings.SiteName}.`);
cy.get(`.signup-body-card-agreement > span > [href="${config.SupportSettings.TermsOfServiceLink || TERMS_OF_SERVICE_LINK}"]`).should('be.visible');
cy.get(`.signup-body-card-agreement > span > [href="${config.SupportSettings.PrivacyPolicyLink || PRIVACY_POLICY_LINK}"]`).should('be.visible');
// * Check newsletter subscription checkbox text and links
cy.findByText('I would like to receive Mattermost security updates via newsletter.').should('be.visible');
cy.findByText(/By subscribing, I consent to receive emails from Mattermost with product updates, promotions, and company news\./).should('be.visible');
cy.findByText(/I have read the/).parent().within(() => {
cy.findByRole('link', {name: 'Privacy Policy'}).should('be.visible').and('have.attr', 'href').and('include', 'mattermost.com/pl/privacy-policy/');
cy.findByRole('link', {name: 'unsubscribe'}).should('be.visible').and('have.attr', 'href').and('include', 'forms.mattermost.com/UnsubscribePage.html');
});
});
it('should match elements, footer', () => {

View file

@ -36,7 +36,7 @@ export const inviteUserByEmail = (email) => {
// # Wait half a second to ensure that the modal has been fully loaded
cy.wait(TIMEOUTS.HALF_SEC);
cy.findByRole('textbox', {name: 'Add or Invite People'}).
cy.findByRole('textbox', {name: 'Invite People'}).
typeWithForce(email).
wait(TIMEOUTS.HALF_SEC).
typeWithForce('{enter}');
@ -71,7 +71,7 @@ export const signupAndVerifyTutorial = (username, password, teamDisplayName) =>
cy.get('#name', {timeout: TIMEOUTS.HALF_MIN}).should('be.visible').type(username);
cy.get('#password').should('be.visible').type(password);
// # Attempt to create an account by clicking on the 'Create Account' button
// # Attempt to create an account by clicking on the 'Create account' button
cy.get('#createAccountButton').click();
// # Close the onboarding tutorial

View file

@ -49,11 +49,14 @@ describe('Team Settings', () => {
// # Set 'sample.mattermost.com' as the only allowed email domain and save
cy.get('#allowedDomains').click().type(emailDomain).type(' ');
cy.findByText('Save').should('be.visible').click();
// # Close the modal
cy.get('#teamSettingsModalLabel').find('button').should('be.visible').click();
});
// # Close the modal
cy.findByLabelText('Close').click();
// * Wait for modal to be closed
cy.get('#teamSettingsModal').should('not.exist');
// # Open team menu and click 'Invite People'
cy.uiOpenTeamMenu('Invite people');
@ -63,7 +66,7 @@ describe('Team Settings', () => {
// * Assert that the user has successfully been invited to the team
cy.get('.invitation-modal-confirm--sent').should('be.visible').within(() => {
cy.get('.username-or-icon').find('span').eq(0).should('have.text', userDetailsString);
cy.get('.InviteResultRow').find('div').eq(1).should('have.text', inviteSuccessMessage);
cy.get('.InviteResultRow').find('.reason').should('have.text', inviteSuccessMessage);
});
// # Click on the 'Invite More People button'
@ -75,14 +78,14 @@ describe('Team Settings', () => {
// * Assert that the invite failed and the correct error message is shown
cy.get('.invitation-modal-confirm--not-sent').should('be.visible').within(() => {
cy.get('.username-or-icon').find('span').eq(1).should('have.text', invalidEmail);
cy.get('.InviteResultRow').find('div').eq(1).should('have.text', inviteFailedMessage);
cy.get('.InviteResultRow').find('.reason').should('have.text', inviteFailedMessage);
});
});
function inviteNewMemberToTeam(email) {
cy.wait(TIMEOUTS.HALF_SEC);
cy.findByRole('combobox', {name: 'Add or Invite People'}).
cy.findByRole('combobox', {name: 'Invite People'}).
typeWithForce(email).
wait(TIMEOUTS.HALF_SEC).
typeWithForce('{enter}');

View file

@ -41,7 +41,7 @@ export default class SignupPage {
this.usernameInput = page.locator('#input_name');
this.passwordInput = page.locator('#input_password-input');
this.passwordToggleButton = page.locator('#password_toggle');
this.createAccountButton = page.locator('button:has-text("Create Account")');
this.createAccountButton = page.locator('button:has-text("Create account")');
this.emailError = page.locator('text=Please enter a valid email address');
this.usernameError = page.locator(
'text=Usernames have to begin with a lowercase letter and be 3-22 characters long. You can use lowercase letters, numbers, periods, dashes, and underscores.',

View file

@ -173,5 +173,12 @@ test('MM-63378 System Manager without team access permissions cannot view team d
await expect(teamStatsHeading).toBeVisible();
// Verify the user has no API access to the otherTeam.
await expect(systemManagerClient.getTeam(otherTeam.id)).rejects.toThrow();
let apiError: Error | null = null;
try {
await systemManagerClient.getTeam(otherTeam.id);
} catch (error) {
apiError = error as Error;
}
expect(apiError).not.toBeNull();
expect(apiError?.message).toContain('You do not have the appropriate permissions');
});