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

Code before:
          editorIds = await getEditors(page, "freeText");
          expect(editorIds.length).withContext(`In ${browserName}`).toEqual(0);
          const hidden = await page.$eval(
            "[data-annotation-id='51R']",
            el => el.hidden
          );
          expect(hidden).withContext(`In ${browserName}`).toBeTrue();

          // Re-enable editing mode.
          await switchToFreeText(page);
          await page.focus(".annotationEditorLayer");

          await kbUndo(page);
          await waitForSerialized(page, 0);
        })
      );
    });

    it("must delete an existing annotation with a popup", async () => {
      await Promise.all(
        pages.map(async ([browserName, page]) => {
          await page.click("[data-annotation-id='26R']");
          // Wait for the popup to be displayed.
          await page.waitForSelector(
            "[data-annotation-id='popup_26R'] .popup",
            {
              visible: true,
            }
          );

          await switchToFreeText(page);

          const editorSelector = getEditorSelector(0);
          await selectEditor(page, editorSelector);
          await page.keyboard.press("Backspace");
          await page.waitForFunction(
            sel => !document.querySelector(sel),
            {},
            editorSelector
          );

          const serialized = await getSerialized(page);
          expect(serialized).toEqual([
            {
              pageIndex: 0,
              id: "26R",
              deleted: true,
              popupRef: "",
            },
          ]);


Review comment (suggestion):
Here and for the other occurrences in this new test let's make this a bit more compact by putting the options on a single line:

```
{ visible: true }
```

Code after:
          editorIds = await getEditors(page, "freeText");
          expect(editorIds.length).withContext(`In ${browserName}`).toEqual(0);
          const hidden = await page.$eval(
            "[data-annotation-id='51R']",
            el => el.hidden
          );
          expect(hidden).withContext(`In ${browserName}`).toBeTrue();

          // Re-enable editing mode.
          await switchToFreeText(page);
          await page.focus(".annotationEditorLayer");

          await kbUndo(page);
          await waitForSerialized(page, 0);
        })
      );
    });

    it("must delete an existing annotation with a popup", async () => {
      await Promise.all(
        pages.map(async ([browserName, page]) => {
          await page.click("[data-annotation-id='26R']");
          // Wait for the popup to be displayed.
          const popupSelector = "[data-annotation-id='popup_26R'] .popup";
          await page.waitForSelector(popupSelector, { visible: true });

          await switchToFreeText(page);

          const editorSelector = getEditorSelector(0);
          await selectEditor(page, editorSelector);
          await page.keyboard.press("Backspace");
          await page.waitForFunction(
            sel => !document.querySelector(sel),
            {},
            editorSelector
          );

          await waitForSerialized(page, 1);
          const serialized = await getSerialized(page);
          expect(serialized).toEqual([
            {
              pageIndex: 0,
              id: "26R",
              deleted: true,
              popupRef: "",
            },
          ]);

          // Disable editing mode.
          await switchToFreeText(page, /* disable = */ true);