forked from stackblitz/tutorialkit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfilesystem.test.ts
52 lines (37 loc) · 1.59 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
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', async ({ page }) => {
const testCase = 'watch';
await page.goto(`${BASE_URL}/${testCase}`);
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('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,
});
});