Skip to content

Commit 15c930d

Browse files
committed
Fix failing integration test on Windws with Chrome
It fixes #18775.
1 parent 81cf42d commit 15c930d

File tree

2 files changed

+31
-11
lines changed

2 files changed

+31
-11
lines changed

test/integration/highlight_editor_spec.mjs

+22-8
Original file line numberDiff line numberDiff line change
@@ -1785,6 +1785,10 @@ describe("Highlight Editor", () => {
17851785
await page.keyboard.press("Escape");
17861786
await page.waitForSelector(`${editorSelector}:not(.selectedEditor)`);
17871787

1788+
const clickHandle = await waitForPointerUp(page);
1789+
y = rect.y - rect.height;
1790+
await page.mouse.move(x, y);
1791+
17881792
const counterHandle = await page.evaluateHandle(sel => {
17891793
const el = document.querySelector(sel);
17901794
const counter = { count: 0 };
@@ -1798,10 +1802,10 @@ describe("Highlight Editor", () => {
17981802
return counter;
17991803
}, editorSelector);
18001804

1801-
const clickHandle = await waitForPointerUp(page);
1802-
y = rect.y - rect.height;
1803-
await page.mouse.move(x, y);
18041805
await page.mouse.down();
1806+
await page.waitForSelector(
1807+
`.page[data-page-number = "1"] .annotationEditorLayer.drawing`
1808+
);
18051809
for (
18061810
const endY = rect.y + 2 * rect.height;
18071811
y <= endY;
@@ -1811,6 +1815,9 @@ describe("Highlight Editor", () => {
18111815
}
18121816
await page.mouse.up();
18131817
await awaitPromise(clickHandle);
1818+
await page.waitForSelector(
1819+
`.page[data-page-number = "1"] .annotationEditorLayer:not(.drawing)`
1820+
);
18141821

18151822
const { count } = await counterHandle.jsonValue();
18161823
expect(count).withContext(`In ${browserName}`).toEqual(0);
@@ -1841,14 +1848,18 @@ describe("Highlight Editor", () => {
18411848
"ternative compilation technique for dynamically-typed languages"
18421849
);
18431850
const editorSelector = getEditorSelector(0);
1844-
const x = rect.x + rect.width / 2;
1851+
const x = Math.round(rect.x + rect.width / 2);
18451852
let y = rect.y + rect.height / 2;
18461853
await page.mouse.click(x, y, { count: 3, delay: 100 });
18471854
await page.waitForSelector(editorSelector);
18481855
await waitForSerialized(page, 1);
18491856
await page.keyboard.press("Escape");
18501857
await page.waitForSelector(`${editorSelector}:not(.selectedEditor)`);
18511858

1859+
const clickHandle = await waitForPointerUp(page);
1860+
y = rect.y - 3 * rect.height;
1861+
await page.mouse.move(x, Math.round(y));
1862+
18521863
const counterHandle = await page.evaluateHandle(sel => {
18531864
const el = document.querySelector(sel);
18541865
const counter = { count: 0 };
@@ -1862,19 +1873,22 @@ describe("Highlight Editor", () => {
18621873
return counter;
18631874
}, editorSelector);
18641875

1865-
const clickHandle = await waitForPointerUp(page);
1866-
y = rect.y - 3 * rect.height;
1867-
await page.mouse.move(x, y);
18681876
await page.mouse.down();
1877+
await page.waitForSelector(
1878+
`.page[data-page-number = "1"] .textLayer.selecting`
1879+
);
18691880
for (
18701881
const endY = rect.y + 3 * rect.height;
18711882
y <= endY;
18721883
y += rect.height / 10
18731884
) {
1874-
await page.mouse.move(x, y);
1885+
await page.mouse.move(x, Math.round(y));
18751886
}
18761887
await page.mouse.up();
18771888
await awaitPromise(clickHandle);
1889+
await page.waitForSelector(
1890+
`.page[data-page-number = "1"] .textLayer:not(.selecting)`
1891+
);
18781892

18791893
const { count } = await counterHandle.jsonValue();
18801894
expect(count).withContext(`In ${browserName}`).toEqual(0);

test/integration/text_layer_spec.mjs

+9-3
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,21 @@ describe("Text layer", () => {
3939
}
4040

4141
function middlePosition(rect) {
42-
return { x: rect.x + rect.width / 2, y: rect.y + rect.height / 2 };
42+
return {
43+
x: rect.x + Math.floor(rect.width / 2),
44+
y: rect.y + Math.floor(rect.height / 2),
45+
};
4346
}
4447

4548
function middleLeftPosition(rect) {
46-
return { x: rect.x + 1, y: rect.y + rect.height / 2 };
49+
return { x: rect.x + 1, y: rect.y + Math.floor(rect.height / 2) };
4750
}
4851

4952
function belowEndPosition(rect) {
50-
return { x: rect.x + rect.width, y: rect.y + rect.height * 1.5 };
53+
return {
54+
x: rect.x + rect.width,
55+
y: rect.y + Math.floor(rect.height * 1.5),
56+
};
5157
}
5258

5359
beforeAll(() => {

0 commit comments

Comments
 (0)