From 15c930dd97cbfa6a32102a4d909f737fa95b88e1 Mon Sep 17 00:00:00 2001 From: Calixte Denizet Date: Sun, 6 Oct 2024 16:28:12 +0200 Subject: [PATCH] Fix failing integration test on Windws with Chrome It fixes #18775. --- test/integration/highlight_editor_spec.mjs | 30 ++++++++++++++++------ test/integration/text_layer_spec.mjs | 12 ++++++--- 2 files changed, 31 insertions(+), 11 deletions(-) diff --git a/test/integration/highlight_editor_spec.mjs b/test/integration/highlight_editor_spec.mjs index 931ff440a4439d..3f36d13e7b5a47 100644 --- a/test/integration/highlight_editor_spec.mjs +++ b/test/integration/highlight_editor_spec.mjs @@ -1785,6 +1785,10 @@ describe("Highlight Editor", () => { await page.keyboard.press("Escape"); await page.waitForSelector(`${editorSelector}:not(.selectedEditor)`); + const clickHandle = await waitForPointerUp(page); + y = rect.y - rect.height; + await page.mouse.move(x, y); + const counterHandle = await page.evaluateHandle(sel => { const el = document.querySelector(sel); const counter = { count: 0 }; @@ -1798,10 +1802,10 @@ describe("Highlight Editor", () => { return counter; }, editorSelector); - const clickHandle = await waitForPointerUp(page); - y = rect.y - rect.height; - await page.mouse.move(x, y); await page.mouse.down(); + await page.waitForSelector( + `.page[data-page-number = "1"] .annotationEditorLayer.drawing` + ); for ( const endY = rect.y + 2 * rect.height; y <= endY; @@ -1811,6 +1815,9 @@ describe("Highlight Editor", () => { } await page.mouse.up(); await awaitPromise(clickHandle); + await page.waitForSelector( + `.page[data-page-number = "1"] .annotationEditorLayer:not(.drawing)` + ); const { count } = await counterHandle.jsonValue(); expect(count).withContext(`In ${browserName}`).toEqual(0); @@ -1841,7 +1848,7 @@ describe("Highlight Editor", () => { "ternative compilation technique for dynamically-typed languages" ); const editorSelector = getEditorSelector(0); - const x = rect.x + rect.width / 2; + const x = Math.round(rect.x + rect.width / 2); let y = rect.y + rect.height / 2; await page.mouse.click(x, y, { count: 3, delay: 100 }); await page.waitForSelector(editorSelector); @@ -1849,6 +1856,10 @@ describe("Highlight Editor", () => { await page.keyboard.press("Escape"); await page.waitForSelector(`${editorSelector}:not(.selectedEditor)`); + const clickHandle = await waitForPointerUp(page); + y = rect.y - 3 * rect.height; + await page.mouse.move(x, Math.round(y)); + const counterHandle = await page.evaluateHandle(sel => { const el = document.querySelector(sel); const counter = { count: 0 }; @@ -1862,19 +1873,22 @@ describe("Highlight Editor", () => { return counter; }, editorSelector); - const clickHandle = await waitForPointerUp(page); - y = rect.y - 3 * rect.height; - await page.mouse.move(x, y); await page.mouse.down(); + await page.waitForSelector( + `.page[data-page-number = "1"] .textLayer.selecting` + ); for ( const endY = rect.y + 3 * rect.height; y <= endY; y += rect.height / 10 ) { - await page.mouse.move(x, y); + await page.mouse.move(x, Math.round(y)); } await page.mouse.up(); await awaitPromise(clickHandle); + await page.waitForSelector( + `.page[data-page-number = "1"] .textLayer:not(.selecting)` + ); const { count } = await counterHandle.jsonValue(); expect(count).withContext(`In ${browserName}`).toEqual(0); diff --git a/test/integration/text_layer_spec.mjs b/test/integration/text_layer_spec.mjs index 3eae3efb849ece..9af614d361129d 100644 --- a/test/integration/text_layer_spec.mjs +++ b/test/integration/text_layer_spec.mjs @@ -39,15 +39,21 @@ describe("Text layer", () => { } function middlePosition(rect) { - return { x: rect.x + rect.width / 2, y: rect.y + rect.height / 2 }; + return { + x: rect.x + Math.floor(rect.width / 2), + y: rect.y + Math.floor(rect.height / 2), + }; } function middleLeftPosition(rect) { - return { x: rect.x + 1, y: rect.y + rect.height / 2 }; + return { x: rect.x + 1, y: rect.y + Math.floor(rect.height / 2) }; } function belowEndPosition(rect) { - return { x: rect.x + rect.width, y: rect.y + rect.height * 1.5 }; + return { + x: rect.x + rect.width, + y: rect.y + Math.floor(rect.height * 1.5), + }; } beforeAll(() => {