Skip to content
This repository has been archived by the owner on Mar 13, 2024. It is now read-only.

Commit

Permalink
Cypress/E2E: Fix require license on some system console specs (#6802)
Browse files Browse the repository at this point in the history
* Cypress/E2E: Fix require license on some system console specs

* Moved locale rester to afterEach
  • Loading branch information
Joseph Baylon authored and jfrerich committed Oct 23, 2020
1 parent df6936d commit 12a7881
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,10 @@ const goToAdminConsole = () => {
};

describe('System console', () => {
before(() => {
it('MM-T1201 - Remove and re-add license - Permissions freeze in place when license is removed (and then re-added)', () => {
// * Check if server has license
cy.apiRequireLicense();
});

it('MM-T1201 - Remove and re-add license - Permissions freeze in place when license is removed (and then re-added)', () => {
const verifyCreatePublicChannel = (testTeam, testUserNonTeamAdmin, testUserTeamAdmin, channel) => {
// * Login as system admin and go the channel we created earlier and expect the create public channel button is visible
cy.apiAdminLogin();
Expand Down
7 changes: 5 additions & 2 deletions e2e/cypress/integration/system_console/main_menu_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ const goToAdminConsole = () => {

describe('Main menu', () => {
before(() => {
cy.apiRequireLicense();

goToAdminConsole();

// # Open the hamburger menu
Expand Down Expand Up @@ -59,6 +57,9 @@ describe('Main menu', () => {
});

it('MM-T913 About opens About modal', () => {
// * Check if server has license
cy.apiRequireLicense();

// # click to open about modal
cy.findByText('About Mattermost').click();

Expand All @@ -79,6 +80,8 @@ describe('Main menu', () => {
});

it('MM-T899 - Edition and License: Verify Privacy Policy link points to correct URL', () => {
// * Check if server has license
cy.apiRequireLicense();
goToAdminConsole();

// * Find privacy link and then assert that the href is what we expect it to be
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,27 +19,21 @@ const goToAdminConsole = () => {

describe('System Console > Site Statistics', () => {
let testTeam;
after(() => {
// # Login as admin and set the langauge back to ENGLISH!
cy.apiAdminLogin();
cy.visit(`/${testTeam.name}/channels/town-square`);
cy.get('#headerUsername').click();
cy.get('#accountSettings').should('be.visible').click();
cy.get('#displayButton').click();
cy.get('#languagesEdit').click();
cy.get('#displayLanguage').type('English{enter}');
cy.get('#saveSetting').click();

afterEach(() => {
// # Reset locale
cy.apiPatchMe({locale: 'en'});
});

it('MM-T904_1 Site Statistics displays expected content categories', () => {
// # Require license.
// * Check if server has license
cy.apiRequireLicense();

// # Visit site statistics page.
cy.visit('/admin_console/reporting/system_analytics').wait(TIMEOUTS.TWO_SEC);
cy.visit('/admin_console/reporting/system_analytics');

// * Check that the header has loaded correctly and contains the expected text.
cy.get('.admin-console__header span').should('be.visible').should('contain', 'System Statistics');
cy.get('.admin-console__header span', {timeout: TIMEOUTS.ONE_MIN}).should('be.visible').should('contain', 'System Statistics');

// * Check that the rows for the table were generated.
cy.get('.admin-console__content .row').should('have.length', 5);
Expand All @@ -60,6 +54,9 @@ describe('System Console > Site Statistics', () => {

// * Check that some of the values for the stats are valid.
cy.get('.admin-console__content .row').eq(0).find('.content').each((el) => {
cy.waitUntil(() => cy.wrap(el).then((content) => {
return content[0].innerText !== 'Loading...';
}));
cy.wrap(el).eq(0).invoke('text').then(parseFloat).should('be.gte', 0);
});
});
Expand All @@ -69,10 +66,10 @@ describe('System Console > Site Statistics', () => {
cy.apiDeleteLicense();

// # Visit site statistics page.
cy.visit('/admin_console/reporting/system_analytics').wait(TIMEOUTS.TWO_SEC);
cy.visit('/admin_console/reporting/system_analytics');

// * Check that the header has loaded correctly and contains the expected text.
cy.get('.admin-console__header span').should('be.visible').should('contain', 'System Statistics');
cy.get('.admin-console__header span', {timeout: TIMEOUTS.ONE_MIN}).should('be.visible').should('contain', 'System Statistics');

// * Check that the rows for the table were generated.
cy.get('.admin-console__content .row').should('have.length', 4);
Expand All @@ -87,14 +84,17 @@ describe('System Console > Site Statistics', () => {

// * Check that the values for the stats are valid.
cy.get('.admin-console__content .row').eq(0).find('.content').each((el) => {
cy.waitUntil(() => cy.wrap(el).then((content) => {
return content[0].innerText !== 'Loading...';
}));
cy.wrap(el).eq(0).invoke('text').then(parseFloat).should('be.gt', 0);
});
});

it('MM-T902 - Reporting ➜ Site statistics line graphs show same date', () => {
const sysadmin = getAdminAccount();

// # Require license.
// * Check if server has license
cy.apiRequireLicense();

let newChannel;
Expand Down Expand Up @@ -124,7 +124,7 @@ describe('System Console > Site Statistics', () => {
goToAdminConsole();

// * Find site statistics and click it
cy.findByTestId('reporting.system_analytics').click();
cy.findByTestId('reporting.system_analytics', {timeout: TIMEOUTS.ONE_MIN}).click();

let totalPostsDataSet;
let totalPostsFromBots;
Expand Down Expand Up @@ -164,7 +164,7 @@ describe('System Console > Site Statistics', () => {
goToAdminConsole();

// # Go to system analytics
cy.get('#reporting\\/system_analytics').click();
cy.findByTestId('reporting.system_analytics', {timeout: TIMEOUTS.ONE_MIN}).click();
cy.wait(TIMEOUTS.ONE_SEC);

let totalActiveUsersInitial;
Expand Down Expand Up @@ -211,13 +211,16 @@ describe('System Console > Site Statistics', () => {
});

it('MM-T905 - Site Statistics card labels in different languages', () => {
// * Check if server has license
cy.apiRequireLicense();

cy.apiInitSetup().then(({team}) => {
testTeam = team;

// # Login as admin and set the langauge to french
cy.apiAdminLogin();
cy.visit(`/${testTeam.name}/channels/town-square`);
cy.get('#headerUsername').click();
cy.get('#headerUsername', {timeout: TIMEOUTS.ONE_MIN}).click();
cy.get('#accountSettings').should('be.visible').click();
cy.get('#displayButton').click();
cy.get('#languagesEdit').click();
Expand All @@ -236,7 +239,7 @@ describe('System Console > Site Statistics', () => {
expectedResult = true;
}

cy.findByTestId(id).then((el) => {
cy.findByTestId(id, {timeout: TIMEOUTS.ONE_MIN}).then((el) => {
const titleSpan = el[0].childNodes[0];

// * All the boxes on System Statistics page should have UNTRUNCATED titles when in french except Total Commands, Master DB Conns, and Replica DB Conns.
Expand Down
5 changes: 2 additions & 3 deletions e2e/cypress/integration/system_console/search_box_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,10 @@ const goToAdminConsole = () => {
};

describe('System console', () => {
before(() => {
it('MM-T897_1 - Focus should be in System Console search box on opening System Console or refreshing pages in System Console', () => {
// * Check if server has license
cy.apiRequireLicense();
});

it('MM-T897_1 - Focus should be in System Console search box on opening System Console or refreshing pages in System Console', () => {
const pageIds = ['reporting\\/system_analytics', 'reporting\\/team_statistics', 'reporting\\/server_logs', 'user_management\\/users', 'user_management\\/teams'];
goToAdminConsole();

Expand Down

0 comments on commit 12a7881

Please sign in to comment.