forked from stackblitz/tutorialkit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfilesystem.test.ts
104 lines (76 loc) · 3.47 KB
/
filesystem.test.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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
import { test, expect } from '@playwright/test';
const BASE_URL = '/tests/filesystem';
test('editor should reflect changes made from webcontainer', async ({ page }) => {
const testCase = 'watch';
await page.goto(`${BASE_URL}/${testCase}`);
await expect(page.getByRole('textbox', { name: 'Editor' })).toHaveText('Initial content\n', {
useInnerText: true,
});
await page.getByTestId('write-to-file').click();
await expect(page.getByRole('textbox', { name: 'Editor' })).toHaveText('Something else', {
useInnerText: true,
});
});
test('editor should reflect changes made from webcontainer in file in nested folder and not add new files', async ({ page }) => {
const testCase = 'watch';
await page.goto(`${BASE_URL}/${testCase}`);
// set up actions that shouldn't do anything
await page.getByTestId('write-new-ignored-file').click();
await page.getByTestId('delete-file').click();
await page.getByRole('button', { name: 'baz.txt' }).click();
await expect(page.getByRole('textbox', { name: 'Editor' })).toHaveText('Baz', {
useInnerText: true,
});
await page.getByTestId('write-to-file-in-subfolder').click();
await expect(page.getByRole('textbox', { name: 'Editor' })).toHaveText('Foo', {
useInnerText: true,
});
// test that ignored actions are ignored
await expect(page.getByRole('button', { name: 'other.txt' })).not.toBeVisible();
await expect(page.getByRole('button', { name: 'bar.txt' })).toBeVisible();
});
test('editor should reflect changes made from webcontainer in specified paths', async ({ page }) => {
const testCase = 'watch-glob';
await page.goto(`${BASE_URL}/${testCase}`);
await expect(page.getByRole('textbox', { name: 'Editor' })).toHaveText('Initial content\n', {
useInnerText: true,
});
await page.getByTestId('write-to-file').click();
await expect(page.getByRole('textbox', { name: 'Editor' })).toHaveText('Something else', {
useInnerText: true,
});
});
test('editor should reflect new files added in specified paths in webcontainer', async ({ page }) => {
const testCase = 'watch-glob';
await page.goto(`${BASE_URL}/${testCase}`);
await page.getByTestId('write-new-ignored-file').click();
await page.getByTestId('write-new-file').click();
await page.getByRole('button', { name: 'new.txt' }).click();
await expect(async () => {
await expect(page.getByRole('button', { name: 'unknown' })).not.toBeVisible();
await expect(page.getByRole('button', { name: 'other.txt' })).not.toBeVisible();
}).toPass();
await expect(page.getByRole('textbox', { name: 'Editor' })).toHaveText('New', {
useInnerText: true,
});
});
test('editor should remove deleted files in specified paths in webcontainer', async ({ page }) => {
const testCase = 'watch-glob';
await page.goto(`${BASE_URL}/${testCase}`);
await page.getByTestId('delete-file').click();
await expect(async () => {
await expect(page.getByRole('button', { name: 'bar.txt' })).not.toBeVisible();
}).toPass();
});
test('editor should not reflect changes made from webcontainer if watch is not set', async ({ page }) => {
const testCase = 'no-watch';
await page.goto(`${BASE_URL}/${testCase}`);
await expect(page.getByRole('textbox', { name: 'Editor' })).toHaveText('Initial content\n', {
useInnerText: true,
});
await page.getByTestId('write-to-file').click();
await page.waitForTimeout(1_000);
await expect(page.getByRole('textbox', { name: 'Editor' })).toHaveText('Initial content\n', {
useInnerText: true,
});
});