wait longer to arrive at #home but poll every 100ms
This commit is contained in:
parent
be32414214
commit
b01e126433
2 changed files with 18 additions and 3 deletions
|
@ -201,4 +201,17 @@ module.exports = class RiotSession {
|
||||||
close() {
|
close() {
|
||||||
return this.browser.close();
|
return this.browser.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async poll(callback, timeout) {
|
||||||
|
const INTERVAL = 100;
|
||||||
|
let waited = 0;
|
||||||
|
while(waited < timeout) {
|
||||||
|
await this.delay(INTERVAL);
|
||||||
|
waited += INTERVAL;
|
||||||
|
if (callback()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,9 +64,11 @@ module.exports = async function signup(session, username, password, homeserver)
|
||||||
|
|
||||||
//wait for registration to finish so the hash gets set
|
//wait for registration to finish so the hash gets set
|
||||||
//onhashchange better?
|
//onhashchange better?
|
||||||
await session.delay(2000);
|
|
||||||
|
|
||||||
const url = session.page.url();
|
const foundHomeUrl = await session.poll(() => {
|
||||||
assert.strictEqual(url, session.url('/#/home'));
|
const url = session.page.url();
|
||||||
|
return url === session.url('/#/home');
|
||||||
|
}, 5000);
|
||||||
|
assert(foundHomeUrl);
|
||||||
session.log.done();
|
session.log.done();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue