etherpad-lite/tests/frontend/specs/redo.js

69 lines
2.3 KiB
JavaScript
Raw Normal View History

2012-10-28 19:19:16 +01:00
describe("undo button then redo button", function(){
2012-10-09 02:30:46 +02:00
beforeEach(function(cb){
helper.newPad(cb); // creates a new pad
2012-11-02 00:19:59 +01:00
this.timeout(60000);
2012-10-09 02:30:46 +02:00
});
it("redo some typing with button", function(done){
2012-10-09 02:30:46 +02:00
var inner$ = helper.padInner$;
var chrome$ = helper.padChrome$;
2012-10-09 02:30:46 +02:00
// get the first text element inside the editable space
var $firstTextElement = inner$("div span").first();
var originalValue = $firstTextElement.text(); // get the original value
2012-10-28 19:19:16 +01:00
var newString = "Foo";
2012-10-09 02:30:46 +02:00
2012-10-28 19:19:16 +01:00
$firstTextElement.sendkeys(newString); // send line 1 to the pad
2012-10-09 02:30:46 +02:00
var modifiedValue = $firstTextElement.text(); // get the modified value
expect(modifiedValue).not.to.be(originalValue); // expect the value to change
2012-10-28 19:19:16 +01:00
// get undo and redo buttons
2012-10-09 02:30:46 +02:00
var $undoButton = chrome$(".buttonicon-undo");
var $redoButton = chrome$(".buttonicon-redo");
// click the buttons
2012-10-28 19:19:16 +01:00
$undoButton.click(); // removes foo
$redoButton.click(); // resends foo
2012-10-09 02:30:46 +02:00
helper.waitFor(function(){
2012-10-28 19:19:16 +01:00
return inner$("div span").first().text() === newString;
2012-10-09 02:30:46 +02:00
}).done(function(){
2012-10-28 19:19:16 +01:00
var finalValue = inner$("div").first().text();
2012-10-09 02:30:46 +02:00
expect(finalValue).to.be(modifiedValue); // expect the value to change
done();
});
});
it("redo some typing with keypress", function(done){
var inner$ = helper.padInner$;
var chrome$ = helper.padChrome$;
// get the first text element inside the editable space
var $firstTextElement = inner$("div span").first();
var originalValue = $firstTextElement.text(); // get the original value
var newString = "Foo";
$firstTextElement.sendkeys(newString); // send line 1 to the pad
var modifiedValue = $firstTextElement.text(); // get the modified value
expect(modifiedValue).not.to.be(originalValue); // expect the value to change
var e = inner$.Event(helper.evtType);
e.ctrlKey = true; // Control key
e.which = 90; // z
inner$("#innerdocbody").trigger(e);
2020-03-23 12:09:05 +01:00
var e = inner$.Event(helper.evtType);
e.ctrlKey = true; // Control key
e.which = 121; // y
inner$("#innerdocbody").trigger(e);
helper.waitFor(function(){
return inner$("div span").first().text() === newString;
}).done(function(){
var finalValue = inner$("div").first().text();
expect(finalValue).to.be(modifiedValue); // expect the value to change
done();
});
});
2012-10-09 02:30:46 +02:00
});