Fixed "jumps to a revision given in the url" test

pull/1468/head
mluto 2013-02-07 17:34:31 +01:00
parent f65ad93fb9
commit ae6a9c25ae
1 changed files with 36 additions and 21 deletions

View File

@ -98,32 +98,47 @@ describe("timeslider", function(){
}, 6000); }, 6000);
}, revs*timePerRev); }, revs*timePerRev);
}); });
// This test is bad because it expects char length to be static
// A much better way would be get the charCount before sending new chars
it("jumps to a revision given in the url", function(done) { it("jumps to a revision given in the url", function(done) {
var inner$ = helper.padInner$; var inner$ = helper.padInner$;
var chrome$ = helper.padChrome$; var chrome$ = helper.padChrome$;
this.timeout(15000); this.timeout(20000);
inner$("div").first().sendkeys('a');
setTimeout(function() { // wait for the text to be loaded
// go to timeslider with a specific revision set helper.waitFor(function(){
$('#iframe-container iframe').attr('src', $('#iframe-container iframe').attr('src')+'/timeslider#0'); return inner$('body').text().length != 0;
var timeslider$; }, 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');
// wait for our additional revision to be added
helper.waitFor(function(){ helper.waitFor(function(){
try{ // newLines takes the new lines into account which are strippen when using
timeslider$ = $('#iframe-container iframe')[0].contentWindow.$; // inner$('body').text(), one <div> is used for one line in ACE.
}catch(e){ 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
if(timeslider$){ // was accepted by the server.
return timeslider$('#padcontent').text().length == 230; var colorOkay = inner$('span').first().attr('class').indexOf("author-") == 0;
} return lenOkay && colorOkay;
}, 6000).always(function(){ }, 6000).always(function() {
expect( timeslider$('#padcontent').text().length ).to.eql( 230 ); // go to timeslider with a specific revision set
done(); $('#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();
});
}); });
}, 2500); });
}); });
it("checks the export url", function(done) { it("checks the export url", function(done) {
var inner$ = helper.padInner$; var inner$ = helper.padInner$;