mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-05-10 17:22:00 -04:00
tests: Admin Frontend Test Coverage(#4717)
Covers all frontend admin operations, runs separated in CI.
This commit is contained in:
parent
294f2a251f
commit
2b112ac851
13 changed files with 463 additions and 50 deletions
73
src/tests/frontend/specs/adminsettings.js
Normal file
73
src/tests/frontend/specs/adminsettings.js
Normal file
|
@ -0,0 +1,73 @@
|
|||
'use strict';
|
||||
|
||||
describe('Admin > Settings', function () {
|
||||
this.timeout(480000);
|
||||
|
||||
before(async function () {
|
||||
let success = false;
|
||||
$.ajax({
|
||||
url: `${location.protocol}//admin:changeme@${location.hostname}:${location.port}/admin/`,
|
||||
type: 'GET',
|
||||
success: () => success = true,
|
||||
});
|
||||
await helper.waitForPromise(() => success === true);
|
||||
});
|
||||
|
||||
beforeEach(async function () {
|
||||
helper.newAdmin('settings');
|
||||
// needed, because the load event is fired to early
|
||||
await helper.waitForPromise(() => helper.admin$ && helper.admin$('.settings').val().length > 0);
|
||||
});
|
||||
|
||||
it('Are Settings visible, populated, does save work', async function () {
|
||||
// save old value
|
||||
const settings = helper.admin$('.settings').val();
|
||||
const settingsLength = settings.length;
|
||||
|
||||
// set new value
|
||||
helper.admin$('.settings').val((_, text) => `/* test */\n${text}`);
|
||||
await helper.waitForPromise(
|
||||
() => settingsLength + 11 === helper.admin$('.settings').val().length);
|
||||
|
||||
// saves
|
||||
helper.admin$('#saveSettings').click();
|
||||
await helper.waitForPromise(() => helper.admin$('#response').is(':visible'));
|
||||
|
||||
// new value for settings.json should now be saved
|
||||
// reset it to the old value
|
||||
helper.newAdmin('settings');
|
||||
await helper.waitForPromise(() => helper.admin$ && helper.admin$('.settings').val().length > 0);
|
||||
|
||||
// replace the test value with a line break
|
||||
helper.admin$('.settings').val((_, text) => text.replace('/* test */\n', ''));
|
||||
await helper.waitForPromise(() => settingsLength === helper.admin$('.settings').val().length);
|
||||
|
||||
helper.admin$('#saveSettings').click(); // saves
|
||||
await helper.waitForPromise(() => helper.admin$('#response').is(':visible'));
|
||||
|
||||
// settings should have the old value
|
||||
helper.newAdmin('settings');
|
||||
await helper.waitForPromise(
|
||||
() => helper.admin$ && helper.admin$('.settings').val().length > 0, 36000);
|
||||
expect(settings).to.be(helper.admin$('.settings').val());
|
||||
});
|
||||
|
||||
function timeout(ms) {
|
||||
return new Promise((resolve) => setTimeout(resolve, ms));
|
||||
}
|
||||
|
||||
it('restart works', async function () {
|
||||
// restarts
|
||||
helper.admin$('#restartEtherpad').click();
|
||||
|
||||
// Hacky... Other suggestions welcome..
|
||||
await timeout(200000);
|
||||
let success = false;
|
||||
$.ajax({
|
||||
url: `${location.protocol}//admin:changeme@${location.hostname}:${location.port}/admin`,
|
||||
type: 'GET',
|
||||
success: () => success = true,
|
||||
});
|
||||
await helper.waitForPromise(() => success === true);
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue