forked from freeCodeCamp/freeCodeCamp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmultifile-cert-projects.spec.ts
73 lines (54 loc) · 2.13 KB
/
multifile-cert-projects.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
import { execSync } from 'child_process';
import { test, expect } from '@playwright/test';
import { clearEditor, focusEditor } from './utils/editor';
test.describe('multifileCertProjects', () => {
test.beforeEach(async ({ page }) => {
execSync('node ./tools/scripts/seed/seed-demo-user --certified-user');
await page.goto(
'learn/2022/responsive-web-design/build-a-tribute-page-project/build-a-tribute-page'
);
});
const success =
/Your code was saved to the database\. It will be here when you return\./;
const tooFast =
/Slow Down! Your code was not saved\. Try again in a few seconds\./;
test('should save and reload user code', async ({
page,
isMobile,
browserName
}) => {
await focusEditor({ page, isMobile });
await clearEditor({ page, browserName });
await page.keyboard.type('save1text');
await expect(page.getByText('save1text')).toBeVisible();
await page
.getByRole('button', { name: !isMobile ? 'Save your Code' : 'Save' })
.click();
await expect(page.getByTestId('flash-message')).toContainText(success);
await page.reload();
await focusEditor({ page, isMobile });
await expect(page.getByText('save1text')).toBeVisible();
});
test('should save using ctrl+s hotkey and persist through navigation', async ({
page,
isMobile,
browserName
}) => {
test.skip(isMobile);
await focusEditor({ page, isMobile });
await clearEditor({ page, browserName });
await page.keyboard.type('save2text');
await expect(page.getByText('save2text')).toBeVisible();
await page.keyboard.down('Control');
await page.keyboard.press('KeyS');
await expect(page.getByTestId('flash-message')).toContainText(success);
await page.getByRole('button', { name: 'Close' }).click();
await expect(page.getByText('save2text')).toBeVisible();
await page.reload();
await expect(page.getByText('save2text')).toBeVisible();
await focusEditor({ page, isMobile });
await page.keyboard.down('Control');
await page.keyboard.press('KeyS');
await expect(page.getByTestId('flash-message')).toContainText(tooFast);
});
});