-
Notifications
You must be signed in to change notification settings - Fork 54
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
ChristiaanScheermeijer
wants to merge
2
commits into
develop
Choose a base branch
from
fix/e2e-overlapping-reports-fix
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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) { | ||
// eslint-disable-next-line react-hooks/rules-of-hooks | ||
I.useConfig(config); | ||
|
||
loginContext = await I.registerOrLogin(loginContext, () => { | ||
|
@@ -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(); | ||
|
||
|
@@ -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!?' }, | ||
|
@@ -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, | ||
|
@@ -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, | ||
|
@@ -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'); | ||
|
@@ -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'); | ||
|
@@ -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, | ||
|
@@ -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, | ||
|
@@ -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, | ||
|
@@ -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, | ||
|
@@ -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); | ||
|
@@ -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, [ | ||
|
@@ -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}"]`); | ||
|
@@ -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); | ||
|
||
|
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 |
---|---|---|
|
@@ -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'); | ||
|
@@ -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'); | ||
|
||
|
@@ -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'); | ||
|
||
|
@@ -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'); | ||
|
||
|
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
Oops, something went wrong.
Oops, something went wrong.
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.
Does it not work to just move the
Before
to the top level where you movedFeature
? This seems like an otherwise nice, simple enough fix, but I wish we didn't need to copy all theawait beforeScenario
calls. Seems too easy to forget to add when you create a new Scenario.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.
Oh I see, Before depends on the runTestSuite args...
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.
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.