forked from freeCodeCamp/freeCodeCamp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathacademic-honesty.spec.ts
79 lines (67 loc) · 2.44 KB
/
academic-honesty.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
import { execSync } from 'child_process';
import { test, expect } from '@playwright/test';
import translations from '../client/i18n/locales/english/translations.json';
import { alertToBeVisible } from './utils/alerts';
test.describe('When the user has not accepted the Academic Honesty Policy', () => {
test.use({ storageState: 'playwright/.auth/development-user.json' });
test.beforeEach(() => {
execSync('node ./tools/scripts/seed/seed-demo-user');
});
test.afterAll(() => {
execSync('node ./tools/scripts/seed/seed-demo-user --certified-user');
});
test('they should be able to accept it', async ({ page }) => {
await page.goto('/settings');
await expect(
page.getByRole('heading', {
name: translations.settings.headings.honesty
})
).toBeVisible();
await expect(
page.getByText(translations.settings.honesty.p1)
).toBeVisible();
await expect(
page.getByText(translations.settings.honesty.p2)
).toBeVisible();
await expect(
page.getByText(translations.settings.honesty.p3)
).toBeVisible();
await expect(
page.getByText(translations.settings.honesty.p4)
).toBeVisible();
await expect(
page.getByText(translations.settings.honesty.p5)
).toBeVisible();
await expect(
page.getByText(translations.settings.honesty.p6)
).toBeVisible();
const agreeButton = page.getByRole('button', {
name: translations.buttons['agree-honesty']
});
await agreeButton.click();
await expect(
page.getByRole('button', {
name: translations.buttons['accepted-honesty']
})
).toBeVisible();
});
test('Should show an error message', async ({ page }) => {
await page.goto('/settings#cert-responsive-web-design');
const claimCertButton = page.getByRole('button', {
name: 'Claim Certification Responsive Web Design'
});
await claimCertButton.click();
await alertToBeVisible(page, translations.flash['honest-first']);
const agreeButton = page.getByRole('button', {
name: translations.buttons['agree-honesty']
});
await agreeButton.click();
await alertToBeVisible(page, translations.buttons['accepted-honesty']);
await page.reload();
await claimCertButton.click();
await alertToBeVisible(
page,
'It looks like you have not completed the necessary steps. Please complete the required projects to claim the Responsive Web Design Certification.'
);
});
});