-
Notifications
You must be signed in to change notification settings - Fork 212
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
test(functional): rewrite sync v3 settings test #15455
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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 contains 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
This file contains 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
130 changes: 130 additions & 0 deletions
130
packages/functional-tests/tests/syncV3/settings.spec.ts
This file contains 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,130 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
import { test, expect, newPagesForSync } from '../../lib/fixtures/standard'; | ||
import { FirefoxCommand, createCustomEventDetail } from '../../lib/channels'; | ||
|
||
const firstPassword = 'password'; | ||
const secondPassword = 'new_password'; | ||
let email; | ||
let syncBrowserPages; | ||
|
||
test.describe.configure({ mode: 'parallel' }); | ||
|
||
test.describe('Firefox Desktop Sync v3 settings', () => { | ||
test.beforeEach(async ({ target }) => { | ||
test.slow(); | ||
syncBrowserPages = await newPagesForSync(target); | ||
const { login, connectAnotherDevice, page } = syncBrowserPages; | ||
email = login.createEmail('sync{id}'); | ||
await target.auth.signUp(email, firstPassword, { | ||
lang: 'en', | ||
preVerified: 'true', | ||
}); | ||
const customEventDetail = createCustomEventDetail( | ||
FirefoxCommand.LinkAccount, | ||
{ | ||
ok: true, | ||
} | ||
); | ||
await page.goto( | ||
`${target.contentServerUrl}?context=fx_desktop_v3&service=sync&action=email` | ||
); | ||
await login.respondToWebChannelMessage(customEventDetail); | ||
await login.fillOutEmailFirstSignIn(email, firstPassword); | ||
expect(await login.isSignInCodeHeader()).toBe(true); | ||
await login.checkWebChannelMessage(FirefoxCommand.LinkAccount); | ||
await login.fillOutSignInCode(email); | ||
await login.checkWebChannelMessage(FirefoxCommand.Login); | ||
expect(await connectAnotherDevice.fxaConnected.isEnabled()).toBeTruthy(); | ||
}); | ||
|
||
test.afterEach(async ({ target }, test) => { | ||
await syncBrowserPages.browser?.close(); | ||
if (email) { | ||
// Cleanup any accounts created during the test | ||
try { | ||
await target.auth.accountDestroy(email, secondPassword); | ||
} catch (e) { | ||
// Handle the error here | ||
console.error('An error occurred during account cleanup:', e); | ||
// Optionally, rethrow the error to propagate it further | ||
throw e; | ||
} | ||
} | ||
}); | ||
|
||
test('sign in, change the password', async ({ target }) => { | ||
const { changePassword, settings, page } = syncBrowserPages; | ||
|
||
//Goto settings sync url | ||
await page.goto( | ||
`${target.contentServerUrl}/settings?context=fx_desktop_v3&service=sync` | ||
); | ||
|
||
//Change password | ||
await settings.password.clickChange(); | ||
await changePassword.fillOutChangePassword(firstPassword, secondPassword); | ||
await changePassword.submit(); | ||
|
||
//Verify success message | ||
expect(await changePassword.changePasswordSuccess()).toContain( | ||
'Password updated' | ||
); | ||
}); | ||
|
||
test('sign in, change the password by browsing directly to settings', async ({ | ||
target, | ||
}) => { | ||
const { login, changePassword, settings } = syncBrowserPages; | ||
|
||
//Goto settings non-sync url | ||
await settings.goto(); | ||
|
||
//Change password | ||
await settings.password.clickChange(); | ||
await login.noSuchWebChannelMessage(FirefoxCommand.ChangePassword); | ||
await changePassword.fillOutChangePassword(firstPassword, secondPassword); | ||
await changePassword.submit(); | ||
|
||
//Verify success message | ||
expect(await changePassword.changePasswordSuccess()).toContain( | ||
'Password updated' | ||
); | ||
}); | ||
}); | ||
|
||
test.describe('Firefox Desktop Sync v3 settings - delete account', () => { | ||
test('sign in, delete the account', async ({ target }) => { | ||
syncBrowserPages = await newPagesForSync(target); | ||
const { login, settings, deleteAccount, page } = syncBrowserPages; | ||
test.slow(); | ||
email = login.createEmail('sync{id}'); | ||
await target.auth.signUp(email, firstPassword, { | ||
lang: 'en', | ||
preVerified: 'true', | ||
}); | ||
await page.goto( | ||
`${target.contentServerUrl}?context=fx_desktop_v3&service=sync&action=email` | ||
); | ||
await login.fillOutEmailFirstSignIn(email, firstPassword); | ||
await login.fillOutSignInCode(email); | ||
|
||
//Go to setting page | ||
await page.goto( | ||
`${target.contentServerUrl}/settings?context=fx_desktop_v3&service=sync` | ||
); | ||
//Click Delete account | ||
await settings.clickDeleteAccount(); | ||
await deleteAccount.checkAllBoxes(); | ||
await deleteAccount.clickContinue(); | ||
|
||
//Enter password | ||
await deleteAccount.setPassword(firstPassword); | ||
await deleteAccount.submit(); | ||
|
||
const success = await page.waitForSelector('.success'); | ||
expect(await success.isVisible()).toBeTruthy(); | ||
}); | ||
}); |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🙌