-
Notifications
You must be signed in to change notification settings - Fork 5.2k
/
Copy pathfilebrowser.spec.ts
84 lines (62 loc) · 2.46 KB
/
filebrowser.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
// Copyright (c) Jupyter Development Team.
// Distributed under the terms of the Modified BSD License.
import path from 'path';
import { expect } from '@playwright/test';
import { test } from './fixtures';
test.describe('File Browser', () => {
test.beforeEach(async ({ page, tmpPath }) => {
await page.contents.uploadFile(
path.resolve(__dirname, './notebooks/empty.ipynb'),
`${tmpPath}/empty.ipynb`
);
await page.contents.createDirectory(`${tmpPath}/folder1`);
await page.contents.createDirectory(`${tmpPath}/folder2`);
});
test('Select one folder', async ({ page, tmpPath }) => {
await page.filebrowser.refresh();
await page.getByText('folder1').last().click();
const toolbar = page.getByRole('toolbar');
expect(toolbar.getByText('Rename')).toBeVisible();
expect(toolbar.getByText('Delete')).toBeVisible();
});
test('Select one file', async ({ page, tmpPath }) => {
await page.filebrowser.refresh();
await page.getByText('empty.ipynb').last().click();
const toolbar = page.getByRole('toolbar');
['Rename', 'Delete', 'Open', 'Download', 'Delete'].forEach(async (text) => {
expect(toolbar.getByText(text)).toBeVisible();
});
});
test('Select files and folders', async ({ page, tmpPath }) => {
await page.filebrowser.refresh();
await page.keyboard.down('Control');
await page.getByText('folder1').last().click();
await page.getByText('folder2').last().click();
await page.getByText('empty.ipynb').last().click();
const toolbar = page.getByRole('toolbar');
expect(toolbar.getByText('Rename')).toBeHidden();
expect(toolbar.getByText('Open')).toBeHidden();
expect(toolbar.getByText('Delete')).toBeVisible();
});
test('Select files and open', async ({ page, tmpPath }) => {
// upload an additional notebook
await page.contents.uploadFile(
path.resolve(__dirname, './notebooks/simple.ipynb'),
`${tmpPath}/simple.ipynb`
);
await page.filebrowser.refresh();
await page.keyboard.down('Control');
await page.getByText('simple.ipynb').last().click();
await page.getByText('empty.ipynb').last().click();
const toolbar = page.getByRole('toolbar');
const [nb1, nb2] = await Promise.all([
page.waitForEvent('popup'),
page.waitForEvent('popup'),
toolbar.getByText('Open').last().click(),
]);
await nb1.waitForLoadState();
await nb1.close();
await nb2.waitForLoadState();
await nb2.close();
});
});