adminsettings test: Refactoring. We cannot guarantee that the system time on

SauceLabs and Github is in sync. In case the SauceLabs runner's clock is slow the test would have failed.

Also be a little stricter for other assertions.
fix-adminupdateplugins
webzwo0i 2021-07-16 20:46:04 +02:00
parent c228283c17
commit da804f0142
1 changed files with 7 additions and 10 deletions

View File

@ -38,7 +38,8 @@ describe('Admin > Settings', function () {
// reset it to the old value
helper.newAdmin('settings');
await helper.waitForPromise(
() => helper.admin$ && helper.admin$('.settings').val().length > 0, 20000);
() => helper.admin$ &&
helper.admin$('.settings').val().length === settingsLength + 11, 20000);
// replace the test value with a line break
helper.admin$('.settings').val((_, text) => text.replace('/* test */\n', ''));
@ -50,12 +51,11 @@ describe('Admin > Settings', function () {
// 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());
() => helper.admin$ && helper.admin$('.settings').val().length === settingsLength &&
settings === helper.admin$('.settings').val(), 20000);
});
it('restart works', async function () {
this.timeout(60000);
const getStartTime = async () => {
try {
const {httpStartTime} = await $.ajax({
@ -66,18 +66,15 @@ describe('Admin > Settings', function () {
});
return httpStartTime;
} catch (err) {
helper.logDebugMsg(`an error occurred: ${err.message} of type ${err.name}`);
return null;
}
};
await helper.waitForPromise(async () => {
const startTime = await getStartTime();
return startTime != null && startTime > 0 && Date.now() > startTime;
}, 1000, 500);
const clickTime = Date.now();
const oldStartTime = await getStartTime();
helper.admin$('#restartEtherpad').click();
await helper.waitForPromise(async () => {
const startTime = await getStartTime();
return startTime != null && startTime >= clickTime;
return startTime != null && startTime >= oldStartTime;
}, 60000, 500);
});
});