Simplify the integration test in adding a function to turn on/off an editing tool

This commit is contained in:
Calixte Denizet 2024-05-24 19:11:37 +02:00
parent 18a7bd60f7
commit b6b02ccff6
5 changed files with 86 additions and 138 deletions

View file

@ -581,6 +581,23 @@ async function kbFocusPrevious(page) {
await awaitPromise(handle);
}
async function switchToEditor(name, page, disable = false) {
const modeChangedHandle = await createPromise(page, resolve => {
window.PDFViewerApplication.eventBus.on(
"annotationeditormodechanged",
resolve,
{ once: true }
);
});
await page.click(`#editor${name}`);
name = name.toLowerCase();
await page.waitForSelector(
".annotationEditorLayer" +
(disable ? `:not(.${name}Editing)` : `.${name}Editing`)
);
await awaitPromise(modeChangedHandle);
}
export {
awaitPromise,
clearInput,
@ -622,6 +639,7 @@ export {
pasteFromClipboard,
scrollIntoView,
serializeBitmapDimensions,
switchToEditor,
waitForAnnotationEditorLayer,
waitForEntryInStorage,
waitForEvent,