mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-25 01:46:14 -04:00
Low hanging lint frontend tests (#4695)
* lint: low hanging specs/alphabet.js * lint: low hanging specs/authorship_of_editions.js * lint: low hanging specs/bold.js * lint: low hanging specs/caret.js * lint: low hanging specs/change_user_color.js * lint: low hanging specs/change_user_name.js * lint: low hanging specs/chat.js * lint: low hanging specs/chat_load_messages.js * lint: low hanging specs/clear_authorship_colors.js * lint: low hanging specs/delete.js * lint: low hanging specs/drag_and_drop.js * lint: low hanging specs/embed_value.js * lint: low hanging specs/enter.js * lint: low hanging specs/font_type.js * lint: low hanging specs/helper.js * lint: low hanging specs/importexport.js * lint: low hanging specs/importindents.js * lint: low hanging specs/indentation.js * lint: low hanging specs/italic.js * lint: low hanging specs/language.js * lint: low hanging specs/multiple_authors_clear_authorship_colors.js * lint: low hanging specs/ordered_list.js * lint: low hanging specs/pad_modal.js * lint: low hanging specs/redo.js * lint: low hanging specs/responsiveness.js * lint: low hanging specs/select_formatting_buttons.js * lint: low hanging specs/strikethrough.js * lint: low hanging specs/timeslider.js * lint: low hanging specs/timeslider_labels.js * lint: low hanging specs/timeslider_numeric_padID.js * lint: low hanging specs/timeslider_revisions.js * lint: low hanging specs/undo.js * lint: low hanging specs/unordered_list.js * lint: low hanging specs/xxauto_reconnect.js * lint: attempt to do remote_runner.js * lint: helper linting * lint: rate limit linting * use constructor for Event to make eslint happier * for squash: lint fix refinements * for squash: lint fix refinements Co-authored-by: Richard Hansen <rhansen@rhansen.org>
This commit is contained in:
parent
759e2aaec3
commit
915849b319
39 changed files with 595 additions and 357 deletions
|
@ -1,3 +1,5 @@
|
|||
'use strict';
|
||||
|
||||
describe('timeslider', function () {
|
||||
// create a new pad before each test run
|
||||
beforeEach(function (cb) {
|
||||
|
@ -23,7 +25,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 +69,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 +83,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 +98,23 @@ 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) {
|
||||
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) {
|
||||
// Empty catch block <3
|
||||
}
|
||||
if (timeslider$) {
|
||||
return timeslider$('#innerdocbody').text().length == oldLength;
|
||||
return timeslider$('#innerdocbody').text().length === oldLength;
|
||||
}
|
||||
}, 10000).always(() => {
|
||||
expect(timeslider$('#innerdocbody').text().length).to.eql(oldLength);
|
||||
|
@ -147,24 +155,26 @@ describe('timeslider', function () {
|
|||
|
||||
it('checks the export url', function (done) {
|
||||
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) {
|
||||
// Empty catch block <3
|
||||
}
|
||||
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