From 32dc2a5894fbb1cc28a3587dccfe2c591d8683d8 Mon Sep 17 00:00:00 2001 From: Calixte Denizet Date: Tue, 17 Mar 2026 15:30:57 +0100 Subject: [PATCH] Wait to have all the spans in the text layer before trying to set the caret in integration tests --- test/integration/test_utils.mjs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/integration/test_utils.mjs b/test/integration/test_utils.mjs index cf382f098..6bbb3e756 100644 --- a/test/integration/test_utils.mjs +++ b/test/integration/test_utils.mjs @@ -680,6 +680,10 @@ async function firstPageOnTop(page) { } async function setCaretAt(page, pageNumber, text, position) { + // Wait for the text layer to finish rendering before trying to find the span. + await page.waitForSelector( + `.page[data-page-number="${pageNumber}"] .textLayer .endOfContent` + ); await page.evaluate( (pageN, string, pos) => { for (const el of document.querySelectorAll(