forked from freeCodeCamp/freeCodeCamp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprogress-reset-modal.spec.ts
157 lines (128 loc) · 4.15 KB
/
progress-reset-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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
import { exec } from 'child_process';
import { promisify } from 'util';
import { test, expect } from '@playwright/test';
import translations from '../client/i18n/locales/english/translations.json';
const execP = promisify(exec);
test.beforeEach(async ({ page }) => {
await page.goto('/settings');
});
test.afterEach(async () => {
await execP('node ./tools/scripts/seed/seed-demo-user --certified-user');
});
test.describe('Progress reset modal', () => {
test('should display the content properly', async ({ page }) => {
await page
.getByRole('button', { name: 'Reset all of my progress' })
.click();
await expect(
page.getByRole('dialog', { name: 'Reset My Progress' })
).toBeVisible();
await expect(
page.getByText(
'This will permanently delete and reset all of the following:'
)
).toBeVisible();
await expect(
page.getByText(
'Your progress through each step/challenge (all completed challenges will be lost)'
)
).toBeVisible();
await expect(
page.getByText(
'Any saved code, including partially completed challenges, and certification project code'
)
).toBeVisible();
await expect(
page.getByText('All completed and claimed certifications')
).toBeVisible();
await expect(
page.getByText(
'You will effectively be set back to the very first day you signed up.'
)
).toBeVisible();
await expect(
page.getByText(
"We won't be able to recover any of it for you later, even if you change your mind."
)
).toBeVisible();
await expect(
page.getByRole('button', {
name: "Nevermind, I don't want to delete all of my progress"
})
).toBeVisible();
await expect(
page.getByRole('button', {
name: 'Reset everything. I want to start from the beginning'
})
).toBeVisible();
await expect(
page.getByRole('button', {
name: 'Reset everything. I want to start from the beginning'
})
).toBeDisabled();
});
test('should close the dialog if the user clicks the cancel button', async ({
page
}) => {
await page
.getByRole('button', { name: 'Reset all of my progress' })
.click();
await expect(
page.getByRole('dialog', { name: 'Reset My Progress' })
).toBeVisible();
await page
.getByRole('button', {
name: "Nevermind, I don't want to delete all of my progress"
})
.click();
await expect(
page.getByRole('dialog', { name: 'Reset My Progress' })
).toBeHidden();
});
test('Reset progress button should be disabled if user incorrectly fills verify input text', async ({
page
}) => {
await page
.getByRole('button', { name: 'Reset all of my progress' })
.click();
await expect(
page.getByRole('dialog', { name: 'Reset My Progress' })
).toBeVisible();
const verifyResetInput = page.getByRole('textbox', {
exact: true
});
await verifyResetInput.fill('incorrect text');
await expect(
page.getByRole('button', {
name: 'Reset everything. I want to start from the beginning'
})
).toBeDisabled();
});
test('should reset the progress if the user fills the verify input text and clicks the reset button', async ({
page
}) => {
await page
.getByRole('button', { name: 'Reset all of my progress' })
.click();
await expect(
page.getByRole('dialog', { name: 'Reset My Progress' })
).toBeVisible();
const verifyResetText = translations.settings.danger['verify-reset-text'];
const verifyResetInput = page.getByRole('textbox', {
exact: true
});
await verifyResetInput.fill(verifyResetText);
await page
.getByRole('button', {
name: 'Reset everything. I want to start from the beginning'
})
.click();
await page.waitForURL('/');
await expect(page.getByText('Your progress has been reset')).toBeVisible();
// Go to /settings and confirm that all certifications are reset
await page.goto('/settings');
await expect(
page.getByRole('link', { name: 'Show Certification' })
).toBeHidden();
});
});