mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-24 01:16:15 -04:00
low hanging lint and some hard coded timeouts
This commit is contained in:
parent
809670dbea
commit
edf1dabe65
36 changed files with 273 additions and 150 deletions
|
@ -1,3 +1,5 @@
|
|||
'use strict';
|
||||
|
||||
describe('timeslider', function () {
|
||||
// create a new pad before each test run
|
||||
beforeEach(function (cb) {
|
||||
|
@ -5,7 +7,8 @@ describe('timeslider', function () {
|
|||
this.timeout(60000);
|
||||
});
|
||||
|
||||
it('loads adds a hundred revisions', function (done) { // passes
|
||||
it('loads adds a hundred revisions', function (done) {
|
||||
this.timeout(100000);
|
||||
const inner$ = helper.padInner$;
|
||||
const chrome$ = helper.padChrome$;
|
||||
|
||||
|
@ -23,7 +26,8 @@ describe('timeslider', function () {
|
|||
|
||||
setTimeout(() => {
|
||||
// go to timeslider
|
||||
$('#iframe-container iframe').attr('src', `${$('#iframe-container iframe').attr('src')}/timeslider`);
|
||||
$('#iframe-container iframe')
|
||||
.attr('src', `${$('#iframe-container iframe').attr('src')}/timeslider`);
|
||||
|
||||
setTimeout(() => {
|
||||
const timeslider$ = $('#iframe-container iframe')[0].contentWindow.$;
|
||||
|
@ -66,7 +70,6 @@ describe('timeslider', function () {
|
|||
// Disabled as jquery trigger no longer works properly
|
||||
xit('changes the url when clicking on the timeslider', function (done) {
|
||||
const inner$ = helper.padInner$;
|
||||
const chrome$ = helper.padChrome$;
|
||||
|
||||
// make some changes to produce 7 revisions
|
||||
const timePerRev = 1000;
|
||||
|
@ -81,13 +84,13 @@ describe('timeslider', function () {
|
|||
|
||||
setTimeout(() => {
|
||||
// go to timeslider
|
||||
$('#iframe-container iframe').attr('src', `${$('#iframe-container iframe').attr('src')}/timeslider`);
|
||||
$('#iframe-container iframe')
|
||||
.attr('src', `${$('#iframe-container iframe').attr('src')}/timeslider`);
|
||||
|
||||
setTimeout(() => {
|
||||
const timeslider$ = $('#iframe-container iframe')[0].contentWindow.$;
|
||||
const $sliderBar = timeslider$('#ui-slider-bar');
|
||||
|
||||
const latestContents = timeslider$('#innerdocbody').text();
|
||||
const oldUrl = $('#iframe-container iframe')[0].contentWindow.location.hash;
|
||||
|
||||
// Click somewhere on the timeslider
|
||||
|
@ -96,20 +99,22 @@ describe('timeslider', function () {
|
|||
e.clientY = e.pageY = 60;
|
||||
$sliderBar.trigger(e);
|
||||
|
||||
helper.waitFor(() => $('#iframe-container iframe')[0].contentWindow.location.hash != oldUrl, 6000).always(() => {
|
||||
expect($('#iframe-container iframe')[0].contentWindow.location.hash).not.to.eql(oldUrl);
|
||||
done();
|
||||
});
|
||||
helper.waitFor(
|
||||
() => $('#iframe-container iframe')[0].contentWindow.location.hash !== oldUrl, 6000)
|
||||
.always(() => {
|
||||
expect($('#iframe-container iframe')[0].contentWindow.location.hash)
|
||||
.not.to.eql(oldUrl);
|
||||
done();
|
||||
});
|
||||
}, 6000);
|
||||
}, revs * timePerRev);
|
||||
});
|
||||
it('jumps to a revision given in the url', function (done) {
|
||||
this.timeout(6000);
|
||||
const inner$ = helper.padInner$;
|
||||
const chrome$ = helper.padChrome$;
|
||||
this.timeout(40000);
|
||||
|
||||
// wait for the text to be loaded
|
||||
helper.waitFor(() => inner$('body').text().length != 0, 10000).always(() => {
|
||||
helper.waitFor(() => inner$('body').text().length !== 0, 10000).always(() => {
|
||||
const newLines = inner$('body div').length;
|
||||
const oldLength = inner$('body').text().length + newLines / 2;
|
||||
expect(oldLength).to.not.eql(0);
|
||||
|
@ -120,22 +125,25 @@ describe('timeslider', function () {
|
|||
helper.waitFor(() => {
|
||||
// newLines takes the new lines into account which are strippen when using
|
||||
// inner$('body').text(), one <div> is used for one line in ACE.
|
||||
const lenOkay = inner$('body').text().length + newLines / 2 != oldLength;
|
||||
const lenOkay = inner$('body').text().length + newLines / 2 !== oldLength;
|
||||
// this waits for the color to be added to our <span>, which means that the revision
|
||||
// was accepted by the server.
|
||||
const colorOkay = inner$('span').first().attr('class').indexOf('author-') == 0;
|
||||
const colorOkay = inner$('span').first().attr('class').indexOf('author-') === 0;
|
||||
return lenOkay && colorOkay;
|
||||
}, 10000).always(() => {
|
||||
// go to timeslider with a specific revision set
|
||||
$('#iframe-container iframe').attr('src', `${$('#iframe-container iframe').attr('src')}/timeslider#0`);
|
||||
$('#iframe-container iframe')
|
||||
.attr('src', `${$('#iframe-container iframe').attr('src')}/timeslider#0`);
|
||||
|
||||
// wait for the timeslider to be loaded
|
||||
helper.waitFor(() => {
|
||||
try {
|
||||
timeslider$ = $('#iframe-container iframe')[0].contentWindow.$;
|
||||
} catch (e) {}
|
||||
} catch (e) {
|
||||
// silently fart. Deadly.
|
||||
}
|
||||
if (timeslider$) {
|
||||
return timeslider$('#innerdocbody').text().length == oldLength;
|
||||
return timeslider$('#innerdocbody').text().length === oldLength;
|
||||
}
|
||||
}, 10000).always(() => {
|
||||
expect(timeslider$('#innerdocbody').text().length).to.eql(oldLength);
|
||||
|
@ -146,25 +154,28 @@ describe('timeslider', function () {
|
|||
});
|
||||
|
||||
it('checks the export url', function (done) {
|
||||
this.timeout(6000);
|
||||
const inner$ = helper.padInner$;
|
||||
const chrome$ = helper.padChrome$;
|
||||
this.timeout(11000);
|
||||
inner$('div').first().sendkeys('a');
|
||||
|
||||
setTimeout(() => {
|
||||
// go to timeslider
|
||||
$('#iframe-container iframe').attr('src', `${$('#iframe-container iframe').attr('src')}/timeslider#0`);
|
||||
$('#iframe-container iframe')
|
||||
.attr('src', `${$('#iframe-container iframe').attr('src')}/timeslider#0`);
|
||||
let timeslider$;
|
||||
let exportLink;
|
||||
|
||||
helper.waitFor(() => {
|
||||
try {
|
||||
timeslider$ = $('#iframe-container iframe')[0].contentWindow.$;
|
||||
} catch (e) {}
|
||||
} catch (e) {
|
||||
// silently give up on life.
|
||||
}
|
||||
if (!timeslider$) return false;
|
||||
exportLink = timeslider$('#exportplaina').attr('href');
|
||||
if (!exportLink) return false;
|
||||
return exportLink.substr(exportLink.length - 12) == '0/export/txt';
|
||||
return exportLink.substr(exportLink.length - 12) === '0/export/txt';
|
||||
}, 6000).always(() => {
|
||||
expect(exportLink.substr(exportLink.length - 12)).to.eql('0/export/txt');
|
||||
done();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue