Move /e2e -> /e2e-tests
Этот коммит содержится в:
@@ -0,0 +1,61 @@
|
||||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
// ***************************************************************
|
||||
// - [#] indicates a test step (e.g. # Go to a page)
|
||||
// - [*] indicates an assertion (e.g. * Check the title)
|
||||
// - Use element ID when selecting an element. Create one if none.
|
||||
// ***************************************************************
|
||||
|
||||
// Stage: @prod
|
||||
// Group: @channels @channel
|
||||
|
||||
import {measurePerformance} from './utils.js';
|
||||
|
||||
describe('Channel switch performance test', () => {
|
||||
let teamName;
|
||||
|
||||
before(() => {
|
||||
cy.apiInitSetup({loginAfter: true}).then(({team}) => {
|
||||
teamName = team;
|
||||
|
||||
// # Go to town square
|
||||
cy.visit(`/${team.name}/channels/town-square`);
|
||||
cy.get('#sidebarItem_off-topic').should('be.visible');
|
||||
});
|
||||
});
|
||||
|
||||
it('measures switching between two channels from LHS', () => {
|
||||
measurePerformance(
|
||||
'channelLoad',
|
||||
800,
|
||||
() => {
|
||||
// # Switch channel to Off-topic
|
||||
|
||||
cy.get('#sidebarItem_off-topic').click({force: true});
|
||||
|
||||
// * Expect that the user is now in Off-Topic
|
||||
return expectActiveChannelToBe('Off-Topic', '/off-topic');
|
||||
},
|
||||
|
||||
// # Reset test run so we can start on the initially specified channel
|
||||
() => {
|
||||
cy.visit(`/${teamName.name}/channels/town-square`);
|
||||
cy.get('#sidebarItem_off-topic').should('be.visible');
|
||||
},
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
const expectActiveChannelToBe = (title, url) => {
|
||||
// * Expect channel title to match title passed in argument
|
||||
cy.get('#channelHeaderTitle').
|
||||
should('be.visible').
|
||||
and('contain.text', title);
|
||||
|
||||
// * Expect that center channel is visible and page has loaded
|
||||
cy.get('#app-content').should('be.visible');
|
||||
|
||||
// * Expect url to match url passed in argument
|
||||
return cy.url().should('contain', url);
|
||||
};
|
||||
@@ -0,0 +1,67 @@
|
||||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
// ***************************************************************
|
||||
// - [#] indicates a test step (e.g. # Go to a page)
|
||||
// - [*] indicates an assertion (e.g. * Check the title)
|
||||
// - Use element ID when selecting an element. Create one if none.
|
||||
// ***************************************************************
|
||||
|
||||
import {measurePerformance} from './utils.js';
|
||||
|
||||
describe('Team switch performance test', () => {
|
||||
let testTeam1;
|
||||
let testTeam2;
|
||||
|
||||
before(() => {
|
||||
cy.apiInitSetup({loginAfter: true}).then(({team}) => {
|
||||
testTeam1 = team;
|
||||
|
||||
cy.apiCreateTeam('team-b', 'Team B').then(({team: team2}) => {
|
||||
testTeam2 = team2;
|
||||
|
||||
// # Go to town square
|
||||
cy.visit(`/${testTeam1.name}/channels/town-square`);
|
||||
cy.get('#teamSidebarWrapper').should('be.visible');
|
||||
cy.get(`#${testTeam2.name}TeamButton`).should('be.visible');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('measures switching between two teams from LHS', () => {
|
||||
// # Invoke window object
|
||||
measurePerformance(
|
||||
'teamLoad',
|
||||
1900,
|
||||
() => {
|
||||
// # Switch to Team 2
|
||||
cy.get('#teamSidebarWrapper').within(() => {
|
||||
cy.get(`#${testTeam2.name}TeamButton`).should('be.visible').click();
|
||||
});
|
||||
|
||||
// * Expect that the user has switched teams
|
||||
return expectActiveTeamToBe(testTeam2.display_name, testTeam2.name);
|
||||
},
|
||||
|
||||
// # Reset test run so we can start on the initially specified team
|
||||
() => {
|
||||
cy.visit(`/${testTeam1.name}/channels/town-square`);
|
||||
cy.get('#teamSidebarWrapper').should('be.visible');
|
||||
cy.get(`#${testTeam2.name}TeamButton`).should('be.visible');
|
||||
},
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
const expectActiveTeamToBe = (title, url) => {
|
||||
// * Expect channel title to match title passed in argument
|
||||
cy.get('#sidebar-header-container').
|
||||
should('be.visible').
|
||||
and('contain.text', title);
|
||||
|
||||
// * Expect that center channel is visible and page has loaded
|
||||
cy.get('#app-content').should('be.visible');
|
||||
|
||||
// * Expect url to match url passed in argument
|
||||
return cy.url().should('contain', url);
|
||||
};
|
||||
@@ -0,0 +1,37 @@
|
||||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
export const measurePerformance = (name, upperLimit, callback, reset, runs = 6) => {
|
||||
return cy.window().its('performance').then((performance) => {
|
||||
const durations = [];
|
||||
|
||||
Cypress._.times(runs, (i) => {
|
||||
const markerNameA = `${name}_start_${i}`;
|
||||
const markerNameB = `${name}_end_${i}`;
|
||||
|
||||
cy.wrap({mark: () => performance.mark(markerNameA)}).invoke('mark');
|
||||
callback().then(() => {
|
||||
performance.mark(markerNameB);
|
||||
|
||||
performance.measure(`${name}_${i}`, markerNameA, markerNameB);
|
||||
const measure = performance.getEntriesByName(`${name}_${i}`)[0];
|
||||
durations.push(measure.duration);
|
||||
});
|
||||
|
||||
reset();
|
||||
});
|
||||
|
||||
const currentTime = Date.now();
|
||||
|
||||
cy.log('loop finish').then(() => {
|
||||
const avgDuration = Math.round(durations.reduce((a, b) => a + b) / runs);
|
||||
cy.log(`[PERFORMANCE] ${name}: ${avgDuration}ms ${avgDuration <= upperLimit ? ' within upper limit' : ' outside upper limit'} of ${upperLimit}ms`);
|
||||
cy.writeFile(`./tests/integration/performance/logs/${name}_${currentTime}.json`, {name, date: currentTime, duration: avgDuration});
|
||||
assert.isAtMost(avgDuration, upperLimit);
|
||||
|
||||
// Clean the marks
|
||||
performance.clearMarks();
|
||||
performance.clearMeasures();
|
||||
});
|
||||
});
|
||||
};
|
||||
Ссылка в новой задаче
Block a user