tests: Speed up helper.edit() and helper.clearPad()

This commit is contained in:
Richard Hansen 2021-04-01 15:52:39 -04:00 committed by webzwo0i
parent 7a154b1e1d
commit 7cbb3f565d
3 changed files with 33 additions and 6 deletions

View file

@ -32,8 +32,11 @@ helper.spyOnSocketIO = () => {
helper.edit = async (message, line) => {
const editsNum = helper.commits.length;
line = line ? line - 1 : 0;
helper.linesDiv()[line].sendkeys(message);
return helper.waitForPromise(() => editsNum + 1 === helper.commits.length);
await helper.withFastCommit(async (incorp) => {
helper.linesDiv()[line].sendkeys(message);
incorp();
await helper.waitForPromise(() => editsNum + 1 === helper.commits.length);
});
};
/**
@ -216,7 +219,10 @@ helper.clearPad = async () => {
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);
await helper.withFastCommit(async (incorp) => {
helper.padInner$('#innerdocbody').trigger(e);
incorp();
await helper.waitForPromise(helper.padIsEmpty);
await helper.waitForPromise(() => helper.commits.length > commitsBefore);
});
};