Unverified Commit b0acfbc4 authored by Mattermost Build's avatar Mattermost Build Committed by GitHub
Browse files

Fix team members spec (#5954)


Co-authored-by: default avatarJoseph Baylon <joseph.baylon@mattermost.com>
parent cf4da299
......@@ -11,14 +11,6 @@
import * as TIMEOUTS from '../../../fixtures/timeouts';
const saveConfig = () => {
// # Click save
cy.get('#saveSetting').click();
// # Check that the members block is no longer visible meaning that the save has succeeded and we were redirected out
cy.get('#teamMembers').should('not.be.visible');
};
describe('Team members test', () => {
let testTeam;
let user1;
......@@ -70,8 +62,7 @@ describe('Team members test', () => {
cy.get('#teamMembers').scrollIntoView().should('be.visible');
// # Search for user1 that we know is in the team
cy.get('#teamMembers .DataGrid_search input').clear().type(user1.email);
cy.wait(TIMEOUTS.HALF_SEC); // Timeout required to wait for timeout that happens when search input changes
searchFor(user1.email);
// # Wait till loading complete and then remove the only visible user
cy.get('#teamMembers .DataGrid_loading').should('not.be.visible');
......@@ -87,8 +78,7 @@ describe('Team members test', () => {
cy.get('#cancelModalButton').click();
// # Search for user2 that we know is in the team
cy.get('#teamMembers .DataGrid_search input').clear().type(user2.email);
cy.wait(TIMEOUTS.HALF_SEC); // Timeout required to wait for timeout that happens when search input changes
searchFor(user2.email);
// # Wait till loading complete and then remove the only visible user
cy.get('#teamMembers .DataGrid_loading').should('not.be.visible');
......@@ -110,15 +100,13 @@ describe('Team members test', () => {
cy.visit(`/admin_console/user_management/teams/${testTeam.id}`);
// # Search for user1 that we know is no longer in the team
cy.get('#teamMembers .DataGrid_search input').scrollIntoView().clear().type(user1.email);
cy.wait(TIMEOUTS.HALF_SEC); // Timeout required to wait for timeout that happens when search input changes
searchFor(user1.email);
// * Assert that no matching users found
cy.get('#teamMembers .DataGrid_rows').should('contain', 'No users found');
// # Search for user2 that we know is no longer in the team
cy.get('#teamMembers .DataGrid_search input').clear().type(user2.email);
cy.wait(TIMEOUTS.HALF_SEC); // Timeout required to wait for timeout that happens when search input changes
searchFor(user2.email);
// * Assert that no matching users found
cy.get('#teamMembers .DataGrid_rows').should('contain', 'No users found');
......@@ -133,8 +121,7 @@ describe('Team members test', () => {
cy.get('#addUsersToTeamModal #saveItems').click();
// # Search for user1
cy.get('#teamMembers .DataGrid_search input').clear().type(user1.email);
cy.wait(TIMEOUTS.HALF_SEC); // Timeout required to wait for timeout that happens when search input changes
searchFor(user1.email);
// * Assert that the user is now added to the members block and contains text denoting that they are New
cy.get('#teamMembers .DataGrid_rows').children(0).should('contain', user1.email).and('contain', 'New');
......@@ -149,15 +136,13 @@ describe('Team members test', () => {
});
// # Search for user2
cy.get('#teamMembers .DataGrid_search input').clear().type(user2.email);
cy.wait(TIMEOUTS.HALF_SEC); // Timeout required to wait for timeout that happens when search input changes
searchFor(user2.email);
// * Assert that the user is now added to the members block and contains text denoting that they are New
cy.get('#teamMembers .DataGrid_rows').children(0).should('contain', user2.email).and('contain', 'New');
// # Search for sysadmin
cy.get('#teamMembers .DataGrid_search input').clear().type(sysadmin.email);
cy.wait(TIMEOUTS.HALF_SEC); // Timeout required to wait for timeout that happens when search input changes
searchFor(sysadmin.email);
// * Assert that searching for users after adding users returns only relevant search results
cy.get('#teamMembers .DataGrid_rows').children(0).should('contain', sysadmin.email);
......@@ -169,8 +154,7 @@ describe('Team members test', () => {
cy.visit(`/admin_console/user_management/teams/${testTeam.id}`);
// # Search user1 that we know is now in the team again
cy.get('#teamMembers .DataGrid_search input').scrollIntoView().clear().type(user1.email);
cy.wait(TIMEOUTS.HALF_SEC); // Timeout required to wait for timeout that happens when search input changes
searchFor(user1.email);
cy.get('#teamMembers .DataGrid_loading').should('not.be.visible');
// * Assert that the user is now saved as an admin
......@@ -189,8 +173,7 @@ describe('Team members test', () => {
cy.get('#teamMembers .DataGrid_rows').children(0).should('contain', user1.email).and('not.contain', 'New').and('contain', 'Team Member');
// # Search user2 that we know is now in the team again
cy.get('#teamMembers .DataGrid_search input').scrollIntoView().clear().type(user2.email);
cy.wait(TIMEOUTS.HALF_SEC); // Timeout required to wait for timeout that happens when search input changes
searchFor(user2.email);
cy.get('#teamMembers .DataGrid_loading').should('not.be.visible');
// * Assert user2 is now saved as a regular member
......@@ -200,3 +183,16 @@ describe('Team members test', () => {
saveConfig();
});
});
function searchFor(searchTerm) {
cy.get('#teamMembers .DataGrid_search input[type="text"]').scrollIntoView().clear().type(searchTerm);
cy.wait(TIMEOUTS.HALF_SEC); // Timeout required to wait for timeout that happens when search input changes
}
function saveConfig() {
// # Click save
cy.get('#saveSetting').click();
// # Check that the members block is no longer visible meaning that the save has succeeded and we were redirected out
cy.get('#teamMembers').should('not.be.visible');
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment