From f6b215144d66e4e163ec1f033bc50c5b78ab4216 Mon Sep 17 00:00:00 2001 From: Calixte Denizet Date: Tue, 19 Mar 2024 22:29:59 +0100 Subject: [PATCH] Simplify the copy & paste integration test --- test/integration/copy_paste_spec.mjs | 27 ++++++++------------------- test/integration/test_utils.mjs | 8 -------- 2 files changed, 8 insertions(+), 27 deletions(-) diff --git a/test/integration/copy_paste_spec.mjs b/test/integration/copy_paste_spec.mjs index dac86b8cf..6c18929d9 100644 --- a/test/integration/copy_paste_spec.mjs +++ b/test/integration/copy_paste_spec.mjs @@ -20,7 +20,6 @@ import { loadAndWait, mockClipboard, waitForEvent, - waitForTextLayer, } from "./test_utils.mjs"; const selectAll = async page => { @@ -40,17 +39,7 @@ describe("Copy and paste", () => { let pages; beforeAll(async () => { - pages = await loadAndWait( - "tracemonkey.pdf", - "#hiddenCopyElement", - 100, - async page => { - await page.waitForFunction( - () => !!window.PDFViewerApplication.eventBus - ); - await waitForTextLayer(page); - } - ); + pages = await loadAndWait("tracemonkey.pdf", "#hiddenCopyElement", 100); await mockClipboard(pages); }); @@ -61,6 +50,9 @@ describe("Copy and paste", () => { it("must check that we've all the contents on copy/paste", async () => { await Promise.all( pages.map(async ([browserName, page]) => { + await page.waitForSelector( + ".page[data-page-number='1'] .textLayer .endOfContent" + ); await selectAll(page); const promise = waitForEvent(page, "copy"); @@ -150,13 +142,7 @@ describe("Copy and paste", () => { pages = await loadAndWait( "copy_paste_ligatures.pdf", "#hiddenCopyElement", - 100, - async page => { - await page.waitForFunction( - () => !!window.PDFViewerApplication.eventBus - ); - await waitForTextLayer(page); - } + 100 ); await mockClipboard(pages); }); @@ -168,6 +154,9 @@ describe("Copy and paste", () => { it("must check that the ligatures have been removed when the text has been copied", async () => { await Promise.all( pages.map(async ([browserName, page]) => { + await page.waitForSelector( + ".page[data-page-number='1'] .textLayer .endOfContent" + ); await selectAll(page); const promise = waitForEvent(page, "copy"); diff --git a/test/integration/test_utils.mjs b/test/integration/test_utils.mjs index 67b82acf7..fdb97d479 100644 --- a/test/integration/test_utils.mjs +++ b/test/integration/test_utils.mjs @@ -307,13 +307,6 @@ function waitForAnnotationEditorLayer(page) { }); } -async function waitForTextLayer(page) { - const handle = await createPromise(page, resolve => { - window.PDFViewerApplication.eventBus.on("textlayerrendered", resolve); - }); - return awaitPromise(handle); -} - async function scrollIntoView(page, selector) { const handle = await page.evaluateHandle( sel => [ @@ -541,7 +534,6 @@ export { waitForSelectedEditor, waitForSerialized, waitForStorageEntries, - waitForTextLayer, waitForTimeout, waitForUnselectedEditor, };