Skip to content

Commit c989de8

Browse files
committed
test: extract duplicated indentation test setup into shared helper
1 parent 4c5baba commit c989de8

1 file changed

Lines changed: 19 additions & 40 deletions

File tree

tests/src/end-to-end/indentation/indentation.test.tsx

Lines changed: 19 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,24 @@ beforeEach(async () => {
2323
await waitForSelector(EDITOR_SELECTOR);
2424
});
2525

26+
// Inserts a paragraph followed by three nested headings (H1, H2, H3), which is
27+
// the shared starting document for all indentation tests below.
28+
async function setupIndentationTestContent() {
29+
await focusOnEditor();
30+
31+
await insertParagraph();
32+
await userEvent.keyboard("{Enter}");
33+
await userEvent.keyboard("{Tab}");
34+
await insertHeading(1);
35+
await userEvent.keyboard("{Enter}");
36+
await insertHeading(2);
37+
await userEvent.keyboard("{Enter}");
38+
await insertHeading(3);
39+
}
40+
2641
describe("Check Block Indentation Functionality", () => {
2742
test("Should be able to increase indentation for single block", async () => {
28-
await focusOnEditor();
29-
30-
await insertParagraph();
31-
await userEvent.keyboard("{Enter}");
32-
await userEvent.keyboard("{Tab}");
33-
await insertHeading(1);
34-
await userEvent.keyboard("{Enter}");
35-
await insertHeading(2);
36-
await userEvent.keyboard("{Enter}");
37-
await insertHeading(3);
43+
await setupIndentationTestContent();
3844

3945
const { x, y, height } = getRect(H_TWO_BLOCK_SELECTOR);
4046

@@ -51,16 +57,7 @@ describe("Check Block Indentation Functionality", () => {
5157
await compareDocToSnapshot("increaseIndentSingleBlock");
5258
});
5359
test("Should be able to decrease indentation for single block", async () => {
54-
await focusOnEditor();
55-
56-
await insertParagraph();
57-
await userEvent.keyboard("{Enter}");
58-
await userEvent.keyboard("{Tab}");
59-
await insertHeading(1);
60-
await userEvent.keyboard("{Enter}");
61-
await insertHeading(2);
62-
await userEvent.keyboard("{Enter}");
63-
await insertHeading(3);
60+
await setupIndentationTestContent();
6461

6562
const { x, y, height } = getRect(H_TWO_BLOCK_SELECTOR);
6663

@@ -77,16 +74,7 @@ describe("Check Block Indentation Functionality", () => {
7774
await compareDocToSnapshot("decreaseIndentSingleBlock");
7875
});
7976
test("Should be able to increase indentation for multiple blocks", async () => {
80-
await focusOnEditor();
81-
82-
await insertParagraph();
83-
await userEvent.keyboard("{Enter}");
84-
await userEvent.keyboard("{Tab}");
85-
await insertHeading(1);
86-
await userEvent.keyboard("{Enter}");
87-
await insertHeading(2);
88-
await userEvent.keyboard("{Enter}");
89-
await insertHeading(3);
77+
await setupIndentationTestContent();
9078

9179
const firstElementBoundingBox = getRect(H_TWO_BLOCK_SELECTOR);
9280
await clickAt(
@@ -116,16 +104,7 @@ describe("Check Block Indentation Functionality", () => {
116104
await compareDocToSnapshot("increaseIndentMultipleBlocks");
117105
});
118106
test("Should be able to decrease indentation for multiple blocks", async () => {
119-
await focusOnEditor();
120-
121-
await insertParagraph();
122-
await userEvent.keyboard("{Enter}");
123-
await userEvent.keyboard("{Tab}");
124-
await insertHeading(1);
125-
await userEvent.keyboard("{Enter}");
126-
await insertHeading(2);
127-
await userEvent.keyboard("{Enter}");
128-
await insertHeading(3);
107+
await setupIndentationTestContent();
129108

130109
const firstElementBoundingBox = getRect(H_TWO_BLOCK_SELECTOR);
131110
await clickAt(

0 commit comments

Comments
 (0)