mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-22 16:36:15 -04:00
tests: Speed up helper.edit()
and helper.clearPad()
This commit is contained in:
parent
7a154b1e1d
commit
7cbb3f565d
3 changed files with 33 additions and 6 deletions
|
@ -127,6 +127,8 @@ const helper = {};
|
|||
$('#iframe-container').append($iframe);
|
||||
await new Promise((resolve) => $iframe.one('load', resolve));
|
||||
helper.padChrome$ = getFrameJQuery($('#iframe-container iframe'));
|
||||
helper.padChrome$.padeditor =
|
||||
helper.padChrome$.window.require('ep_etherpad-lite/static/js/pad_editor').padeditor;
|
||||
if (opts.clearCookies) {
|
||||
helper.clearPadPrefCookie();
|
||||
}
|
||||
|
@ -260,6 +262,22 @@ const helper = {};
|
|||
selection.addRange(range);
|
||||
};
|
||||
|
||||
// Temporarily reduces minimum time between commits and calls the provided function with a single
|
||||
// argument: a function that immediately incorporates all pad edits (as opposed to waiting for the
|
||||
// idle timer to fire).
|
||||
helper.withFastCommit = async (fn) => {
|
||||
const incorp = () => helper.padChrome$.padeditor.ace.callWithAce(
|
||||
(ace) => ace.ace_inCallStackIfNecessary('helper.edit', () => ace.ace_fastIncorp()));
|
||||
const cc = helper.padChrome$.window.pad.collabClient;
|
||||
const {commitDelay} = cc;
|
||||
cc.commitDelay = 0;
|
||||
try {
|
||||
return await fn(incorp);
|
||||
} finally {
|
||||
cc.commitDelay = commitDelay;
|
||||
}
|
||||
};
|
||||
|
||||
const getTextNodeAndOffsetOf = ($targetLine, targetOffsetAtLine) => {
|
||||
const $textNodes = $targetLine.find('*').contents().filter(function () {
|
||||
return this.nodeType === Node.TEXT_NODE;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue