Skip to content

Commit 393e799

Browse files
committed
Fix missing await for asynchronous method calls in the integration tests
The `Page.evaluate()` and `Mouse.click()` APIs in Puppeteer both return a promise; see https://pptr.dev/api/puppeteer.page.evaluate and https://pptr.dev/api/puppeteer.mouse.click, and should therefore be awaited before proceeding in tests to make sure that the test's behavior is deterministic and avoid intermittent failures. The following command was used to find potential places to fix: `grep -nEr "[^await|return] page\." test/integration/*`
1 parent 819671d commit 393e799

3 files changed

Lines changed: 7 additions & 7 deletions

File tree

test/integration/freetext_editor_spec.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,7 @@ describe("FreeText Editor", () => {
669669
}
670670
);
671671

672-
page.evaluate(() => {
672+
await page.evaluate(() => {
673673
window.PDFViewerApplication.eventBus.dispatch(
674674
"switchannotationeditorparams",
675675
{
@@ -1290,7 +1290,7 @@ describe("FreeText Editor", () => {
12901290
".selectedEditor .internal"
12911291
);
12921292

1293-
page.evaluate(() => {
1293+
await page.evaluate(() => {
12941294
window.PDFViewerApplication.eventBus.dispatch(
12951295
"switchannotationeditorparams",
12961296
{

test/integration/highlight_editor_spec.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -626,7 +626,7 @@ describe("Highlight Editor", () => {
626626
const { width: prevWidth } = await getRect(page, editorSelector);
627627

628628
value = 24;
629-
page.evaluate(val => {
629+
await page.evaluate(val => {
630630
window.PDFViewerApplication.eventBus.dispatch(
631631
"switchannotationeditorparams",
632632
{
@@ -763,7 +763,7 @@ describe("Highlight Editor", () => {
763763

764764
const { width: prevWidth } = await getRect(page, editorSelector);
765765

766-
page.evaluate(val => {
766+
await page.evaluate(val => {
767767
window.PDFViewerApplication.eventBus.dispatch(
768768
"switchannotationeditorparams",
769769
{

test/integration/ink_editor_spec.mjs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ describe("Ink Editor", () => {
302302
await page.mouse.up();
303303
await awaitPromise(clickHandle);
304304

305-
page.mouse.click(rect.x - 10, rect.y + 10);
305+
await page.mouse.click(rect.x - 10, rect.y + 10);
306306
await page.waitForSelector(`${getEditorSelector(0)}.disabled`);
307307
})
308308
);
@@ -583,7 +583,7 @@ describe("Ink Editor", () => {
583583
}
584584

585585
const red = "#ff0000";
586-
page.evaluate(value => {
586+
await page.evaluate(value => {
587587
window.PDFViewerApplication.eventBus.dispatch(
588588
"switchannotationeditorparams",
589589
{
@@ -763,7 +763,7 @@ describe("Ink Editor", () => {
763763
await selectEditor(page, pdfjsA);
764764

765765
const red = "#ff0000";
766-
page.evaluate(value => {
766+
await page.evaluate(value => {
767767
window.PDFViewerApplication.eventBus.dispatch(
768768
"switchannotationeditorparams",
769769
{

0 commit comments

Comments
 (0)