Repository: mozilla/pdf.js
File: test/integration/highlight_editor_spec.mjs (JavaScript)

Code before:
          await highlightSpan(page, 1, "Abstract");
          await waitForSerialized(page, 1);

          await page.waitForSelector(`${editorSelector} button.deleteButton`);
          await page.click(`${editorSelector} button.deleteButton`);
          await waitForSerialized(page, 0);
          await page.waitForSelector("#editorUndoBar", { visible: true });

          await page.waitForSelector("#editorUndoBarUndoButton", {
            visible: true,
          });
          await page.click("#editorUndoBarUndoButton");
          await page.waitForSelector("#editorUndoBar", { hidden: true });
        })
      );
    });

    it("must check that the popup disappears when the close button is clicked", async () => {
      await Promise.all(
        pages.map(async ([browserName, page]) => {
          await switchToHighlight(page);

          await highlightSpan(page, 1, "Abstract");
          await waitForSerialized(page, 1);

          await page.waitForSelector(editorSelector);
          await waitForSerialized(page, 1);

          await page.waitForSelector(`${editorSelector} button.deleteButton`);
          await page.click(`${editorSelector} button.deleteButton`);
          await waitForSerialized(page, 0);
          await page.waitForSelector("#editorUndoBar", { visible: true });

          await page.waitForSelector("#editorUndoBarCloseButton", {
            visible: true,
          });
          await page.click("#editorUndoBarCloseButton");
          await page.waitForSelector("#editorUndoBar", { hidden: true });
        })
      );
    });

    it("must check that the popup disappears when a new annotation is created", async () => {
      await Promise.all(
        pages.map(async ([browserName, page]) => {
          await switchToHighlight(page);

          await highlightSpan(page, 1, "Abstract");
          await waitForSerialized(page, 1);

          await page.waitForSelector(`${editorSelector} button.deleteButton`);

Review comment (suggestion):
This line shoudn't be necessary anymore now that `highlightSpan` already waits for the editor internally, and the next line shouldn't be necessary anymore because you already added it above, so both can be removed. It also makes the test more equal to the one above.

Code after:
          await highlightSpan(page, 1, "Abstract");
          await waitForSerialized(page, 1);

          await page.waitForSelector(`${editorSelector} button.deleteButton`);
          await page.click(`${editorSelector} button.deleteButton`);
          await waitForSerialized(page, 0);
          await page.waitForSelector("#editorUndoBar", { visible: true });

          await page.waitForSelector("#editorUndoBarUndoButton", {
            visible: true,
          });
          await page.click("#editorUndoBarUndoButton");
          await page.waitForSelector("#editorUndoBar", { hidden: true });
        })
      );
    });

    it("must check that the popup disappears when the close button is clicked", async () => {
      await Promise.all(
        pages.map(async ([browserName, page]) => {
          await switchToHighlight(page);

          await highlightSpan(page, 1, "Abstract");
          await waitForSerialized(page, 1);

          await page.waitForSelector(`${editorSelector} button.deleteButton`);
          await page.click(`${editorSelector} button.deleteButton`);
          await waitForSerialized(page, 0);
          await page.waitForSelector("#editorUndoBar", { visible: true });

          await page.waitForSelector("#editorUndoBarCloseButton", {
            visible: true,
          });
          await page.click("#editorUndoBarCloseButton");
          await page.waitForSelector("#editorUndoBar", { hidden: true });
        })
      );
    });

    it("must check that the popup disappears when a new annotation is created", async () => {
      await Promise.all(
        pages.map(async ([browserName, page]) => {
          await switchToHighlight(page);

          await highlightSpan(page, 1, "Abstract");
          await waitForSerialized(page, 1);

          await page.waitForSelector(`${editorSelector} button.deleteButton`);
          await page.click(`${editorSelector} button.deleteButton`);
          await page.waitForSelector("#editorUndoBar", { visible: true });