mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-21 16:06:16 -04:00
tests: Improve /admin/settings
restart test
This commit is contained in:
parent
ac52fb8a9d
commit
f9ec49d7ac
1 changed files with 23 additions and 15 deletions
|
@ -54,22 +54,30 @@ describe('Admin > Settings', function () {
|
||||||
expect(settings).to.be(helper.admin$('.settings').val());
|
expect(settings).to.be(helper.admin$('.settings').val());
|
||||||
});
|
});
|
||||||
|
|
||||||
function timeout(ms) {
|
|
||||||
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
||||||
}
|
|
||||||
|
|
||||||
it('restart works', async function () {
|
it('restart works', async function () {
|
||||||
// restarts
|
this.timeout(60000);
|
||||||
|
const getUptime = async () => {
|
||||||
|
try {
|
||||||
|
const {httpUptime} = await $.ajax({
|
||||||
|
url: new URL('/stats', window.location.href),
|
||||||
|
method: 'GET',
|
||||||
|
dataType: 'json',
|
||||||
|
timeout: 450, // Slightly less than the waitForPromise() interval.
|
||||||
|
});
|
||||||
|
return httpUptime;
|
||||||
|
} catch (err) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
await helper.waitForPromise(async () => {
|
||||||
|
const uptime = await getUptime();
|
||||||
|
return uptime != null && uptime > 0;
|
||||||
|
}, 1000, 500);
|
||||||
|
const clickTime = Date.now();
|
||||||
helper.admin$('#restartEtherpad').click();
|
helper.admin$('#restartEtherpad').click();
|
||||||
|
await helper.waitForPromise(async () => {
|
||||||
// Hacky... Other suggestions welcome..
|
const uptime = await getUptime();
|
||||||
await timeout(200000);
|
return uptime != null && Date.now() - uptime >= clickTime;
|
||||||
let success = false;
|
}, 60000, 500);
|
||||||
$.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