-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Fix E2E flaky tests #2996
Fix E2E flaky tests #2996
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,8 +51,8 @@ describe('Account Settings > Sidebar > General', () => { | |
cy.get('#accountSettingsHeader > .close').click(); | ||
cy.get('#sidebarHeaderDropdownButton').click(); | ||
|
||
cy.get('#manageMembers').should('be.visible'); | ||
cy.get('#manageMembers').click(); | ||
cy.get('#viewMembers').should('be.visible'); | ||
cy.get('#viewMembers').click(); | ||
|
||
// # Search for username and check that no nickname is present | ||
cy.get('.modal-title').should('be.visible'); | ||
|
@@ -82,8 +82,8 @@ describe('Account Settings > Sidebar > General', () => { | |
cy.get('#accountSettingsHeader > .close').click(); | ||
cy.get('#sidebarHeaderDropdownButton').click(); | ||
|
||
cy.get('#manageMembers').should('be.visible'); | ||
cy.get('#manageMembers').click(); | ||
cy.get('#viewMembers').should('be.visible'); | ||
cy.get('#viewMembers').click(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
// # Search for username and check that expected nickname is present | ||
cy.get('.modal-title').should('be.visible'); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -230,6 +230,8 @@ describe('at-mention', () => { | |
cy.get('@postMessageText'). | ||
find(`[data-mention=${receiver.username}]`). | ||
should('not.exist'); | ||
|
||
cy.get('#sidebarItem_saepe-5').scrollIntoView().click({force: true}); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: Added missing step There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Another nit, no need to scroll into view if we are forcing the click. |
||
}); | ||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,19 +7,19 @@ | |
// - Use element ID when selecting an element. Create one if none. | ||
// *************************************************************** | ||
|
||
/*eslint max-nested-callbacks: ["error", 3]*/ | ||
/*eslint max-nested-callbacks: ["error", 4]*/ | ||
|
||
let testTeam; | ||
|
||
describe('Message Draft', () => { | ||
before(() => { | ||
// # Login as new user | ||
cy.loginAsNewUser(); | ||
|
||
// # Create new team and visit its URL | ||
cy.apiCreateTeam('test-team', 'Test Team').then((response) => { | ||
testTeam = response.body; | ||
cy.visit(`/${testTeam.name}`); | ||
cy.loginAsNewUser().then(() => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think having to use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not totally sure about this but let's try and observe. |
||
// # Create new team and visit its URL | ||
cy.apiCreateTeam('test-team', 'Test Team').then((response) => { | ||
testTeam = response.body; | ||
cy.visit(`/${testTeam.name}`); | ||
}); | ||
}); | ||
}); | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,8 +7,18 @@ | |
// - Use element ID when selecting an element. Create one if none. | ||
// *************************************************************** | ||
|
||
/* eslint max-nested-callbacks: ["error", 4] */ | ||
|
||
let config; | ||
|
||
describe('Signup Email page', () => { | ||
before(() => { | ||
cy.apiGetConfig().then((response) => { | ||
config = response.body; | ||
}); | ||
cy.apiLogout(); | ||
|
||
// # Go to login page | ||
saturninoabril marked this conversation as resolved.
Show resolved
Hide resolved
|
||
// # Go to signup email page | ||
cy.visit('/signup_email'); | ||
}); | ||
|
@@ -18,7 +28,7 @@ describe('Signup Email page', () => { | |
cy.get('#signup_email_section').should('be.visible'); | ||
|
||
// * Check the title | ||
cy.title().should('include', 'Mattermost'); | ||
cy.title().should('include', config.TeamSettings.SiteName); | ||
}); | ||
|
||
it('should match elements, back button', () => { | ||
|
@@ -32,7 +42,7 @@ describe('Signup Email page', () => { | |
it('should match elements, body', () => { | ||
// * Check elements in the body | ||
cy.get('#signup_email_section').should('be.visible'); | ||
cy.get('#site_name').should('contain', 'Mattermost'); | ||
cy.get('#site_name').should('contain', config.TeamSettings.SiteName); | ||
cy.get('#site_description').should('contain', 'All team communication in one place, searchable and accessible anywhere'); | ||
cy.get('#create_account').should('contain', 'Let\'s create your account'); | ||
cy.get('#signin_account').should('contain', 'Already have an account?'); | ||
|
@@ -56,8 +66,8 @@ describe('Signup Email page', () => { | |
cy.get('#createAccountButton').should('contain', 'Create Account'); | ||
|
||
cy.get('#signup_agreement').should('contain', 'By proceeding to create your account and use Mattermost, you agree to our Terms of Service and Privacy Policy. If you do not agree, you cannot use Mattermost.'); | ||
cy.get('#signup_agreement > span > [href="https://about.mattermost.com/default-terms/"]').should('be.visible'); | ||
cy.get('#signup_agreement > span > [href="https://about.mattermost.com/default-privacy-policy/"]').should('be.visible'); | ||
cy.get(`#signup_agreement > span > [href="${config.SupportSettings.TermsOfServiceLink}"]`).should('be.visible'); | ||
cy.get(`#signup_agreement > span > [href="${config.SupportSettings.PrivacyPolicyLink}"]`).should('be.visible'); | ||
}); | ||
|
||
it('should match elements, footer', () => { | ||
|
@@ -67,12 +77,12 @@ describe('Signup Email page', () => { | |
cy.get('#copyright').should('contain', '© 2015-'); | ||
cy.get('#copyright').should('contain', 'Mattermost, Inc.'); | ||
cy.get('#about_link').should('contain', 'About'); | ||
cy.get('#about_link').should('have.attr', 'href', 'https://about.mattermost.com/default-about/'); | ||
cy.get('#about_link').should('have.attr', 'href', config.SupportSettings.AboutLink); | ||
cy.get('#privacy_link').should('contain', 'Privacy'); | ||
cy.get('#privacy_link').should('have.attr', 'href', 'https://about.mattermost.com/default-privacy-policy/'); | ||
cy.get('#privacy_link').should('have.attr', 'href', config.SupportSettings.PrivacyPolicyLink); | ||
cy.get('#terms_link').should('contain', 'Terms'); | ||
cy.get('#terms_link').should('have.attr', 'href', 'https://about.mattermost.com/default-terms/'); | ||
cy.get('#terms_link').should('have.attr', 'href', config.SupportSettings.TermsOfServiceLink); | ||
cy.get('#help_link').should('contain', 'Help'); | ||
cy.get('#help_link').should('have.attr', 'href', 'https://about.mattermost.com/default-help/'); | ||
cy.get('#help_link').should('have.attr', 'href', config.SupportSettings.HelpLink); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is failing since cypress server has different config for |
||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,40 @@ | ||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. | ||
// See LICENSE.txt for license information. | ||
|
||
require('@babel/polyfill'); | ||
require('isomorphic-fetch'); | ||
|
||
const {Client4} = require('mattermost-redux/client'); | ||
const axios = require('axios'); | ||
|
||
const cypressConfig = require('../../cypress.json'); | ||
|
||
module.exports = async ({sender, message, channelId, createAt = 0}) => { | ||
const url = `${cypressConfig.baseUrl}/api/v4/users/login`; | ||
|
||
const response = await axios({ | ||
url, | ||
const loginResponse = await axios({ | ||
url: `${cypressConfig.baseUrl}/api/v4/users/login`, | ||
headers: {'X-Requested-With': 'XMLHttpRequest'}, | ||
method: 'post', | ||
data: {login_id: sender.username, password: sender.password}, | ||
}); | ||
|
||
const token = response.headers.token; | ||
|
||
Client4.setUrl(cypressConfig.baseUrl); | ||
Client4.setToken(token); | ||
const setCookie = loginResponse.headers['set-cookie']; | ||
let cookieString = ''; | ||
setCookie.forEach((cookie) => { | ||
const nameAndValue = cookie.split(';')[0]; | ||
cookieString += nameAndValue + ';'; | ||
}); | ||
|
||
const options = { | ||
channel_id: channelId, | ||
message, | ||
type: '', | ||
create_at: createAt, | ||
}; | ||
const response = await axios({ | ||
url: `${cypressConfig.baseUrl}/api/v4/posts`, | ||
headers: { | ||
'Content-Type': 'application/json', | ||
'X-Requested-With': 'XMLHttpRequest', | ||
Cookie: cookieString, | ||
}, | ||
method: 'post', | ||
data: { | ||
channel_id: channelId, | ||
message, | ||
type: '', | ||
create_at: createAt, | ||
}, | ||
}); | ||
|
||
return Client4.createPost(options); | ||
return {status: response.status, data: response.data, error: response.error}; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not totally sure why postMessageAs is not working as expected. I just removed the use of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. mattermost-redux changes perhaps? I haven't looked at recent commits, but I think it's totally fine for us to use the API directly, ultimately that's what the client is doing. This way we have more control over the requests as well. 👍 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think so as the current mattermost-redux is working locally but let's eliminate potential issue by going thru API call directly. |
||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: update the correct usage of
cy.postMessage
where the text param don't need to add{enter}
since the command itself is doing it already.