forked from freeCodeCamp/freeCodeCamp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmobile-layout.spec.ts
89 lines (78 loc) · 3.09 KB
/
mobile-layout.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
85
86
87
88
89
import { test, expect } from '@playwright/test';
import translations from '../client/i18n/locales/english/translations.json';
test.describe('Classic challenge - 5 tabs mobile layout component', () => {
test.skip(
({ isMobile }) => isMobile === false,
'Skip testing on desktop as this component is only used for mobile'
);
test('The page has mobile layout with "Instruction", "Code", "Console", "Preview", "Portal Preview" tabs', async ({
page
}) => {
await page.goto(
'learn/2022/responsive-web-design/build-a-survey-form-project/build-a-survey-form'
);
const tabs = page.getByRole('tablist');
await expect(tabs).toBeVisible();
const instructions = page.getByRole('tab', {
name: translations.learn['editor-tabs'].instructions
});
await expect(instructions).toBeVisible();
const code = page.getByRole('tab', {
name: translations.learn['editor-tabs'].code
});
await expect(code).toBeVisible();
const console = page.getByRole('tab', {
name: translations.learn['editor-tabs'].console
});
await expect(console).toBeVisible();
const preview = page.getByRole('tab', {
name: translations.learn['editor-tabs'].preview
});
await expect(preview).toBeVisible();
const portalButton = page.getByRole('button', {
name: translations.aria['move-preview-to-new-window']
});
await expect(portalButton).toBeVisible();
const help = page.getByRole('button', { name: translations.buttons.help });
await expect(help).toBeVisible();
const save = page.getByRole('button', { name: translations.buttons.save });
await expect(save).toBeVisible();
const run = page.getByRole('button', { name: translations.buttons.run });
await expect(run).toBeVisible();
});
});
test.describe('Classic challenge - 3 tabs mobile layout component', () => {
test.skip(
({ isMobile }) => isMobile === false,
'Skip testing on desktop as this component is only used for mobile'
);
test('The page has mobile layout with "Instruction", "Code", "Console" tabs', async ({
page
}) => {
await page.goto(
'learn/javascript-algorithms-and-data-structures/basic-javascript/use-recursion-to-create-a-range-of-numbers'
);
const tabs = page.getByRole('tablist');
await expect(tabs).toBeVisible();
const instructions = page.getByRole('tab', {
name: translations.learn['editor-tabs'].instructions
});
await expect(instructions).toBeVisible();
const code = page.getByRole('tab', {
name: translations.learn['editor-tabs'].code
});
await expect(code).toBeVisible();
const console = page.getByRole('tab', {
name: translations.learn['editor-tabs'].console
});
await expect(console).toBeVisible();
const help = page.getByRole('button', { name: translations.buttons.help });
await expect(help).toBeVisible();
const reset = page.getByRole('button', {
name: translations.buttons.reset
});
await expect(reset).toBeVisible();
const run = page.getByRole('button', { name: translations.buttons.run });
await expect(run).toBeVisible();
});
});