mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-22 00:16:15 -04:00
tests: Fix helper.newPad()
retries
* Pass retry count in options object so that each pad has its own retry count. * Delete useless `origPadName` variable.
This commit is contained in:
parent
eac5a52690
commit
27b35699ea
1 changed files with 7 additions and 20 deletions
|
@ -89,19 +89,11 @@ const helper = {};
|
||||||
}
|
}
|
||||||
helper.evtType = evtType;
|
helper.evtType = evtType;
|
||||||
|
|
||||||
// @todo needs fixing asap
|
helper.newPad = (opts, padName) => {
|
||||||
// newPad occasionally timeouts, might be a problem with ready/onload code during page setup
|
opts = Object.assign({
|
||||||
// This ensures that tests run regardless of this problem
|
_retry: 0,
|
||||||
helper.retry = 0;
|
clearCookies: true,
|
||||||
|
}, typeof opts === 'function' ? {cb: opts} : opts);
|
||||||
helper.newPad = (cb, padName) => {
|
|
||||||
// build opts object
|
|
||||||
let opts = {clearCookies: true};
|
|
||||||
if (typeof cb === 'function') {
|
|
||||||
opts.cb = cb;
|
|
||||||
} else {
|
|
||||||
opts = _.defaults(cb, opts);
|
|
||||||
}
|
|
||||||
|
|
||||||
// if opts.params is set we manipulate the URL to include URL parameters IE ?foo=Bah.
|
// if opts.params is set we manipulate the URL to include URL parameters IE ?foo=Bah.
|
||||||
let encodedParams;
|
let encodedParams;
|
||||||
|
@ -120,8 +112,6 @@ const helper = {};
|
||||||
|
|
||||||
if (!padName) padName = `FRONTEND_TEST_${helper.randomString(20)}`;
|
if (!padName) padName = `FRONTEND_TEST_${helper.randomString(20)}`;
|
||||||
$iframe = $(`<iframe src='/p/${padName}${hash || ''}${encodedParams || ''}'></iframe>`);
|
$iframe = $(`<iframe src='/p/${padName}${hash || ''}${encodedParams || ''}'></iframe>`);
|
||||||
// needed for retry
|
|
||||||
const origPadName = padName;
|
|
||||||
|
|
||||||
// clean up inner iframe references
|
// clean up inner iframe references
|
||||||
helper.padChrome$ = helper.padOuter$ = helper.padInner$ = null;
|
helper.padChrome$ = helper.padOuter$ = helper.padInner$ = null;
|
||||||
|
@ -170,11 +160,8 @@ const helper = {};
|
||||||
helper.spyOnSocketIO();
|
helper.spyOnSocketIO();
|
||||||
opts.cb();
|
opts.cb();
|
||||||
}).fail(() => {
|
}).fail(() => {
|
||||||
if (helper.retry > 3) {
|
if (opts._retry++ >= 4) throw new Error('Pad never loaded');
|
||||||
throw new Error('Pad never loaded');
|
helper.newPad(opts, padName);
|
||||||
}
|
|
||||||
helper.retry++;
|
|
||||||
helper.newPad(cb, origPadName);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue