Skip to content

Commit

Permalink
Merge pull request #15440 from mozilla/rewrite-signin-oauth-avatar-tests
Browse files Browse the repository at this point in the history
test(functional): rewrite signin and oauth reset password test
  • Loading branch information
ashrivastava-qa authored Jun 22, 2023
2 parents 5b2ae6e + 00becd6 commit 6d65d20
Show file tree
Hide file tree
Showing 4 changed files with 144 additions and 3 deletions.
1 change: 0 additions & 1 deletion packages/functional-tests/pages/resetPassword.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { BaseLayout } from './layout';
import { LoginPage } from './login';

export const selectors = {
RESET_PASSWORD_EXPIRED_HEADER: '#fxa-reset-link-expired-header',
Expand Down
41 changes: 41 additions & 0 deletions packages/functional-tests/tests/oauth/resetPassword.spec.ts
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);
});
});
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { test, expect } from '../../lib/fixtures/standard';

const PASSWORD = 'passwordzxcv';

test.describe('Reset password current', () => {
test.beforeEach(async ({ target, credentials, pages: { login } }) => {
test.slow();
Expand Down
103 changes: 103 additions & 0 deletions packages/functional-tests/tests/signin/signIn.spec.ts
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);
});
});

0 comments on commit 6d65d20

Please sign in to comment.