2012-11-26 21:15:10 +01:00
|
|
|
describe("timeslider", function(){
|
|
|
|
//create a new pad before each test run
|
|
|
|
beforeEach(function(cb){
|
|
|
|
helper.newPad(cb);
|
|
|
|
this.timeout(6000);
|
|
|
|
});
|
2013-01-07 12:49:04 +01:00
|
|
|
xit("loads adds a hundred revisions", function(done) {
|
2012-11-26 21:15:10 +01:00
|
|
|
var inner$ = helper.padInner$;
|
|
|
|
var chrome$ = helper.padChrome$;
|
|
|
|
|
|
|
|
// make some changes to produce 100 revisions
|
|
|
|
var timePerRev = 900
|
2012-12-07 16:20:23 +01:00
|
|
|
, revs = 100;
|
2012-11-26 21:15:10 +01:00
|
|
|
this.timeout(revs*timePerRev+10000);
|
|
|
|
for(var i=0; i < revs; i++) {
|
|
|
|
setTimeout(function() {
|
2012-12-07 16:20:23 +01:00
|
|
|
// enter 'a' in the first text element
|
2012-11-26 21:15:10 +01:00
|
|
|
inner$("div").first().sendkeys('a');
|
|
|
|
}, timePerRev*i);
|
|
|
|
}
|
|
|
|
|
|
|
|
setTimeout(function() {
|
2012-12-07 16:20:23 +01:00
|
|
|
// go to timeslider
|
2012-11-26 21:15:10 +01:00
|
|
|
$('#iframe-container iframe').attr('src', $('#iframe-container iframe').attr('src')+'/timeslider');
|
|
|
|
|
2012-12-07 16:20:23 +01:00
|
|
|
setTimeout(function() {
|
|
|
|
var timeslider$ = $('#iframe-container iframe')[0].contentWindow.$;
|
|
|
|
var $sliderBar = timeslider$('#ui-slider-bar');
|
|
|
|
|
|
|
|
var latestContents = timeslider$('#padcontent').text();
|
2012-11-26 21:15:10 +01:00
|
|
|
|
2012-12-07 16:20:23 +01:00
|
|
|
// 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')
|
2012-11-26 21:15:10 +01:00
|
|
|
|
2012-12-07 16:20:23 +01:00
|
|
|
setTimeout(function() {
|
|
|
|
//make sure the text has changed
|
|
|
|
expect( timeslider$('#padcontent').text() ).not.to.eql( latestContents );
|
|
|
|
done();
|
|
|
|
}, 1000);
|
|
|
|
|
|
|
|
}, 6000);
|
2012-11-26 21:15:10 +01:00
|
|
|
}, revs*timePerRev);
|
|
|
|
});
|
2013-01-28 21:12:50 +01:00
|
|
|
it("changes the url when clicking on the timeslider", function(done) {
|
|
|
|
var inner$ = helper.padInner$;
|
|
|
|
var chrome$ = helper.padChrome$;
|
|
|
|
|
|
|
|
// make some changes to produce 7 revisions
|
2013-02-07 16:24:30 +01:00
|
|
|
var timePerRev = 1000
|
|
|
|
, revs = 20;
|
2013-01-28 21:12:50 +01:00
|
|
|
this.timeout(revs*timePerRev+10000);
|
|
|
|
for(var i=0; i < revs; i++) {
|
|
|
|
setTimeout(function() {
|
|
|
|
// enter 'a' in the first text element
|
|
|
|
inner$("div").first().sendkeys('a');
|
|
|
|
}, timePerRev*i);
|
|
|
|
}
|
|
|
|
|
|
|
|
setTimeout(function() {
|
|
|
|
// go to timeslider
|
|
|
|
$('#iframe-container iframe').attr('src', $('#iframe-container iframe').attr('src')+'/timeslider');
|
|
|
|
|
|
|
|
setTimeout(function() {
|
|
|
|
var timeslider$ = $('#iframe-container iframe')[0].contentWindow.$;
|
|
|
|
var $sliderBar = timeslider$('#ui-slider-bar');
|
|
|
|
|
|
|
|
var latestContents = timeslider$('#padcontent').text();
|
|
|
|
|
|
|
|
var oldUrl = $('#iframe-container iframe')[0].contentWindow.location.hash;
|
|
|
|
|
|
|
|
// Click somewhere on the timeslider
|
|
|
|
var e = new jQuery.Event('mousedown');
|
|
|
|
e.clientX = e.pageX = 150;
|
|
|
|
e.clientY = e.pageY = 60;
|
|
|
|
$sliderBar.trigger(e);
|
|
|
|
|
|
|
|
helper.waitFor(function(){
|
|
|
|
return $('#iframe-container iframe')[0].contentWindow.location.hash != oldUrl;
|
|
|
|
}, 6000).always(function(){
|
|
|
|
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) {
|
|
|
|
var inner$ = helper.padInner$;
|
2013-02-07 17:34:31 +01:00
|
|
|
var chrome$ = helper.padChrome$;
|
|
|
|
this.timeout(20000);
|
|
|
|
|
|
|
|
// wait for the text to be loaded
|
|
|
|
helper.waitFor(function(){
|
|
|
|
return inner$('body').text().length != 0;
|
|
|
|
}, 6000).always(function() {
|
|
|
|
var newLines = inner$('body div').length;
|
|
|
|
var oldLength = inner$('body').text().length + newLines / 2;
|
|
|
|
expect( oldLength ).to.not.eql( 0 );
|
|
|
|
inner$("div").first().sendkeys('a');
|
2013-01-28 21:12:50 +01:00
|
|
|
|
2013-02-07 17:34:31 +01:00
|
|
|
// wait for our additional revision to be added
|
2013-01-28 21:12:50 +01:00
|
|
|
helper.waitFor(function(){
|
2013-02-07 17:34:31 +01:00
|
|
|
// newLines takes the new lines into account which are strippen when using
|
|
|
|
// inner$('body').text(), one <div> is used for one line in ACE.
|
|
|
|
var 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.
|
|
|
|
var colorOkay = inner$('span').first().attr('class').indexOf("author-") == 0;
|
|
|
|
return lenOkay && colorOkay;
|
|
|
|
}, 6000).always(function() {
|
|
|
|
// go to timeslider with a specific revision set
|
|
|
|
$('#iframe-container iframe').attr('src', $('#iframe-container iframe').attr('src')+'/timeslider#0');
|
|
|
|
|
|
|
|
// wait for the timeslider to be loaded
|
|
|
|
helper.waitFor(function(){
|
|
|
|
try {
|
|
|
|
timeslider$ = $('#iframe-container iframe')[0].contentWindow.$;
|
|
|
|
} catch(e){}
|
|
|
|
if(timeslider$){
|
|
|
|
return timeslider$('#padcontent').text().length == oldLength;
|
|
|
|
}
|
|
|
|
}, 6000).always(function(){
|
|
|
|
expect( timeslider$('#padcontent').text().length ).to.eql( oldLength );
|
|
|
|
done();
|
|
|
|
});
|
2013-01-28 21:12:50 +01:00
|
|
|
});
|
2013-02-07 17:34:31 +01:00
|
|
|
});
|
2013-01-28 21:12:50 +01:00
|
|
|
});
|
2013-01-28 21:38:56 +01:00
|
|
|
it("checks the export url", function(done) {
|
|
|
|
var inner$ = helper.padInner$;
|
|
|
|
var chrome$ = helper.padChrome$;
|
|
|
|
this.timeout(11000);
|
|
|
|
inner$("div").first().sendkeys('a');
|
|
|
|
|
|
|
|
setTimeout(function() {
|
|
|
|
// go to timeslider
|
|
|
|
$('#iframe-container iframe').attr('src', $('#iframe-container iframe').attr('src')+'/timeslider#0');
|
|
|
|
var timeslider$;
|
|
|
|
var exportLink;
|
|
|
|
|
|
|
|
helper.waitFor(function(){
|
2013-02-07 16:24:30 +01:00
|
|
|
try{
|
|
|
|
timeslider$ = $('#iframe-container iframe')[0].contentWindow.$;
|
|
|
|
}catch(e){}
|
2013-01-28 21:38:56 +01:00
|
|
|
if(!timeslider$)
|
|
|
|
return false;
|
|
|
|
exportLink = timeslider$('#exportplaina').attr('href');
|
|
|
|
if(!exportLink)
|
|
|
|
return false;
|
|
|
|
return exportLink.substr(exportLink.length - 12) == "0/export/txt";
|
|
|
|
}, 6000).always(function(){
|
|
|
|
expect( exportLink.substr(exportLink.length - 12) ).to.eql( "0/export/txt" );
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
}, 2500);
|
|
|
|
});
|
2012-11-26 21:15:10 +01:00
|
|
|
});
|