forked from freeCodeCamp/freeCodeCamp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexam-results-modal.spec.ts
67 lines (55 loc) · 2.34 KB
/
exam-results-modal.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
import { test, expect } from '@playwright/test';
test.describe('Exam results modal', () => {
test.beforeEach(async ({ page }) => {
await page.goto('/settings');
});
test('should display the content correctly', async ({ page }) => {
const viewButton = page.getByRole('button', {
name: 'View Results for Foundational C# with Microsoft Certification Exam'
});
await expect(viewButton).toBeVisible();
await viewButton.click();
await expect(
page.getByRole('dialog', {
name: 'Results for Foundational C# with Microsoft Certification Exam'
})
).toBeVisible();
await expect(page.getByText('Number of questions: 80')).toBeVisible();
await expect(page.getByText('Correct answers: 70')).toBeVisible();
await expect(page.getByText('Percent correct: 87.5%')).toBeVisible();
await expect(page.getByText('Time: 36:35')).toBeVisible();
await expect(page.getByRole('button', { name: 'Close' })).toHaveCount(2);
});
test('should close when the x button is clicked', async ({ page }) => {
const viewButton = page.getByRole('button', {
name: 'View Results for Foundational C# with Microsoft Certification Exam'
});
await expect(viewButton).toBeVisible();
await viewButton.click();
await expect(
page.getByRole('dialog', {
name: 'Results for Foundational C# with Microsoft Certification Exam'
})
).toBeVisible();
// There are 2 close buttons on the page, and the x button is the first
const closeButton = page.getByRole('button', { name: 'Close' }).first();
await closeButton.click();
await expect(page.getByRole('dialog')).toHaveCount(0);
});
test('should close when the close button is clicked', async ({ page }) => {
const viewButton = page.getByRole('button', {
name: 'View Results for Foundational C# with Microsoft Certification Exam'
});
await expect(viewButton).toBeVisible();
await viewButton.click();
await expect(
page.getByRole('dialog', {
name: 'Results for Foundational C# with Microsoft Certification Exam'
})
).toBeVisible();
// There are 2 close buttons on the page, and the close button is the last
const closeButton = page.getByRole('button', { name: 'Close' }).last();
await closeButton.click();
await expect(page.getByRole('dialog')).toHaveCount(0);
});
});