-
-
Notifications
You must be signed in to change notification settings - Fork 40.6k
test(e2e): add tests for the progress reset flow #54614
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
huyenltnguyen
merged 6 commits into
freeCodeCamp:main
from
huyenltnguyen:test/progress-reset
May 13, 2024
Merged
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
d2606f0
rename reset-modal to challenge-reset-modal
huyenltnguyen 9becb64
add progress-reset-modal.spec.ts
huyenltnguyen f188543
remove cypress test
huyenltnguyen 3065505
simplify settings.spect.ts test
huyenltnguyen 44702f8
use the ui to verify the reset
huyenltnguyen f7277b9
Merge branch 'main' of https://github.com/freeCodeCamp/freeCodeCamp i…
huyenltnguyen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
import { exec } from 'child_process'; | ||
import { promisify } from 'util'; | ||
import { test, expect } from '@playwright/test'; | ||
|
||
const execP = promisify(exec); | ||
|
||
test.use({ storageState: 'playwright/.auth/certified-user.json' }); | ||
|
||
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(); | ||
}); | ||
|
||
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('should reset the progress if the user 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(); | ||
|
||
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(); | ||
}); | ||
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.