-
Notifications
You must be signed in to change notification settings - Fork 212
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15440 from mozilla/rewrite-signin-oauth-avatar-tests
test(functional): rewrite signin and oauth reset password test
- Loading branch information
Showing
4 changed files
with
144 additions
and
3 deletions.
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
41 changes: 41 additions & 0 deletions
41
packages/functional-tests/tests/oauth/resetPassword.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,41 @@ | ||
/* 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 } from '../../lib/fixtures/standard'; | ||
import { EmailHeader, EmailType } from '../../lib/email'; | ||
|
||
test.describe('oauth reset password', () => { | ||
test.beforeEach(async ({ target, pages: { login } }) => { | ||
test.slow(); | ||
}); | ||
|
||
test('reset password happy path', async ({ | ||
target, | ||
page, | ||
credentials, | ||
pages: { login, relier, resetPassword }, | ||
}) => { | ||
await relier.goto(); | ||
await relier.clickEmailFirst(); | ||
await login.setEmail(credentials.email); | ||
await login.submit(); | ||
await login.clickForgotPassword(); | ||
|
||
// Verify reset password header | ||
expect(await resetPassword.resetPasswordHeader()).toBe(true); | ||
|
||
await resetPassword.fillOutResetPassword(credentials.email); | ||
|
||
const link = await target.email.waitForEmail( | ||
credentials.email, | ||
EmailType.recovery, | ||
EmailHeader.link | ||
); | ||
await page.goto(link); | ||
await resetPassword.resetNewPassword(credentials.password); | ||
|
||
// Verify logged in | ||
expect(await relier.isLoggedIn()).toBe(true); | ||
}); | ||
}); |
2 changes: 0 additions & 2 deletions
2
packages/functional-tests/tests/reset-password/resetPassword.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
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,103 @@ | ||
/* 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 } from '../../lib/fixtures/standard'; | ||
|
||
test.describe('signin here', () => { | ||
test('signin verified with incorrect password, click `forgot password?`', async ({ | ||
target, | ||
page, | ||
credentials, | ||
pages: { login, resetPassword }, | ||
}) => { | ||
await page.goto(target.contentServerUrl); | ||
await login.setEmail(credentials.email); | ||
await login.clickSubmit(); | ||
await login.setPassword('incorrect password'); | ||
await login.clickSubmit(); | ||
|
||
// Verify the error | ||
expect(await login.getTooltipError()).toContain('Incorrect password'); | ||
|
||
//Click forgot password link | ||
await login.clickForgotPassword(); | ||
|
||
//Verify reset password header | ||
expect(await resetPassword.resetPasswordHeader()).toBe(true); | ||
}); | ||
|
||
test('signin with email with leading/trailing whitespace on the email', async ({ | ||
target, | ||
page, | ||
credentials, | ||
pages: { login }, | ||
}) => { | ||
const emailWithleadingSpace = ' ' + credentials.email; | ||
await page.goto(target.contentServerUrl); | ||
await login.fillOutEmailFirstSignIn( | ||
emailWithleadingSpace, | ||
credentials.password | ||
); | ||
|
||
// Verify the header after login | ||
expect(await login.loginHeader()).toBe(true); | ||
|
||
// Need to clear the cache to get the new email | ||
await login.clearCache(); | ||
|
||
await page.goto(target.contentServerUrl); | ||
const emailWithTrailingSpace = credentials.email + ' '; | ||
await login.fillOutEmailFirstSignIn( | ||
emailWithTrailingSpace, | ||
credentials.password | ||
); | ||
|
||
// Verify the header after login | ||
expect(await login.loginHeader()).toBe(true); | ||
}); | ||
|
||
test('signin verified with password that incorrectly has leading whitespace', async ({ | ||
target, | ||
page, | ||
credentials, | ||
pages: { login }, | ||
}) => { | ||
await page.goto(target.contentServerUrl); | ||
await login.setEmail(credentials.email); | ||
await login.clickSubmit(); | ||
await login.setPassword(' ' + credentials.password); | ||
await login.clickSubmit(); | ||
|
||
// Verify the error | ||
expect(await login.getTooltipError()).toContain('Incorrect password'); | ||
}); | ||
|
||
test('login as an existing user', async ({ | ||
target, | ||
page, | ||
credentials, | ||
pages: { login, settings }, | ||
}) => { | ||
await page.goto(target.contentServerUrl); | ||
await login.fillOutEmailFirstSignIn( | ||
credentials.email, | ||
credentials.password | ||
); | ||
|
||
// Verify the header after login | ||
expect(await login.loginHeader()).toBe(true); | ||
|
||
// Sign out | ||
await settings.signOut(); | ||
|
||
// Login as existing user | ||
await login.setEmail(credentials.email); | ||
await login.clickSubmit(); | ||
await login.setPassword(credentials.password); | ||
await login.clickSubmit(); | ||
|
||
// Verify the header after login | ||
expect(await login.loginHeader()).toBe(true); | ||
}); | ||
}); |