2021-02-01 20:23:14 +00:00
|
|
|
'use strict';
|
|
|
|
|
2020-11-23 13:21:51 -05:00
|
|
|
describe('undo button', function () {
|
2021-03-31 21:14:02 -04:00
|
|
|
beforeEach(async function () {
|
|
|
|
await helper.aNewPad();
|
2012-10-09 00:52:46 +01:00
|
|
|
});
|
|
|
|
|
2021-03-31 21:14:02 -04:00
|
|
|
it('undo some typing by clicking undo button', async function () {
|
2020-11-23 13:21:51 -05:00
|
|
|
const inner$ = helper.padInner$;
|
|
|
|
const chrome$ = helper.padChrome$;
|
2020-03-24 01:04:24 +01:00
|
|
|
|
2012-10-09 00:52:46 +01:00
|
|
|
// get the first text element inside the editable space
|
2020-11-23 13:21:51 -05:00
|
|
|
const $firstTextElement = inner$('div span').first();
|
|
|
|
const originalValue = $firstTextElement.text(); // get the original value
|
2012-10-09 00:52:46 +01:00
|
|
|
|
2020-11-23 13:21:51 -05:00
|
|
|
$firstTextElement.sendkeys('foo'); // send line 1 to the pad
|
|
|
|
const modifiedValue = $firstTextElement.text(); // get the modified value
|
2012-10-09 00:52:46 +01:00
|
|
|
expect(modifiedValue).not.to.be(originalValue); // expect the value to change
|
|
|
|
|
|
|
|
// get clear authorship button as a variable
|
2020-11-23 13:21:51 -05:00
|
|
|
const $undoButton = chrome$('.buttonicon-undo');
|
2012-10-09 00:52:46 +01:00
|
|
|
// click the button
|
2021-07-05 17:12:47 +02:00
|
|
|
$undoButton.trigger('click');
|
2012-10-09 00:52:46 +01:00
|
|
|
|
2021-03-31 21:14:02 -04:00
|
|
|
await helper.waitForPromise(() => inner$('div span').first().text() === originalValue);
|
2012-10-09 00:52:46 +01:00
|
|
|
});
|
2013-03-13 15:00:04 -03:00
|
|
|
|
2021-03-31 21:14:02 -04:00
|
|
|
it('undo some typing using a keypress', async function () {
|
2020-11-23 13:21:51 -05:00
|
|
|
const inner$ = helper.padInner$;
|
2013-03-13 15:00:04 -03:00
|
|
|
|
|
|
|
// get the first text element inside the editable space
|
2020-11-23 13:21:51 -05:00
|
|
|
const $firstTextElement = inner$('div span').first();
|
|
|
|
const originalValue = $firstTextElement.text(); // get the original value
|
2013-03-13 15:00:04 -03:00
|
|
|
|
2020-11-23 13:21:51 -05:00
|
|
|
$firstTextElement.sendkeys('foo'); // send line 1 to the pad
|
|
|
|
const modifiedValue = $firstTextElement.text(); // get the modified value
|
2013-03-13 15:00:04 -03:00
|
|
|
expect(modifiedValue).not.to.be(originalValue); // expect the value to change
|
|
|
|
|
2021-02-01 20:23:14 +00:00
|
|
|
const e = new inner$.Event(helper.evtType);
|
2013-03-13 15:00:04 -03:00
|
|
|
e.ctrlKey = true; // Control key
|
|
|
|
e.which = 90; // z
|
2020-11-23 13:21:51 -05:00
|
|
|
inner$('#innerdocbody').trigger(e);
|
2013-03-13 15:00:04 -03:00
|
|
|
|
2021-03-31 21:14:02 -04:00
|
|
|
await helper.waitForPromise(() => inner$('div span').first().text() === originalValue);
|
2013-03-13 15:00:04 -03:00
|
|
|
});
|
2012-10-09 00:52:46 +01:00
|
|
|
});
|