Skip to content
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 sign up with CWTS tests #15469

Merged
merged 3 commits into from
Jun 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/functional-tests/pages/forceAuth/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { BaseLayout } from '../layout';
import uaStrings from '../../lib/ua-strings';
import { Credentials } from '../../lib/targets/base';

export abstract class ForceAuthPage extends BaseLayout {
ashrivastava-qa marked this conversation as resolved.
Show resolved Hide resolved
export class ForceAuthPage extends BaseLayout {
readonly path = 'force_auth';
context;
service;
Expand Down
2 changes: 2 additions & 0 deletions packages/functional-tests/pages/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { DeleteAccountPage } from './settings/deleteAccount';
import { DisplayNamePage } from './settings/displayName';
import { FourOhFourPage } from './fourOhFour';
import { FxDesktopV3ForceAuthPage } from './forceAuth/fxDesktopV3';
import { ForceAuthPage } from './forceAuth';
import { LoginPage } from './login';
import { RecoveryKeyPage } from './settings/recoveryKey';
import { RelierPage } from './relier';
Expand All @@ -31,6 +32,7 @@ export function create(page: Page, target: BaseTarget) {
displayName: new DisplayNamePage(page, target),
fourOhFour: new FourOhFourPage(page, target),
fxDesktopV3ForceAuth: new FxDesktopV3ForceAuthPage(page, target),
forceAuth: new ForceAuthPage(page, target),
login: new LoginPage(page, target),
page,
recoveryKey: new RecoveryKeyPage(page, target),
Expand Down
68 changes: 56 additions & 12 deletions packages/functional-tests/pages/login.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,17 @@ export const selectors = {
NOT_EMAIL_MET: '#password-same-as-email.password-strength-met',
NOT_EMAIL_FAIL: '#password-same-as-email.password-strength-fail',
PERMISSION_ACCEPT: '#accept',
CWTS_HEADER: 'text="Choose what to sync"',
CWTS_ENGINE_HEADER: 'text="Choose what to sync"',
CWTS_ENGINE_BOOKMARKS: '#sync-engine-bookmarks',
CWTS_ENGINE_HISTORY: '#sync-engine-history',
CWTS_ENGINE_PASSWORDS: '#sync-engine-passwords',
CWTS_ENGINE_ADDONS: '#sync-engine-addons',
CWTS_ENGINE_TABS: '#sync-engine-tabs',
CWTS_ENGINE_PREFS: '#sync-engine-prefs',
CWTS_ENGINE_CREDITCARDS: '#sync-engine-creditcards',
CWTS_ENGINE_ADDRESSES: '#sync-engine-addresses',
DO_NOT_SYNC: '#do-not-sync-device',
CWTS_PAGE_HEADER: '#fxa-choose-what-to-sync-header',
};

type FirstSignUpOptions = {
Expand Down Expand Up @@ -378,22 +386,58 @@ export class LoginPage extends BaseLayout {
return this.page.locator(selectors.SUBMIT).click();
}

async waitForCWTSHeader() {
await this.page.waitForSelector(selectors.CWTS_HEADER, {
timeout: 100,
async waitForCWTSEngineHeader() {
await this.page.waitForSelector(selectors.CWTS_ENGINE_HEADER, {
timeout: 2000,
ashrivastava-qa marked this conversation as resolved.
Show resolved Hide resolved
});
}

async waitForCWTSEngineBookmarks() {
await this.page.waitForSelector(selectors.CWTS_ENGINE_BOOKMARKS, {
timeout: 100,
});
async isCWTSPageHeader() {
return this.page.locator(selectors.CWTS_PAGE_HEADER).isVisible();
}

async waitForCWTSEngineHistory() {
await this.page.waitForSelector(selectors.CWTS_ENGINE_HISTORY, {
timeout: 100,
});
async isCWTSEngineCreditCards() {
return this.page.locator(selectors.CWTS_ENGINE_CREDITCARDS).isVisible();
}

async isCWTSEngineBookmarks() {
return this.page.locator(selectors.CWTS_ENGINE_BOOKMARKS).isVisible();
}

async isCWTSEngineHistory() {
return this.page.locator(selectors.CWTS_ENGINE_HISTORY).isVisible();
}

async isCWTSEnginePasswords() {
return this.page.locator(selectors.CWTS_ENGINE_PASSWORDS).isVisible();
}

async isCWTSEngineAddons() {
return this.page.locator(selectors.CWTS_ENGINE_ADDONS).isVisible();
}

async isCWTSEnginePrefs() {
return this.page.locator(selectors.CWTS_ENGINE_PREFS).isVisible();
}

async isCWTSEngineTabs() {
return this.page.locator(selectors.CWTS_ENGINE_TABS).isVisible();
}

async isCWTSEngineAddresses() {
return this.page.locator(selectors.CWTS_ENGINE_ADDRESSES).isVisible();
}

async isDoNotSync() {
return this.page.locator(selectors.DO_NOT_SYNC).isVisible();
}

async uncheckCWTSEngineHistory() {
await this.page.locator(selectors.CWTS_ENGINE_HISTORY).click();
}

async uncheckCWTSEnginePasswords() {
await this.page.locator(selectors.CWTS_ENGINE_PASSWORDS).click();
}
ashrivastava-qa marked this conversation as resolved.
Show resolved Hide resolved

async isSyncConnectedHeader() {
Expand Down
5 changes: 5 additions & 0 deletions packages/functional-tests/pages/resetPassword.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export const selectors = {
VPASSWORD: '#vpassword',
PASSWORD: '#password',
RESEND_RESET_PASSWORD_LINK: '#resend',
REMEMBER_PASSWORD: 'text="Remember password? Sign in"',
RESEND_SUCCESS: '.success',
UNKNOWN_ACCOUNT_ERROR: '.error',
RESET_PASSWORD_COMPLETE_HEADER: '#fxa-reset-password-complete-header',
Expand Down Expand Up @@ -70,6 +71,10 @@ export class ResetPasswordPage extends BaseLayout {
await this.page.locator(selectors.RESEND_RESET_PASSWORD_LINK).click();
}

async clickRememberPassword() {
await this.page.locator(selectors.REMEMBER_PASSWORD).click();
}

async resendSuccessMessage() {
await this.page.locator(selectors.RESEND_SUCCESS).waitFor();
return this.page.innerText(selectors.RESEND_SUCCESS);
Expand Down
71 changes: 71 additions & 0 deletions packages/functional-tests/tests/misc/forceAuth.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/* 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('force auth', () => {
test('with a registered email, registered uid', async ({
credentials,
pages: { login, forceAuth },
}) => {
await forceAuth.open(credentials);
await login.setPassword(credentials.password);
await login.submit();
expect(await login.loginHeader()).toBe(true);
});

test('forgot password flow via force_auth', async ({
credentials,
pages: { login, resetPassword, forceAuth },
}) => {
await forceAuth.open(credentials);
await login.clickForgotPassword();

// Verify reset password header
expect(await resetPassword.resetPasswordHeader()).toBe(true);

//Verify email is prefilled
expect(await login.getPrefilledEmail()).toContain(credentials.email);

//Click 'Remember password? Sign in', redirected to force auth page
await resetPassword.clickRememberPassword();
expect(await login.getPrefilledEmail()).toContain(credentials.email);

//Click forgot password again
await login.clickForgotPassword();
await resetPassword.clickBeginReset();

//Verify confirm reset password header
expect(await resetPassword.confirmResetPasswordHeader()).toBe(true);

//Click 'Remember password? Sign in', redirected to force auth page
await resetPassword.clickRememberPassword();
expect(await login.getPrefilledEmail()).toContain(credentials.email);
});

test('form prefill information is cleared after sign in->sign out', async ({
credentials,
pages: { login, forceAuth, settings },
}) => {
await forceAuth.open(credentials);
await login.setPassword(credentials.password);
await login.submit();
expect(await login.loginHeader()).toBe(true);

//Sign out
await settings.signOut();

//Verify user need to enter email
expect(await login.isEmailHeader()).toBe(true);
await login.setEmail(credentials.email);
await login.submit();

//Verify password is empty and user need to enter password
expect(await login.isPasswordHeader()).toBe(true);
expect(await login.getPasswordInput()).toContain('');
await login.setPassword(credentials.password);
await login.submit();
expect(await login.loginHeader()).toBe(true);
});
});
6 changes: 3 additions & 3 deletions packages/functional-tests/tests/oauth/webchannel.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ test.describe('oauth webchannel', () => {
await login.submit();

// the CWTS form is on the same signup page
await login.waitForCWTSHeader();
await login.waitForCWTSEngineBookmarks();
await login.waitForCWTSEngineHistory();
await login.waitForCWTSEngineHeader();
expect(await login.isCWTSEngineBookmarks()).toBe(true);
expect(await login.isCWTSEngineHistory()).toBe(true);

await login.fillOutFirstSignUp(email, PASSWORD, {
enterEmail: false,
Expand Down
Loading