[MM-40144] Restructure tests, add test case numbers, some cleanup (#1864)
* [MM-40144] Restructure tests, add test case numbers, some cleanup * Fix a test
This commit is contained in:
78
e2e/specs/server_management/remove_server_modal.test.js
Normal file
78
e2e/specs/server_management/remove_server_modal.test.js
Normal file
@@ -0,0 +1,78 @@
|
||||
// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
'use strict';
|
||||
|
||||
const fs = require('fs');
|
||||
|
||||
const env = require('../../modules/environment');
|
||||
const {asyncSleep} = require('../../modules/utils');
|
||||
|
||||
describe('RemoveServerModal', function desc() {
|
||||
this.timeout(30000);
|
||||
const config = env.demoConfig;
|
||||
|
||||
beforeEach(async () => {
|
||||
env.createTestUserDataDir();
|
||||
env.cleanTestConfig();
|
||||
fs.writeFileSync(env.configFilePath, JSON.stringify(config));
|
||||
await asyncSleep(1000);
|
||||
this.app = await env.getApp();
|
||||
|
||||
const mainView = this.app.windows().find((window) => window.url().includes('index'));
|
||||
const dropdownView = this.app.windows().find((window) => window.url().includes('dropdown'));
|
||||
await mainView.click('.TeamDropdownButton');
|
||||
await dropdownView.hover('.TeamDropdown .TeamDropdown__button:nth-child(1)');
|
||||
await dropdownView.click('.TeamDropdown .TeamDropdown__button:nth-child(1) button.TeamDropdown__button-remove');
|
||||
|
||||
removeServerView = await this.app.waitForEvent('window', {
|
||||
predicate: (window) => window.url().includes('removeServer'),
|
||||
});
|
||||
|
||||
// wait for autofocus to finish
|
||||
await asyncSleep(500);
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
if (this.app) {
|
||||
await this.app.close();
|
||||
}
|
||||
});
|
||||
|
||||
let removeServerView;
|
||||
|
||||
it('MM-T4390_1 should remove existing team on click Remove', async () => {
|
||||
await removeServerView.click('button:has-text("Remove")');
|
||||
await asyncSleep(1000);
|
||||
|
||||
const expectedConfig = JSON.parse(JSON.stringify(config.teams.slice(1)));
|
||||
expectedConfig.forEach((value) => {
|
||||
value.order--;
|
||||
});
|
||||
|
||||
const savedConfig = JSON.parse(fs.readFileSync(env.configFilePath, 'utf8'));
|
||||
savedConfig.teams.should.deep.equal(expectedConfig);
|
||||
});
|
||||
|
||||
it('MM-T4390_2 should NOT remove existing team on click Cancel', async () => {
|
||||
await removeServerView.click('button:has-text("Cancel")');
|
||||
await asyncSleep(1000);
|
||||
|
||||
const savedConfig = JSON.parse(fs.readFileSync(env.configFilePath, 'utf8'));
|
||||
savedConfig.teams.should.deep.equal(config.teams);
|
||||
});
|
||||
|
||||
it('MM-T4390_3 should disappear on click Close', async () => {
|
||||
await removeServerView.click('button.close');
|
||||
await asyncSleep(1000);
|
||||
const existing = Boolean(await this.app.windows().find((window) => window.url().includes('removeServer')));
|
||||
existing.should.be.false;
|
||||
});
|
||||
|
||||
it('MM-T4390_4 should disappear on click background', async () => {
|
||||
await removeServerView.click('.modal', {position: {x: 20, y: 20}});
|
||||
await asyncSleep(1000);
|
||||
const existing = Boolean(await this.app.windows().find((window) => window.url().includes('removeServer')));
|
||||
existing.should.be.false;
|
||||
});
|
||||
});
|
Reference in New Issue
Block a user