From 16ad5739794f795bbdb65cc5153fbd69d2d3efd5 Mon Sep 17 00:00:00 2001 From: Saturnino Abril Date: Wed, 14 Jun 2023 07:56:23 +0800 Subject: [PATCH] fix: known failed E2E tests (#23708) --- .../archive_channel_reaction_spec.ts | 4 +- .../auth_sso/authentication_1_spec.ts | 147 +++++++++--------- .../auth_sso/authentication_2_spec.ts | 4 +- .../auth_sso/authentication_4_spec.ts | 20 ++- .../channel/new_channel_with_board_spec.js | 4 +- .../custom_status/custom_status_1_spec.ts | 7 +- .../auth_sso/authentication_spec.js | 79 +++++----- .../cypress/tests/support/api/preference.js | 6 + e2e-tests/cypress/tests/support/api/setup.ts | 4 +- e2e-tests/cypress/tests/support/api/user.d.ts | 1 + e2e-tests/cypress/tests/support/api/user.js | 6 +- .../cypress/tests/support/ui/channel.d.ts | 1 + e2e-tests/cypress/tests/support/ui/channel.js | 6 +- 13 files changed, 152 insertions(+), 137 deletions(-) diff --git a/e2e-tests/cypress/tests/integration/channels/archived_channel/archive_channel_reaction_spec.ts b/e2e-tests/cypress/tests/integration/channels/archived_channel/archive_channel_reaction_spec.ts index 6130219d531..e778940716d 100644 --- a/e2e-tests/cypress/tests/integration/channels/archived_channel/archive_channel_reaction_spec.ts +++ b/e2e-tests/cypress/tests/integration/channels/archived_channel/archive_channel_reaction_spec.ts @@ -41,6 +41,7 @@ describe('Archived channels', () => { cy.wait(TIMEOUTS.HALF_SEC).get(`#CENTER_reaction_${postId}`).should('be.visible'); // # Archive the channel + cy.get('body').type('{esc}'); cy.uiArchiveChannel(); // # Click on post dot menu so we can check for reaction icon @@ -50,7 +51,7 @@ describe('Archived channels', () => { cy.wait(TIMEOUTS.HALF_SEC).get(`#CENTER_reaction_${postId}`).should('not.exist'); // # Remove focus so we can open RHS - cy.get('#channel_view').click(); + cy.get('body').type('{esc}'); // # Open RHS for the post cy.clickPostCommentIcon(postId); @@ -62,6 +63,7 @@ describe('Archived channels', () => { cy.wait(TIMEOUTS.HALF_SEC).get(`#RHS_ROOT_reaction_${postId}`).should('not.exist'); // # Search for "Test archive reaction" + cy.get('body').type('{esc}'); cy.get('#searchBox').should('be.visible').type(messageText).type('{enter}'); // # Click on post dot menu so we can check for reaction icon diff --git a/e2e-tests/cypress/tests/integration/channels/auth_sso/authentication_1_spec.ts b/e2e-tests/cypress/tests/integration/channels/auth_sso/authentication_1_spec.ts index db4b4c2bb58..8f3b02e29a3 100644 --- a/e2e-tests/cypress/tests/integration/channels/auth_sso/authentication_1_spec.ts +++ b/e2e-tests/cypress/tests/integration/channels/auth_sso/authentication_1_spec.ts @@ -11,10 +11,10 @@ // Group: @channels @system_console @authentication import * as TIMEOUTS from '../../../fixtures/timeouts'; - import {getRandomId} from '../../../utils'; describe('Authentication', () => { + const restrictCreationToDomains = 'mattermost.com, test.com'; let testUser; let testUserAlreadyInTeam; let testTeam; @@ -41,84 +41,83 @@ describe('Authentication', () => { // # Set restricted domain cy.apiUpdateConfig({ TeamSettings: { - RestrictCreationToDomains: 'mattermost.com, test.com', + RestrictCreationToDomains: restrictCreationToDomains, }, - }).then(() => { - cy.apiLogout(); - - // # Go to front page - cy.visit('/login'); - - // * Assert that create account button is visible - cy.findByText('Don\'t have an account?', {timeout: TIMEOUTS.ONE_MIN}).should('be.visible'); - - // # Go to sign up with email page - cy.visit('/signup_user_complete'); - - cy.get('#input_email', {timeout: TIMEOUTS.ONE_MIN}).type(`Hossein2Cool4School${getRandomId()}@mattermost.com`); - - cy.get('#input_password-input').type('Test123456!'); - - cy.get('#input_name').clear().type(`HosseinIs2Cool${getRandomId()}`); - - cy.findByText('Create Account').click(); - - // * Make sure account was created successfully and we are at the select team page - cy.findByText('Teams you can join:', {timeout: TIMEOUTS.ONE_MIN}).should('be.visible'); }); + + // # Log out and go to login page + cy.apiLogout(); + cy.visit('/login'); + + // * Assert that create account button is visible + cy.findByText('Don\'t have an account?', {timeout: TIMEOUTS.ONE_MIN}).should('be.visible'); + + // # Go to sign up with email page + cy.visit('/signup_user_complete'); + + cy.get('#input_email', {timeout: TIMEOUTS.ONE_MIN}).type(`test-${getRandomId()}@mattermost.com`); + + cy.get('#input_password-input').type('Test123456!'); + + cy.get('#input_name').clear().type(`test${getRandomId()}`); + + cy.findByText('Create Account').click(); + + // * Make sure account was created successfully and we are at the select team page + cy.findByText('Teams you can join:', {timeout: TIMEOUTS.ONE_MIN}).should('be.visible'); }); it('MM-T1757 - Restrict Domains - Multiple - fail', () => { // # Set restricted domain cy.apiUpdateConfig({ TeamSettings: { - RestrictCreationToDomains: 'mattermost.com, test.com', + RestrictCreationToDomains: restrictCreationToDomains, }, - }).then(() => { - cy.apiLogin(testUserAlreadyInTeam); - cy.visit('/'); - - // # Open Profile - cy.uiOpenProfileModal('Profile Settings'); - - // # Click "Edit" to the right of "Email" - cy.get('#emailEdit').should('be.visible').click(); - - // # Type new email - cy.get('#primaryEmail').should('be.visible').type('user-123123@example.com'); - cy.get('#confirmEmail').should('be.visible').type('user-123123@example.com'); - cy.get('#currentPassword').should('be.visible').type(testUser.password); - - // # Save the settings - cy.uiSave().wait(TIMEOUTS.HALF_SEC); - - // * Assert an error exist and is what is expected - cy.findByText('The email you provided does not belong to an accepted domain. Please contact your administrator or sign up with a different email.').should('be.visible'); }); + + cy.apiLogin(testUserAlreadyInTeam); + cy.visit('/'); + + // # Open Profile + cy.uiOpenProfileModal('Profile Settings'); + + // # Click "Edit" to the right of "Email" + cy.get('#emailEdit').should('be.visible').click(); + + // # Type new email + cy.get('#primaryEmail').should('be.visible').type('user-123123@example.com'); + cy.get('#confirmEmail').should('be.visible').type('user-123123@example.com'); + cy.get('#currentPassword').should('be.visible').type(testUser.password); + + // # Save the settings + cy.uiSave().wait(TIMEOUTS.HALF_SEC); + + // * Assert an error exist and is what is expected + cy.findByText('The email you provided does not belong to an accepted domain. Please contact your administrator or sign up with a different email.').should('be.visible'); }); it('MM-T1758 - Restrict Domains - Team invite closed team', () => { // # Set restricted domain cy.apiUpdateConfig({ TeamSettings: { - RestrictCreationToDomains: 'mattermost.com, test.com', + RestrictCreationToDomains: restrictCreationToDomains, }, - }).then(() => { - cy.apiLogout(); - - cy.visit(`/signup_user_complete/?id=${testTeam.invite_id}`); - - cy.get('#input_email', {timeout: TIMEOUTS.ONE_MIN}).type(`Hossein_Is_The_Best_PROGRAMMER${getRandomId()}@BestInTheWorld.com`); - - cy.get('#input_password-input').type('Test123456!'); - - cy.get('#input_name').clear().type(`HosseinIs2Cool${getRandomId()}`); - - cy.findByText('Create Account').click(); - - // * Make sure account was not created successfully - cy.findByText('The email you provided does not belong to an accepted domain. Please contact your administrator or sign up with a different email.').should('be.visible'); }); + + cy.apiLogout(); + cy.visit(`/signup_user_complete/?id=${testTeam.invite_id}`); + + cy.get('#input_email', {timeout: TIMEOUTS.ONE_MIN}).type(`test-${getRandomId()}@example.com`); + + cy.get('#input_password-input').type('Test123456!'); + + cy.get('#input_name').clear().type(`test${getRandomId()}`); + + cy.findByText('Create Account').click(); + + // * Make sure account was not created successfully + cy.get('.AlertBanner__title').scrollIntoView().should('be.visible'); + cy.findByText('The email you provided does not belong to an accepted domain. Please contact your administrator or sign up with a different email.').should('be.visible'); }); it('MM-T1763 - Security - Signup: Email verification not required, user immediately sees Town Square', () => { @@ -128,9 +127,8 @@ describe('Authentication', () => { RequireEmailVerification: false, }, }).then(({config}) => { + // # Log out and go to front page cy.apiLogout(); - - // # Go to front page cy.visit('/login'); // * Assert that create account button is visible @@ -139,7 +137,7 @@ describe('Authentication', () => { // # Go to sign up with email page cy.visit('/signup_user_complete'); - const username = `Hossein${getRandomId()}`; + const username = `Test${getRandomId()}`; const email = `${username.toLowerCase()}@example.com`; cy.get('#input_email', {timeout: TIMEOUTS.ONE_MIN}).type(email); @@ -169,17 +167,16 @@ describe('Authentication', () => { GitLabSettings: { Enable: true, }, - }).then(() => { - cy.apiLogout(); - - cy.visit(`/signup_user_complete/?id=${testTeam.invite_id}`); - - cy.findByText('Create your account with one of the following:').should('exist'); - cy.findByText('GitLab', {timeout: TIMEOUTS.ONE_MIN}).should('be.visible'); - - // * Email and Password option does not exist - cy.findByText('Email address').should('not.exist'); - cy.findByText('Choose a Password').should('not.exist'); }); + + cy.apiLogout(); + cy.visit(`/signup_user_complete/?id=${testTeam.invite_id}`); + + cy.findByText('Create your account with one of the following:').should('exist'); + cy.findByText('GitLab', {timeout: TIMEOUTS.ONE_MIN}).should('be.visible'); + + // * Email and Password option does not exist + cy.findByText('Email address').should('not.exist'); + cy.findByText('Choose a Password').should('not.exist'); }); }); diff --git a/e2e-tests/cypress/tests/integration/channels/auth_sso/authentication_2_spec.ts b/e2e-tests/cypress/tests/integration/channels/auth_sso/authentication_2_spec.ts index 43034041227..9f1af61e1b2 100644 --- a/e2e-tests/cypress/tests/integration/channels/auth_sso/authentication_2_spec.ts +++ b/e2e-tests/cypress/tests/integration/channels/auth_sso/authentication_2_spec.ts @@ -56,7 +56,7 @@ describe('Authentication', () => { // # Go to sign up with email page cy.visit('/signup_user_complete'); - cy.get('#input_email', {timeout: TIMEOUTS.ONE_MIN}).type(`Hossein_Is_The_Best_PROGRAMMER${getRandomId()}@BestInTheWorld.com`); + cy.get('#input_email', {timeout: TIMEOUTS.ONE_MIN}).type(`test-${getRandomId()}@example.com`); cy.get('#input_name').clear().type(`BestUsername${getRandomId()}`); @@ -109,7 +109,7 @@ describe('Authentication', () => { // # Go to sign up with email page cy.visit('/signup_user_complete'); - cy.get('#input_email', {timeout: TIMEOUTS.ONE_MIN}).type(`Hossein_Is_The_Best_PROGRAMMER${getRandomId()}@BestInTheWorld.com`); + cy.get('#input_email', {timeout: TIMEOUTS.ONE_MIN}).type(`test-${getRandomId()}@example.com`); cy.get('#input_name').clear().type(`BestUsernameInTheWorld${getRandomId()}`); diff --git a/e2e-tests/cypress/tests/integration/channels/auth_sso/authentication_4_spec.ts b/e2e-tests/cypress/tests/integration/channels/auth_sso/authentication_4_spec.ts index b369178af9c..4e8a3057b47 100644 --- a/e2e-tests/cypress/tests/integration/channels/auth_sso/authentication_4_spec.ts +++ b/e2e-tests/cypress/tests/integration/channels/auth_sso/authentication_4_spec.ts @@ -145,7 +145,7 @@ describe('Authentication', () => { // # Go to sign up with email page cy.visit('/signup_user_complete'); - cy.get('#input_email', {timeout: TIMEOUTS.ONE_MIN}).type('Hossein_Is_The_Best_PROGRAMMER@BestInTheWorld.com'); + cy.get('#input_email', {timeout: TIMEOUTS.ONE_MIN}).type(`test-${getRandomId()}@example.com`); cy.get('#input_password-input').type('Test123456!'); @@ -154,6 +154,7 @@ describe('Authentication', () => { cy.findByText('Create Account').click(); // * Assert the error is what is expected; + cy.get('.Input___error').scrollIntoView().should('be.visible'); cy.findByText('Usernames have to begin with a lowercase letter and be 3-22 characters long. You can use lowercase letters, numbers, periods, dashes, and underscores.').should('be.visible'); }); }); @@ -176,11 +177,11 @@ describe('Authentication', () => { // # Go to sign up with email page cy.visit('/signup_user_complete'); - cy.get('#input_email', {timeout: TIMEOUTS.ONE_MIN}).type(`Hossein_Is_The_Best_PROGRAMMER${getRandomId()}@BestInTheWorld.com`); + cy.get('#input_email', {timeout: TIMEOUTS.ONE_MIN}).type(`test-${getRandomId()}@example.com`); cy.get('#input_password-input').type('Test123456!'); - cy.get('#input_name').clear().type(`HosseinIs2Cool${getRandomId()}`); + cy.get('#input_name').clear().type(`Test${getRandomId()}`); cy.findByText('Create Account').click(); @@ -207,15 +208,16 @@ describe('Authentication', () => { // # Go to sign up with email page cy.visit('/signup_user_complete'); - cy.get('#input_email', {timeout: TIMEOUTS.ONE_MIN}).type(`Hossein_Is_The_Best_PROGRAMMER${getRandomId()}@BestInTheWorld.com`); + cy.get('#input_email', {timeout: TIMEOUTS.ONE_MIN}).type(`test-${getRandomId()}@example.com`); cy.get('#input_password-input').type('Test123456!'); - cy.get('#input_name').clear().type(`HosseinIs2Cool${getRandomId()}`); + cy.get('#input_name').clear().type(`Test${getRandomId()}`); cy.findByText('Create Account').click(); // * Make sure account was not created successfully and we are on the team joining page + cy.get('.AlertBanner__title').scrollIntoView().should('be.visible'); cy.findByText('User sign-up with email is disabled.').should('be.visible').and('exist'); }); @@ -239,15 +241,16 @@ describe('Authentication', () => { // # Go to sign up with email page cy.visit('/signup_user_complete'); - cy.get('#input_email', {timeout: TIMEOUTS.ONE_MIN}).type(`Hossein_Is_The_Best_PROGRAMMER${getRandomId()}@BestInTheWorld.com`); + cy.get('#input_email', {timeout: TIMEOUTS.ONE_MIN}).type(`test-${getRandomId()}@example.com`); cy.get('#input_password-input').type('Test123456!'); - cy.get('#input_name').clear().type(`HosseinIs2Cool${getRandomId()}`); + cy.get('#input_name').clear().type(`Test${getRandomId()}`); cy.findByText('Create Account').click(); // * Make sure account was not created successfully + cy.get('.AlertBanner__title').scrollIntoView().should('be.visible'); cy.findByText('The email you provided does not belong to an accepted domain. Please contact your administrator or sign up with a different email.').should('be.visible').and('exist'); }); @@ -261,6 +264,7 @@ describe('Authentication', () => { }); cy.visit('/'); + cy.postMessage('hello'); // # Open team menu and click on "Invite People" cy.uiOpenTeamMenu('Invite People'); @@ -269,7 +273,7 @@ describe('Authentication', () => { cy.findByText('Copy invite link').click(); // # Input email, select member - cy.findByText('Enter a name or email address').type('HosseinTheBestProgrammer@Mattermost.com{downarrow}{downarrow}{enter}'); + cy.findByLabelText('Add or Invite People').type(`test-${getRandomId()}@mattermost.com{downarrow}{downarrow}{enter}`, {force: true}); // # Click invite members button cy.findByRole('button', {name: 'Invite'}).click({force: true}); diff --git a/e2e-tests/cypress/tests/integration/channels/channel/new_channel_with_board_spec.js b/e2e-tests/cypress/tests/integration/channels/channel/new_channel_with_board_spec.js index e924b17f823..76deb4ed446 100644 --- a/e2e-tests/cypress/tests/integration/channels/channel/new_channel_with_board_spec.js +++ b/e2e-tests/cypress/tests/integration/channels/channel/new_channel_with_board_spec.js @@ -32,7 +32,7 @@ describe('New Channel modal with Boards enabled', () => { isPrivate: false, purpose: '', name: channelName, - createBoard: true, + createBoard: 'Roadmap', }).then(() => { // * Verify that new channel is in the sidebar and is active cy.url().should('include', `/${testTeam.name}/channels/test-channel`); @@ -42,7 +42,7 @@ describe('New Channel modal with Boards enabled', () => { // * Verify the board is created - check the message sent cy.waitUntil(() => cy.getLastPost().then((el) => { const postedMessageEl = el.find('.post-message__text > p')[0]; - return Boolean(postedMessageEl && postedMessageEl.textContent.includes('created the board')); + return Boolean(postedMessageEl && postedMessageEl.textContent.includes('linked the board')); })); }); }); diff --git a/e2e-tests/cypress/tests/integration/channels/custom_status/custom_status_1_spec.ts b/e2e-tests/cypress/tests/integration/channels/custom_status/custom_status_1_spec.ts index 0598a3479cb..0505fe7c07e 100644 --- a/e2e-tests/cypress/tests/integration/channels/custom_status/custom_status_1_spec.ts +++ b/e2e-tests/cypress/tests/integration/channels/custom_status/custom_status_1_spec.ts @@ -10,12 +10,15 @@ // Stage: @prod // Group: @channels @custom_status +import moment from 'moment-timezone'; + describe('Custom Status - CTAs for New Users', () => { before(() => { cy.apiUpdateConfig({TeamSettings: {EnableCustomUserStatuses: true}}); - // # Login as test user and visit channel - cy.apiInitSetup({loginAfter: true}).then(({team, channel}) => { + // # Create a user from more than 7 days ago, log and visit channel + const userCreateAt = moment().subtract(8, 'day').unix(); + cy.apiInitSetup({loginAfter: true, userCreateAt}).then(({team, channel}) => { cy.visit(`/${team.name}/channels/${channel.name}`); }); }); diff --git a/e2e-tests/cypress/tests/integration/channels/enterprise/auth_sso/authentication_spec.js b/e2e-tests/cypress/tests/integration/channels/enterprise/auth_sso/authentication_spec.js index 82b37e5b67f..3a0abcd99a9 100644 --- a/e2e-tests/cypress/tests/integration/channels/enterprise/auth_sso/authentication_spec.js +++ b/e2e-tests/cypress/tests/integration/channels/enterprise/auth_sso/authentication_spec.js @@ -15,6 +15,7 @@ import * as TIMEOUTS from '../../../../fixtures/timeouts'; import {getRandomId} from '../../../../utils'; describe('Authentication', () => { + const restrictCreationToDomains = 'mattermost.com, test.com'; let testTeam; before(() => { @@ -34,34 +35,33 @@ describe('Authentication', () => { // # Set restricted domain cy.apiUpdateConfig({ TeamSettings: { - RestrictCreationToDomains: 'mattermost.com, test.com', + RestrictCreationToDomains: restrictCreationToDomains, }, - }).then(() => { - cy.visit(`/admin_console/user_management/teams/${testTeam.id}`); - - cy.findByTestId('allowAllToggleSwitch', {timeout: TIMEOUTS.ONE_MIN}).click(); - - // # Click "Save" - cy.findByText('Save').scrollIntoView().click(); - - // # Wait until we are at the Mattermost Teams page - cy.findByText('Mattermost Teams', {timeout: TIMEOUTS.ONE_MIN}).should('be.visible'); - - cy.apiLogout(); - - cy.visit(`/signup_user_complete/?id=${testTeam.invite_id}`); - - cy.get('#input_email', {timeout: TIMEOUTS.ONE_MIN}).type(`Hossein_Is_The_Best_PROGRAMMER${getRandomId()}@BestInTheWorld.com`); - - cy.get('#input_password-input').type('Test123456!'); - - cy.get('#input_name').clear().type(`HosseinIs2Cool${getRandomId()}`); - - cy.findByText('Create Account').click(); - - // * Make sure account was not created successfully - cy.findByText('The email you provided does not belong to an accepted domain. Please contact your administrator or sign up with a different email.').should('be.visible').and('exist'); }); + + cy.visit(`/admin_console/user_management/teams/${testTeam.id}`); + + cy.findByTestId('allowAllToggleSwitch', {timeout: TIMEOUTS.ONE_MIN}).click(); + + // # Click "Save" + cy.findByText('Save').scrollIntoView().click(); + + // # Wait until we are at the Mattermost Teams page + cy.findByText('Mattermost Teams', {timeout: TIMEOUTS.ONE_MIN}).should('be.visible'); + + cy.apiLogout().visit(`/signup_user_complete/?id=${testTeam.invite_id}`); + + cy.get('#input_email', {timeout: TIMEOUTS.ONE_MIN}).type(`test-${getRandomId()}@example.com`); + + cy.get('#input_password-input').type('Test123456!'); + + cy.get('#input_name').clear().type(`Test${getRandomId()}`); + + cy.findByText('Create Account').click(); + + // * Make sure account was not created successfully + cy.get('.AlertBanner__title').scrollIntoView().should('be.visible'); + cy.findByText('The email you provided does not belong to an accepted domain. Please contact your administrator or sign up with a different email.').should('be.visible').and('exist'); }); it('MM-T1761 - Enable Open Server - Create link appears if email account creation is false and other signin methods are true', () => { @@ -73,13 +73,12 @@ describe('Authentication', () => { LdapSettings: { Enable: true, }, - }).then(() => { - cy.apiLogout(); - cy.visit('/'); - - // * Assert that create account button is visible - cy.findByText('Don\'t have an account?', {timeout: TIMEOUTS.ONE_MIN}).should('be.visible'); }); + + cy.apiLogout().visit('/'); + + // * Assert that create account button is visible + cy.findByText('Don\'t have an account?', {timeout: TIMEOUTS.ONE_MIN}).should('be.visible'); }); it('MM-T1766 - Authentication - Email - Creation with email = true', () => { @@ -89,16 +88,14 @@ describe('Authentication', () => { EnableSignUpWithEmail: true, }, TeamSettings: { - RestrictCreationToDomains: 'mattermost.com, test.com', + RestrictCreationToDomains: restrictCreationToDomains, }, - }).then(() => { - cy.apiLogout(); - - cy.visit(`/signup_user_complete/?id=${testTeam.invite_id}`); - - // * Email and Password option exist - cy.findByText('Email address').should('exist').and('be.visible'); - cy.findByPlaceholderText('Choose a Password').should('exist').and('be.visible'); }); + + cy.apiLogout().visit(`/signup_user_complete/?id=${testTeam.invite_id}`); + + // * Email and Password option exist + cy.findByText('Email address').should('exist').and('be.visible'); + cy.findByPlaceholderText('Choose a Password').should('exist').and('be.visible'); }); }); diff --git a/e2e-tests/cypress/tests/support/api/preference.js b/e2e-tests/cypress/tests/support/api/preference.js index f6dd3e5e1a1..5dc5713b4e8 100644 --- a/e2e-tests/cypress/tests/support/api/preference.js +++ b/e2e-tests/cypress/tests/support/api/preference.js @@ -438,6 +438,12 @@ Cypress.Commands.add('apiDisableTutorials', (userId) => { name: 'drafts_tour_tip_showed', value: '{"drafts_tour_tip_showed":true}', }, + { + user_id: userId, + category: 'app_bar', + name: 'channel_with_board_tip_showed', + value: '{"channel_with_board_tip_showed":true}', + }, ]; return cy.apiSaveUserPreference(preferences, userId); diff --git a/e2e-tests/cypress/tests/support/api/setup.ts b/e2e-tests/cypress/tests/support/api/setup.ts index 053230f82d7..cd462014be7 100644 --- a/e2e-tests/cypress/tests/support/api/setup.ts +++ b/e2e-tests/cypress/tests/support/api/setup.ts @@ -16,6 +16,7 @@ interface SetupParam { promoteNewUserAsAdmin?: boolean; hideAdminTrialModal?: boolean; userPrefix?: string; + userCreateAt?: number; teamPrefix?: {name: string; displayName: string}; channelPrefix?: {name: string; displayName: string}; skipBoardsWelcomePage?: boolean; @@ -26,6 +27,7 @@ function apiInitSetup(arg: SetupParam = {}): ChainableT { promoteNewUserAsAdmin = false, hideAdminTrialModal = true, userPrefix, + userCreateAt, teamPrefix = {name: 'team', displayName: 'Team'}, channelPrefix = {name: 'channel', displayName: 'Channel'}, skipBoardsWelcomePage = true, @@ -34,7 +36,7 @@ function apiInitSetup(arg: SetupParam = {}): ChainableT { return (cy.apiCreateTeam(teamPrefix.name, teamPrefix.displayName) as any).then(({team}) => { // # Add public channel return (cy.apiCreateChannel(team.id, channelPrefix.name, channelPrefix.displayName) as any).then(({channel}) => { - return (cy.apiCreateUser({prefix: userPrefix || (promoteNewUserAsAdmin ? 'admin' : 'user')}) as any).then(({user}) => { + return (cy.apiCreateUser({prefix: userPrefix || (promoteNewUserAsAdmin ? 'admin' : 'user'), createAt: userCreateAt}) as any).then(({user}) => { if (promoteNewUserAsAdmin) { (cy as any).apiPatchUserRoles(user.id, ['system_admin', 'system_user']); diff --git a/e2e-tests/cypress/tests/support/api/user.d.ts b/e2e-tests/cypress/tests/support/api/user.d.ts index e123b89ea51..0d04ef83c83 100644 --- a/e2e-tests/cypress/tests/support/api/user.d.ts +++ b/e2e-tests/cypress/tests/support/api/user.d.ts @@ -209,6 +209,7 @@ declare namespace Cypress { apiCreateUser(options?: { user?: Partial; prefix?: string; + createAt?: number; bypassTutorial?: boolean; showOnboarding?: boolean; }): Chainable<{user: UserProfile}>; diff --git a/e2e-tests/cypress/tests/support/api/user.js b/e2e-tests/cypress/tests/support/api/user.js index a6fc537a89c..325658dc212 100644 --- a/e2e-tests/cypress/tests/support/api/user.js +++ b/e2e-tests/cypress/tests/support/api/user.js @@ -216,7 +216,7 @@ Cypress.Commands.add('apiCreateAdmin', () => { }); }); -function generateRandomUser(prefix = 'user') { +function generateRandomUser(prefix = 'user', createAt = 0) { const randomId = getRandomId(); return { @@ -226,18 +226,20 @@ function generateRandomUser(prefix = 'user') { first_name: `First${randomId}`, last_name: `Last${randomId}`, nickname: `Nickname${randomId}`, + create_at: createAt, }; } Cypress.Commands.add('apiCreateUser', ({ prefix = 'user', + createAt = 0, bypassTutorial = true, hideActionsMenu = true, hideOnboarding = true, bypassWhatsNewModal = true, user = null, } = {}) => { - const newUser = user || generateRandomUser(prefix); + const newUser = user || generateRandomUser(prefix, createAt); const createUserOption = { headers: {'X-Requested-With': 'XMLHttpRequest'}, diff --git a/e2e-tests/cypress/tests/support/ui/channel.d.ts b/e2e-tests/cypress/tests/support/ui/channel.d.ts index 0435ed3f57d..6fe8344f38b 100644 --- a/e2e-tests/cypress/tests/support/ui/channel.d.ts +++ b/e2e-tests/cypress/tests/support/ui/channel.d.ts @@ -24,6 +24,7 @@ declare namespace Cypress { * @param {string} options.purpose - Channel's purpose * @param {string} options.header - Channel's header * @param {boolean} options.isNewSidebar) - the new sidebar has a different ui flow, set this setting to true to use that. Defaults to false. + * @param {string} options.createBoard) - Board template to create * * @example * cy.uiCreateChannel({prefix: 'private-channel-', isPrivate: true, purpose: 'my private channel', header: 'my private header', isNewSidebar: false}); diff --git a/e2e-tests/cypress/tests/support/ui/channel.js b/e2e-tests/cypress/tests/support/ui/channel.js index 8ddd0596302..978c50af42d 100644 --- a/e2e-tests/cypress/tests/support/ui/channel.js +++ b/e2e-tests/cypress/tests/support/ui/channel.js @@ -9,7 +9,7 @@ Cypress.Commands.add('uiCreateChannel', ({ isPrivate = false, purpose = '', name = '', - createBoard = false, + createBoard = '', }) => { cy.uiBrowseOrCreateChannel('Create new channel').click(); @@ -30,8 +30,8 @@ Cypress.Commands.add('uiCreateChannel', ({ cy.findByTestId('add-board-to-channel-check').then((el) => { if (el && !el.hasClass('checked')) { el.click(); - cy.get('#input_select-board-template').should('be.visible').click(); - cy.get('.SelectTemplateMenu .MenuItem:contains(Roadmap) button').should('be.visible').click(); + cy.get('.templates-selector').find('input').click({force: true}); + cy.findByText(createBoard).scrollIntoView().should('be.visible').click({force: true}); } }); }