tests: refactor some frontend tests (#4408)

* don't include sendkeys in index.html as it's included in helper.init
mocha opts: add default timeout and replace ignoreLeaks with checkLeaks,
as the former is deprecated

* introduce helper.edit to write to a pad

* add test to check if helper.edit() supports line numbers

* helper tests: waitFor/waitForPromise seem to be a little bit faster sometimes

* tests: refactor chat.js

* tests: refactor timeslider_numeric_padID

* tests: refactor timeslider_labels

* tests: refactor timeslider_follow

* ensure followContents is enabled, although it should be by default

* timeslider_follow: increase number of revision for Edge

* make textLines() depend on linesDiv()

Co-authored-by: Richard Hansen <rhansen@rhansen.org>

* make linesDiv return standard Array

* use `contain` instead of `indexOf`

* more fixes from the review

* review fixes

* align waitFor and waitForPromise behaviour

* timeslider_follow: check if it's following to the correct lines

* lower expected waitFor/waitForPromise interval check

* disable responsivness and regression test in timeslider_follow

* timeslider_follow: fix Range detection

* more explicit test for linesDiv

Co-authored-by: Richard Hansen <rhansen@rhansen.org>
This commit is contained in:
webzwo0i 2020-10-21 19:43:17 +02:00 committed by GitHub
parent 94cb000e8f
commit 69c7033a86
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 685 additions and 252 deletions

View file

@ -4,64 +4,26 @@ describe("timeslider", function(){
//create a new pad before each test run
beforeEach(function(cb){
helper.newPad(cb, padId);
this.timeout(60000);
});
it("Makes sure the export URIs are as expected when the padID is numeric", function(done) {
var inner$ = helper.padInner$;
var chrome$ = helper.padChrome$;
it("Makes sure the export URIs are as expected when the padID is numeric", async function() {
await helper.edit('a\n');
// make some changes to produce 100 revisions
var revs = 10;
this.timeout(60000);
for(var i=0; i < revs; i++) {
setTimeout(function() {
// enter 'a' in the first text element
inner$("div").first().sendkeys('a');
}, 100);
}
await helper.gotoTimeslider(1);
setTimeout(function() {
// go to timeslider
$('#iframe-container iframe').attr('src', $('#iframe-container iframe').attr('src')+'/timeslider');
// ensure we are on revision 1
await helper.waitForPromise(function(){return helper.contentWindow().location.hash === '#1'})
setTimeout(function() {
var timeslider$ = $('#iframe-container iframe')[0].contentWindow.$;
var $sliderBar = timeslider$('#ui-slider-bar');
// expect URI to be similar to
// http://192.168.1.48:9001/p/2/1/export/html
// http://192.168.1.48:9001/p/735773577399/1/export/html
let rev1ExportLink = helper.contentWindow().$('#exporthtmla').attr('href');
expect(rev1ExportLink).to.contain('/1/export/html');
var latestContents = timeslider$('#padcontent').text();
// Click somewhere left on the timeslider to go to revision 0
helper.sliderClick(30);
// Expect the date and time to be shown
// Click somewhere on the timeslider
var e = new jQuery.Event('mousedown');
e.clientX = e.pageX = 150;
e.clientY = e.pageY = 45;
$sliderBar.trigger(e);
e = new jQuery.Event('mousedown');
e.clientX = e.pageX = 150;
e.clientY = e.pageY = 40;
$sliderBar.trigger(e);
e = new jQuery.Event('mousedown');
e.clientX = e.pageX = 150;
e.clientY = e.pageY = 50;
$sliderBar.trigger(e);
$sliderBar.trigger('mouseup')
setTimeout(function() {
// expect URI to be similar to
// http://192.168.1.48:9001/p/2/2/export/html
// http://192.168.1.48:9001/p/735773577399/0/export/html
var exportLink = timeslider$('#exporthtmla').attr('href');
var checkVal = padId + "/0/export/html";
var includesCorrectURI = exportLink.indexOf(checkVal);
expect(includesCorrectURI).to.not.be(-1);
done();
}, 400);
}, 2000);
}, 2000);
let rev0ExportLink = helper.contentWindow().$('#exporthtmla').attr('href');
expect(rev0ExportLink).to.contain('/0/export/html');
});
});