Skip to content

Commit c156a34

Browse files
committed
test: e2e: siimplify
1 parent a57eadb commit c156a34

2 files changed

Lines changed: 14 additions & 36 deletions

File tree

‎test-e2e/client/keys/insert.js‎

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
import {test, expect} from '@playwright/test';
22

33
const getRows = (page) => page.locator('.files li');
4+
const goto = (page) => page.goto('/', {waitUntil: 'networkidle'});
45
const waitForPanel = (page) => page
56
.locator('.files li')
67
.first()
78
.waitFor();
89

910
test('Insert selects the current file', async ({page}) => {
10-
await page.goto('/', {
11-
waitUntil: 'networkidle',
12-
});
11+
await goto(page);
1312
await waitForPanel(page);
1413

1514
const rows = getRows(page);
@@ -24,9 +23,7 @@ test('Insert selects the current file', async ({page}) => {
2423
});
2524

2625
test('Insert moves the cursor to the next file', async ({page}) => {
27-
await page.goto('/', {
28-
waitUntil: 'networkidle',
29-
});
26+
await goto(page);
3027
await waitForPanel(page);
3128

3229
const rows = getRows(page);
@@ -42,9 +39,7 @@ test('Insert moves the cursor to the next file', async ({page}) => {
4239
});
4340

4441
test('Insert does not leave the cursor on the first file', async ({page}) => {
45-
await page.goto('/', {
46-
waitUntil: 'networkidle',
47-
});
42+
await goto(page);
4843
await waitForPanel(page);
4944

5045
const rows = getRows(page);
@@ -59,9 +54,7 @@ test('Insert does not leave the cursor on the first file', async ({page}) => {
5954
});
6055

6156
test('pressing Insert twice selects two consecutive files: first selected', async ({page}) => {
62-
await page.goto('/', {
63-
waitUntil: 'networkidle',
64-
});
57+
await goto(page);
6558
await waitForPanel(page);
6659

6760
const rows = getRows(page);
@@ -79,9 +72,7 @@ test('pressing Insert twice selects two consecutive files: first selected', asyn
7972
});
8073

8174
test('pressing Insert twice selects two consecutive files: second selected', async ({page}) => {
82-
await page.goto('/', {
83-
waitUntil: 'networkidle',
84-
});
75+
await goto(page);
8576
await waitForPanel(page);
8677

8778
const rows = getRows(page);
@@ -99,9 +90,7 @@ test('pressing Insert twice selects two consecutive files: second selected', asy
9990
});
10091

10192
test('pressing Insert twice leaves cursor on the third file', async ({page}) => {
102-
await page.goto('/', {
103-
waitUntil: 'networkidle',
104-
});
93+
await goto(page);
10594
await waitForPanel(page);
10695

10796
const rows = getRows(page);

‎test-e2e/client/view.js‎

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,14 @@ const getFile = (page, name) => page
55
.locator(`[data-name="js-file-${btoa(name)}"]`)
66
.first();
77

8+
const goto = (page) => page.goto('/', {waitUntil: 'networkidle'});
89
const waitForPanel = (page) => page
910
.locator('.files li')
1011
.first()
1112
.waitFor();
1213

1314
test('F3 on a .png file opens the image viewer', async ({page}) => {
14-
await page.goto('/', {
15-
waitUntil: 'networkidle',
16-
});
15+
await goto(page);
1716
await waitForPanel(page);
1817
await getFile(page, 'view.png').click();
1918
await page.keyboard.press('F3');
@@ -23,9 +22,7 @@ test('F3 on a .png file opens the image viewer', async ({page}) => {
2322
});
2423

2524
test('F3 on a .png file does not open the text viewer', async ({page}) => {
26-
await page.goto('/', {
27-
waitUntil: 'networkidle',
28-
});
25+
await goto(page);
2926
await waitForPanel(page);
3027
await getFile(page, 'view.png').click();
3128
await page.keyboard.press('F3');
@@ -37,9 +34,7 @@ test('F3 on a .png file does not open the text viewer', async ({page}) => {
3734
});
3835

3936
test('double-click on a .png file opens the image viewer', async ({page}) => {
40-
await page.goto('/', {
41-
waitUntil: 'networkidle',
42-
});
37+
await goto(page);
4338
await waitForPanel(page);
4439
await getFile(page, 'view.png').dblclick();
4540

@@ -48,9 +43,7 @@ test('double-click on a .png file opens the image viewer', async ({page}) => {
4843
});
4944

5045
test('double-click on a .png file does not open the text viewer', async ({page}) => {
51-
await page.goto('/', {
52-
waitUntil: 'networkidle',
53-
});
46+
await goto(page);
5447
await waitForPanel(page);
5548
await getFile(page, 'view.png').dblclick();
5649

@@ -61,9 +54,7 @@ test('double-click on a .png file does not open the text viewer', async ({page})
6154
});
6255

6356
test('F3 on a .txt file opens the text viewer', async ({page}) => {
64-
await page.goto('/', {
65-
waitUntil: 'networkidle',
66-
});
57+
await goto(page);
6758
await waitForPanel(page);
6859
await getFile(page, 'copy.txt').click();
6960
await page.keyboard.press('F3');
@@ -73,9 +64,7 @@ test('F3 on a .txt file opens the text viewer', async ({page}) => {
7364
});
7465

7566
test('F3 on a .txt file shows file content', async ({page}) => {
76-
await page.goto('/', {
77-
waitUntil: 'networkidle',
78-
});
67+
await goto(page);
7968
await waitForPanel(page);
8069
await getFile(page, 'copy.txt').click();
8170
await page.keyboard.press('F3');

0 commit comments

Comments
 (0)