forked from freeCodeCamp/freeCodeCamp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpreview.spec.ts
48 lines (44 loc) · 1.29 KB
/
preview.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
import { expect, test } from '@playwright/test';
import translations from '../client/i18n/locales/english/translations.json';
import { focusEditor } from './utils/editor';
test.beforeEach(async ({ page }) => {
await page.goto(
'/learn/2022/responsive-web-design/learn-html-by-building-a-cat-photo-app/step-3'
);
});
test.describe('Challenge Preview Component', () => {
test('should render correct output of default code', async ({
page,
isMobile
}) => {
if (isMobile) {
await page
.getByRole('tab', { name: translations.learn['editor-tabs'].preview })
.click();
}
await expect(
page
.frameLocator('.challenge-preview-frame')
.first()
.getByRole('heading', { name: 'CatPhotoApp' })
).toBeVisible();
});
test('should render correct output of changed code', async ({
page,
isMobile
}) => {
await focusEditor({ page, isMobile });
await page.keyboard.insertText('<h1>FreeCodeCamp</h1>');
if (isMobile) {
await page
.getByRole('tab', { name: translations.learn['editor-tabs'].preview })
.click();
}
await expect(
page
.frameLocator('.challenge-preview-frame')
.first()
.getByRole('heading', { name: 'FreeCodeCamp' })
).toBeVisible();
});
});