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 / fix e2e overlapping reports #495

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
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
54 changes: 48 additions & 6 deletions platforms/web/test-e2e/tests/account_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,16 @@ const consentCheckbox = 'Yes, I want to receive Blender updates by email';
const firstName = 'John Q.';
const lastName = 'Tester';

Feature(`account`).retry(Number(process.env.TEST_RETRY_COUNT) || 0);

runTestSuite(testConfigs.jwpSvod, 'JW Player', 'direct', false);
runTestSuite(testConfigs.svod, 'Cleeng', 'resetLink', true);

function runTestSuite(config: typeof testConfigs.svod, providerName: string, resetPasswordType: string, canEditEmail: boolean) {
let loginContext: LoginContext;

Feature(`account - ${providerName}`).retry(Number(process.env.TEST_RETRY_COUNT) || 0);

Before(async ({ I }) => {
async function beforeScenario(I: CodeceptJS.I) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it not work to just move the Before to the top level where you moved Feature? This seems like an otherwise nice, simple enough fix, but I wish we didn't need to copy all the await beforeScenario calls. Seems too easy to forget to add when you create a new Scenario.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I see, Before depends on the runTestSuite args...

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like the beforeScenario much either, we could also make this a custom step: I.amLoggedIn(config);

We also might be able to refactor the accountContext to a shared value. We can then remove that from each test as well.

// eslint-disable-next-line react-hooks/rules-of-hooks
I.useConfig(config);

loginContext = await I.registerOrLogin(loginContext, () => {
Expand All @@ -34,9 +35,11 @@ function runTestSuite(config: typeof testConfigs.svod, providerName: string, res

I.clickCloseButton();
});
});
}

Scenario(`I can see my account data - ${providerName}`, async ({ I }) => {
await beforeScenario(I);

I.seeInCurrentUrl(constants.baseUrl);
await I.openMainMenu();

Expand Down Expand Up @@ -73,6 +76,8 @@ function runTestSuite(config: typeof testConfigs.svod, providerName: string, res
Scenario(`I can cancel Edit account - ${providerName}`, async ({ I }) => {
if (!canEditEmail) return;

await beforeScenario(I);

editAndCancel(I, editAccount, [
{ name: emailField, startingValue: loginContext.email, newValue: '[email protected]' },
{ name: passwordField, startingValue: '', newValue: 'pass123!?' },
Expand All @@ -82,6 +87,8 @@ function runTestSuite(config: typeof testConfigs.svod, providerName: string, res
Scenario(`I get a duplicate email warning - ${providerName}`, async ({ I }) => {
if (!canEditEmail) return;

await beforeScenario(I);

editAndCancel(I, editAccount, [
{
name: emailField,
Expand All @@ -100,6 +107,8 @@ function runTestSuite(config: typeof testConfigs.svod, providerName: string, res
Scenario(`I get a wrong password warning - ${providerName}`, async ({ I }) => {
if (!canEditEmail) return;

await beforeScenario(I);

editAndCancel(I, editAccount, [
{
name: emailField,
Expand All @@ -118,6 +127,8 @@ function runTestSuite(config: typeof testConfigs.svod, providerName: string, res
Scenario(`I can toggle to view/hide my password - ${providerName}`, async ({ I }) => {
if (!canEditEmail) return;

await beforeScenario(I);

I.amOnPage(constants.accountsUrl);
I.click(editAccount);
await passwordUtils.testPasswordToggling(I, 'confirmationPassword');
Expand All @@ -126,6 +137,8 @@ function runTestSuite(config: typeof testConfigs.svod, providerName: string, res
Scenario(`I can reset my password (reset link) - ${providerName}`, async ({ I }) => {
if (resetPasswordType !== 'resetlink') return;

await beforeScenario(I);

I.amOnPage(constants.accountsUrl);

I.click('Edit password');
Expand Down Expand Up @@ -154,6 +167,8 @@ function runTestSuite(config: typeof testConfigs.svod, providerName: string, res
});

Scenario(`I can update firstName - ${providerName}`, async ({ I }) => {
await beforeScenario(I);

editAndSave(I, editDetails, [
{
name: firstNameField,
Expand All @@ -177,6 +192,8 @@ function runTestSuite(config: typeof testConfigs.svod, providerName: string, res
});

Scenario(`I can update lastName - ${providerName}`, async ({ I }) => {
await beforeScenario(I);

editAndSave(I, editDetails, [
{
name: lastNameField,
Expand All @@ -200,6 +217,8 @@ function runTestSuite(config: typeof testConfigs.svod, providerName: string, res
});

Scenario(`I can update details - ${providerName}`, async ({ I }) => {
await beforeScenario(I);

editAndSave(I, editDetails, [
{
name: firstNameField,
Expand Down Expand Up @@ -235,6 +254,8 @@ function runTestSuite(config: typeof testConfigs.svod, providerName: string, res
});

Scenario(`I see name limit errors - ${providerName}`, async ({ I }) => {
await beforeScenario(I);

editAndCancel(I, editDetails, [
{
name: firstNameField,
Expand All @@ -252,6 +273,8 @@ function runTestSuite(config: typeof testConfigs.svod, providerName: string, res
});

Scenario(`I can update my consents - ${providerName}`, async ({ I }) => {
await beforeScenario(I);

I.amOnPage(constants.accountsUrl);
I.waitForText('Account info', longTimeout);
I.scrollTo('//*[text() = "Legal & Marketing"]', undefined, -100);
Expand Down Expand Up @@ -288,6 +311,8 @@ function runTestSuite(config: typeof testConfigs.svod, providerName: string, res
Scenario(`I can change email - ${providerName}`, async ({ I }) => {
if (!canEditEmail) return;

await beforeScenario(I);

const newEmail = passwordUtils.createRandomEmail();

editAndSave(I, editAccount, [
Expand All @@ -305,7 +330,15 @@ function runTestSuite(config: typeof testConfigs.svod, providerName: string, res
]);
});

function editAndSave(I: CodeceptJS.I, editButton: string, fields: { name: string; newValue: string; expectedError?: string }[]) {
function editAndSave(
I: CodeceptJS.I,
editButton: string,
fields: {
name: string;
newValue: string;
expectedError?: string;
}[],
) {
I.amOnPage(constants.accountsUrl);
I.waitForElement(`//*[text() = "${editButton}"]`, normalTimeout);
I.scrollTo(`//*[text() = "${editButton}"]`);
Expand Down Expand Up @@ -354,7 +387,16 @@ function runTestSuite(config: typeof testConfigs.svod, providerName: string, res
I.click('Cancel');
}

function editAndCancel(I: CodeceptJS.I, editButton: string, fields: { name: string; startingValue: string; newValue: string; expectedError?: string }[]) {
function editAndCancel(
I: CodeceptJS.I,
editButton: string,
fields: {
name: string;
startingValue: string;
newValue: string;
expectedError?: string;
}[],
) {
I.amOnPage(constants.accountsUrl);
I.click(editButton);

Expand Down
4 changes: 2 additions & 2 deletions platforms/web/test-e2e/tests/language_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ Scenario('Spanish language is selected when the locale is `es-ES`', async ({ I }
await assertActiveLanguage(I, 'es');
});

Scenario('Changing the language is persisted in the localStorage`', async ({ I }) => {
Scenario('Changing the language is persisted in the localStorage', async ({ I }) => {
I.restartBrowser({ locale: 'en-US' });
I.useConfig(testConfigs.basicNoAuth);

Expand All @@ -80,7 +80,7 @@ Scenario('Changing the language is persisted in the localStorage`', async ({ I }
assert.strictEqual(persistedLanguage, 'es');
});

Scenario('The language is restored from localStorage`', async ({ I }) => {
Scenario('The language is restored from localStorage', async ({ I }) => {
I.restartBrowser({
storageState: {
origins: [
Expand Down
21 changes: 15 additions & 6 deletions platforms/web/test-e2e/tests/login/account_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,39 @@ import { testConfigs } from '@jwp/ott-testing/constants';

import constants, { normalTimeout } from '#utils/constants';
import passwordUtils from '#utils/password_utils';
import { tryToSubmitForm, fillAndCheckField, checkField } from '#utils/login';
import { checkField, fillAndCheckField, tryToSubmitForm } from '#utils/login';

const fieldRequired = 'This field is required';
const invalidEmail = 'Please re-enter your email details and try again.';
const incorrectLogin = 'Incorrect email/password combination';
const formFeedback = 'div[class*=formFeedback]';

Feature('login - account').retry(Number(process.env.TEST_RETRY_COUNT) || 0);

runTestSuite(testConfigs.jwpAuth, 'JW Player');
runTestSuite(testConfigs.cleengAuthvod, 'Cleeng');

function runTestSuite(config: typeof testConfigs.svod, providerName: string) {
Feature(`login - account - ${providerName}`).retry(Number(process.env.TEST_RETRY_COUNT) || 0);

Before(async ({ I }) => {
async function beforeScenario(I: CodeceptJS.I) {
// eslint-disable-next-line react-hooks/rules-of-hooks
I.useConfig(config);

await I.openSignInModal();

I.waitForElement(constants.loginFormSelector, normalTimeout);
});
}

Scenario(`I can close the modal - ${providerName}`, async ({ I }) => {
await beforeScenario(I);

I.clickCloseButton();
I.dontSee('Email');
I.dontSee('Password');
I.dontSeeElement(constants.loginFormSelector);
});

Scenario(`I can close the modal by clicking outside - ${providerName}`, async ({ I }) => {
await beforeScenario(I);

I.forceClick('div[data-testid="backdrop"]');

I.dontSee('Email');
Expand All @@ -39,17 +43,20 @@ function runTestSuite(config: typeof testConfigs.svod, providerName: string) {
});

Scenario(`I can toggle to view password - ${providerName}`, async ({ I }) => {
await beforeScenario(I);
await passwordUtils.testPasswordToggling(I);
});

Scenario(`I get a warning when the form is incompletely filled in - ${providerName}`, async ({ I }) => {
await beforeScenario(I);
tryToSubmitForm(I);

checkField(I, 'email', fieldRequired);
checkField(I, 'password', fieldRequired);
});

Scenario(`I see email warnings - ${providerName}`, async ({ I }) => {
await beforeScenario(I);
I.fillField('email', '[email protected]');
I.fillField('password', 'Password');

Expand Down Expand Up @@ -81,6 +88,7 @@ function runTestSuite(config: typeof testConfigs.svod, providerName: string) {
});

Scenario(`I see empty password warnings - ${providerName}`, async ({ I }) => {
await beforeScenario(I);
I.fillField('email', '[email protected]');
I.fillField('password', 'Password');

Expand All @@ -105,6 +113,7 @@ function runTestSuite(config: typeof testConfigs.svod, providerName: string) {
});

Scenario(`I see a login error message - ${providerName}`, async ({ I }) => {
await beforeScenario(I);
I.fillField('email', '[email protected]');
I.fillField('password', 'Password');

Expand Down
13 changes: 7 additions & 6 deletions platforms/web/test-e2e/tests/login/home_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,24 @@ import { testConfigs } from '@jwp/ott-testing/constants';
import constants, { longTimeout } from '#utils/constants';
import { LoginContext } from '#utils/password_utils';

Feature(`login - home`).retry(Number(process.env.TEST_RETRY_COUNT) || 0);

runTestSuite(testConfigs.jwpAuth, 'JW Player');
runTestSuite(testConfigs.cleengAuthvod, 'Cleeng');

function runTestSuite(config: typeof testConfigs.svod, providerName: string) {
let loginContext: LoginContext;

Feature(`login - home - ${providerName}`).retry(Number(process.env.TEST_RETRY_COUNT) || 0);

Before(({ I }) => {
I.useConfig(config);
});

Scenario(`Sign-in buttons show for accounts config - ${providerName}`, async ({ I }) => {
I.useConfig(config);
await I.openSignInMenu();

I.see('Sign in');
I.see('Sign up');
});

Scenario(`Sign-in buttons don't show for config without accounts - ${providerName}`, async ({ I }) => {
I.useConfig(config);
await I.openSignInMenu();

I.see('Sign in');
Expand All @@ -37,6 +35,7 @@ function runTestSuite(config: typeof testConfigs.svod, providerName: string) {
});

Scenario(`I can open the log in modal - ${providerName}`, async ({ I }) => {
I.useConfig(config);
await I.openSignInModal();
I.waitForElement(constants.loginFormSelector, longTimeout);

Expand All @@ -51,6 +50,7 @@ function runTestSuite(config: typeof testConfigs.svod, providerName: string) {
});

Scenario(`I can login - ${providerName}`, async ({ I }) => {
I.useConfig(config);
loginContext = await I.registerOrLogin(loginContext);

await I.openMainMenu();
Expand All @@ -64,6 +64,7 @@ function runTestSuite(config: typeof testConfigs.svod, providerName: string) {
});

Scenario(`I can log out - ${providerName}`, async ({ I }) => {
I.useConfig(config);
loginContext = await I.registerOrLogin(loginContext);

await I.openMainMenu();
Expand Down
31 changes: 18 additions & 13 deletions platforms/web/test-e2e/tests/payments/coupons_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { testConfigs } from '@jwp/ott-testing/constants';

import { LoginContext } from '#utils/password_utils';
import constants from '#utils/constants';
import { goToCheckout, formatPrice, finishAndCheckSubscription, addYear, cancelPlan, renewPlan, overrideIP } from '#utils/payments';
import { goToCheckout, formatPrice, finishSubscription, addYear, cancelPlan, renewPlan, overrideIP, checkSubscription } from '#utils/payments';
import { ProviderProps } from '#test/types';

const jwProps: ProviderProps = {
Expand Down Expand Up @@ -31,26 +31,24 @@ const cleengProps: ProviderProps = {
hasInlineOfferSwitch: false,
};

Feature('payments-coupon').retry(Number(process.env.TEST_RETRY_COUNT) || 0);

Before(async ({ I }) => {
// This gets used in checkoutService.getOffer to make sure the offers are geolocated for NL
overrideIP(I);
});

runTestSuite(jwProps, 'JW Player');
runTestSuite(cleengProps, 'Cleeng');

function runTestSuite(props: ProviderProps, providerName: string) {
let couponLoginContext: LoginContext;

const today = new Date();

// This is written as a second test suite so that the login context is a different user.
// Otherwise, there's no way to re-enter payment info and add a coupon code
Feature(`payments-coupon - ${providerName}`).retry(Number(process.env.TEST_RETRY_COUNT) || 0);

Before(async ({ I }) => {
// This gets used in checkoutService.getOffer to make sure the offers are geolocated for NL
overrideIP(I);
Scenario(`I can redeem coupons - ${providerName}`, async ({ I }) => {
I.useConfig(props.config);
couponLoginContext = await I.registerOrLogin(couponLoginContext);
});

Scenario(`I can redeem coupons - ${providerName}`, async ({ I }) => {
await goToCheckout(I);

I.click('Redeem coupon');
Expand Down Expand Up @@ -88,14 +86,21 @@ function runTestSuite(props: ProviderProps, providerName: string) {
);
}

await finishAndCheckSubscription(I, addYear(today), today, props.yearlyOffer.price, props.hasInlineOfferSwitch);
await finishSubscription(I);
await checkSubscription(I, addYear(today), today, props.yearlyOffer.price, props.hasInlineOfferSwitch);
});

Scenario(`I can cancel a free subscription - ${providerName}`, async ({ I }) => {
cancelPlan(I, addYear(today), props.canRenewSubscription, providerName);
I.useConfig(props.config);
couponLoginContext = await I.registerOrLogin(couponLoginContext);

await cancelPlan(I, addYear(today), props.canRenewSubscription, providerName);
});

Scenario(`I can renew a free subscription - ${providerName}`, async ({ I }) => {
I.useConfig(props.config);
couponLoginContext = await I.registerOrLogin(couponLoginContext);

if (props.canRenewSubscription) {
renewPlan(I, addYear(today), props.yearlyOffer.price);
} else {
Expand Down
Loading
Loading