Skip to content

Commit d01913e

Browse files
committed
Isolate the "create editor with keyboard" freetext editor integration tests
This commit reduces the number of freetext editor integration test suite failures, in full isolation, from 6 to 5 by fixing the following issues in the "create editor with keyboard" block: - The second test relied on the first test to enable freetext editing mode and put focus on the page (annotation layer). For isolation we now do that explicitly in the second test. - The second test relied on the first test for the editor numbering. For isolation we change the editor numbering to the one after initial document load. Moreover, the test names have been updated to clarify with scenario is being tested, which came up during comparison of the changes against commit ea5eafa to make sure that we are still testing the originally intended scenarios (confirmed by disabling the relevant code from the commit per scenario and noticing the corresponding test failing).
1 parent 94b2c86 commit d01913e

1 file changed

Lines changed: 9 additions & 7 deletions

File tree

test/integration/freetext_editor_spec.mjs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2340,20 +2340,19 @@ describe("FreeText Editor", () => {
23402340
describe("Create editor with keyboard", () => {
23412341
let pages;
23422342

2343-
beforeAll(async () => {
2343+
beforeEach(async () => {
23442344
pages = await loadAndWait("empty.pdf", ".annotationEditorLayer");
23452345
});
23462346

2347-
afterAll(async () => {
2347+
afterEach(async () => {
23482348
await closePages(pages);
23492349
});
23502350

2351-
it("must create an editor from the toolbar", async () => {
2351+
it("must create an editor, using Enter/Space keys, with focused toolbar button", async () => {
23522352
await Promise.all(
23532353
pages.map(async ([browserName, page]) => {
23542354
await page.focus("#editorFreeTextButton");
23552355
await page.keyboard.press("Enter");
2356-
23572356
let editorSelector = getEditorSelector(0);
23582357
await page.waitForSelector(editorSelector, { visible: true });
23592358

@@ -2394,11 +2393,14 @@ describe("FreeText Editor", () => {
23942393
);
23952394
});
23962395

2397-
it("must create an editor with keyboard", async () => {
2396+
it("must create an editor, using Enter/Space keys, with focused page", async () => {
23982397
await Promise.all(
23992398
pages.map(async ([browserName, page]) => {
2399+
await switchToFreeText(page);
2400+
2401+
await page.focus(".annotationEditorLayer");
24002402
await page.keyboard.press("Enter");
2401-
let editorSelector = getEditorSelector(2);
2403+
let editorSelector = getEditorSelector(0);
24022404
await page.waitForSelector(editorSelector, { visible: true });
24032405

24042406
await moveEditor(page, editorSelector, 10, () => kbBigMoveLeft(page));
@@ -2417,7 +2419,7 @@ describe("FreeText Editor", () => {
24172419
expect(content).withContext(`In ${browserName}`).toEqual(data);
24182420

24192421
await page.keyboard.press(" ");
2420-
editorSelector = getEditorSelector(3);
2422+
editorSelector = getEditorSelector(1);
24212423
await page.waitForSelector(editorSelector, { visible: true });
24222424

24232425
await moveEditor(page, editorSelector, 10, () =>

0 commit comments

Comments
 (0)