mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-20 15:36:16 -04:00
tests: New helper.clearPad
method
This commit is contained in:
parent
ca01856f94
commit
1c388ca66e
2 changed files with 18 additions and 12 deletions
|
@ -219,3 +219,20 @@ helper.timesliderTextLines = function () {
|
||||||
return $(this).text();
|
return $(this).text();
|
||||||
}).get();
|
}).get();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
helper.padIsEmpty = () => (
|
||||||
|
!helper.padInner$.document.getSelection().isCollapsed ||
|
||||||
|
(helper.padInner$('div').length === 1 && helper.padInner$('div').first().html() === '<br>'));
|
||||||
|
|
||||||
|
helper.clearPad = async () => {
|
||||||
|
if (helper.padIsEmpty()) return;
|
||||||
|
const commitsBefore = helper.commits.length;
|
||||||
|
const lines = helper.linesDiv();
|
||||||
|
helper.selectLines(lines[0], lines[lines.length - 1]);
|
||||||
|
await helper.waitForPromise(() => !helper.padInner$.document.getSelection().isCollapsed);
|
||||||
|
const e = new helper.padInner$.Event(helper.evtType);
|
||||||
|
e.keyCode = 8; // delete key
|
||||||
|
helper.padInner$('#innerdocbody').trigger(e);
|
||||||
|
await helper.waitForPromise(helper.padIsEmpty);
|
||||||
|
await helper.waitForPromise(() => helper.commits.length > commitsBefore);
|
||||||
|
};
|
||||||
|
|
|
@ -38,18 +38,7 @@ describe('timeslider follow', function () {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
it('only to lines that exist in the current pad view, see #4389', async function () {
|
it('only to lines that exist in the current pad view, see #4389', async function () {
|
||||||
// Select everything and clear via delete key
|
await helper.clearPad();
|
||||||
const e = helper.padInner$.Event(helper.evtType);
|
|
||||||
e.keyCode = 8; // delete key
|
|
||||||
const lines = helper.linesDiv();
|
|
||||||
helper.selectLines(lines[0], lines[lines.length - 1]); // select all lines
|
|
||||||
// probably unnecessary, but wait for the selection to be Range not Caret
|
|
||||||
await helper.waitForPromise(() => !helper.padInner$.document.getSelection().isCollapsed
|
|
||||||
// only supported in FF57+
|
|
||||||
// return helper.padInner$.document.getSelection().type === 'Range';
|
|
||||||
);
|
|
||||||
helper.padInner$('#innerdocbody').trigger(e);
|
|
||||||
await helper.waitForPromise(() => helper.commits.length === 1);
|
|
||||||
await helper.edit('Test line\n\n');
|
await helper.edit('Test line\n\n');
|
||||||
await helper.edit('Another test line', 3);
|
await helper.edit('Another test line', 3);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue