fix: known failed E2E tests (#23708)

This commit is contained in:
Saturnino Abril 2023-06-14 07:56:23 +08:00 committed by GitHub
parent bc66807acc
commit 16ad573979
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 152 additions and 137 deletions

View File

@ -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

View File

@ -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');
});
});

View File

@ -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()}`);

View File

@ -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});

View File

@ -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'));
}));
});
});

View File

@ -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}`);
});
});

View File

@ -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');
});
});

View File

@ -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);

View File

@ -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<SetupResult> {
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<SetupResult> {
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']);

View File

@ -209,6 +209,7 @@ declare namespace Cypress {
apiCreateUser(options?: {
user?: Partial<UserProfile>;
prefix?: string;
createAt?: number;
bypassTutorial?: boolean;
showOnboarding?: boolean;
}): Chainable<{user: UserProfile}>;

View File

@ -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'},

View File

@ -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});

View File

@ -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});
}
});
}