forked from freeCodeCamp/freeCodeCamp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshow.spec.ts
68 lines (56 loc) · 2.14 KB
/
show.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
import { test, expect } from '@playwright/test';
import translations from '../client/i18n/locales/english/translations.json';
// Tests for challenges rendered by `client/src/templates/Challenges/odin/show.tsx`
test.describe('Odin challenges', () => {
test.beforeEach(async ({ page }) => {
await page.goto(
'/learn/foundational-c-sharp-with-microsoft/write-your-first-code-using-c-sharp/write-your-first-c-sharp-code'
);
});
test.describe('When the user is signed out', () => {
test.use({ storageState: { cookies: [], origins: [] } });
test('should render the content correctly', async ({ page }) => {
await expect(page).toHaveTitle(
'Write Your First Code Using C# - Write Your First C# Code | Learn | freeCodeCamp.org'
);
await expect(
page.getByRole('heading', {
level: 1,
name: 'Write Your First C# Code'
})
).toBeVisible();
// Checkmark doesn't show up if the user has completed the challenge but is signed out
await expect(
page.getByRole('img', { name: translations.icons.passed })
).toBeHidden();
await expect(
page.getByRole('button', { name: translations.buttons['check-answer'] })
).toBeVisible();
await expect(
page.getByRole('button', { name: translations.buttons['ask-for-help'] })
).toBeVisible();
});
});
test.describe('When the user is signed in', () => {
test('should render the content correctly', async ({ page }) => {
await expect(page).toHaveTitle(
'Write Your First Code Using C# - Write Your First C# Code | Learn | freeCodeCamp.org'
);
await expect(
page.getByRole('heading', {
level: 1,
name: 'Write Your First C# Code'
})
).toBeVisible();
await expect(
page.getByRole('img', { name: translations.icons.passed })
).toBeVisible();
await expect(
page.getByRole('button', { name: translations.buttons['check-answer'] })
).toBeVisible();
await expect(
page.getByRole('button', { name: translations.buttons['ask-for-help'] })
).toBeVisible();
});
});
});