Skip to content

Commit 2ac4239

Browse files
committed
Wait a little between each key press in the test 'must check that the comment sidebar is resizable with the keyboard'
1 parent 1192e5e commit 2ac4239

3 files changed

Lines changed: 16 additions & 11 deletions

File tree

test/integration/comment_spec.mjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import {
3232
selectEditor,
3333
switchToEditor,
3434
waitAndClick,
35+
waitForBrowserTrip,
3536
waitForSerialized,
3637
waitForTimeout,
3738
} from "./test_utils.mjs";
@@ -570,6 +571,7 @@ describe("Comment", () => {
570571
const rect = await getRect(page, sidebarSelector);
571572
const arrowKey = extraWidth > 0 ? "ArrowLeft" : "ArrowRight";
572573
for (let i = 0; i < Math.abs(extraWidth); i++) {
574+
await waitForBrowserTrip(page);
573575
await kbModifierDown(page);
574576
await page.keyboard.press(arrowKey);
575577
await kbModifierUp(page);

test/integration/stamp_editor_spec.mjs

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ import {
4343
unselectEditor,
4444
waitForAnnotationEditorLayer,
4545
waitForAnnotationModeChanged,
46+
waitForBrowserTrip,
4647
waitForEntryInStorage,
4748
waitForPageRendered,
4849
waitForSelectedEditor,
@@ -84,14 +85,6 @@ const copyImage = async (page, imagePath, selector) => {
8485
await waitForImage(page, selector);
8586
};
8687

87-
async function waitForTranslation(page) {
88-
return page.evaluate(async () => {
89-
await new Promise(resolve => {
90-
window.requestAnimationFrame(resolve);
91-
});
92-
});
93-
}
94-
9588
const switchToStamp = switchToEditor.bind(null, "Stamp");
9689

9790
describe("Stamp Editor", () => {
@@ -1007,7 +1000,7 @@ describe("Stamp Editor", () => {
10071000
const buttonSelector = `${editorSelector} button.altText.new`;
10081001
await page.waitForSelector(buttonSelector, { visible: true });
10091002

1010-
await waitForTranslation(page);
1003+
await waitForBrowserTrip(page);
10111004
// Check the text in the button.
10121005
let text = await page.evaluate(
10131006
sel => document.querySelector(sel).textContent,
@@ -1056,7 +1049,7 @@ describe("Stamp Editor", () => {
10561049
await waitForSelectedEditor(page, editorSelector);
10571050
await page.waitForSelector(buttonSelector, { visible: true });
10581051

1059-
await waitForTranslation(page);
1052+
await waitForBrowserTrip(page);
10601053
// Check the text in the button.
10611054
text = await page.evaluate(
10621055
sel => document.querySelector(sel).textContent,
@@ -1098,7 +1091,7 @@ describe("Stamp Editor", () => {
10981091
await page.click("#newAltTextSave");
10991092
await page.waitForSelector("#newAltTextDialog", { visible: false });
11001093

1101-
await waitForTranslation(page);
1094+
await waitForBrowserTrip(page);
11021095
// Check the text in the button.
11031096
text = await page.evaluate(
11041097
sel => document.querySelector(sel).firstChild.textContent,

test/integration/test_utils.mjs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1006,6 +1006,15 @@ async function showViewsManager(page) {
10061006
});
10071007
}
10081008

1009+
async function waitForBrowserTrip(page) {
1010+
const handle = await page.evaluateHandle(() => [
1011+
new Promise(resolve => {
1012+
window.requestAnimationFrame(resolve);
1013+
}),
1014+
]);
1015+
await awaitPromise(handle);
1016+
}
1017+
10091018
// Unicode bidi isolation characters, Fluent adds these markers to the text.
10101019
const FSI = "\u2068";
10111020
const PDI = "\u2069";
@@ -1078,6 +1087,7 @@ export {
10781087
waitAndClick,
10791088
waitForAnnotationEditorLayer,
10801089
waitForAnnotationModeChanged,
1090+
waitForBrowserTrip,
10811091
waitForDOMMutation,
10821092
waitForEntryInStorage,
10831093
waitForEvent,

0 commit comments

Comments
 (0)