generated from cfpb/open-source-project-template
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[e2e] Verify users cannot skip Filing steps (#989)
Closes #980 Verify that, from a given step in the Filing process, a user is prevented from accessing future Filing steps.
- Loading branch information
Showing
7 changed files
with
261 additions
and
0 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
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,39 @@ | ||
/* eslint-disable no-await-in-loop */ | ||
|
||
import type { Page } from '@playwright/test'; | ||
import { expect } from '@playwright/test'; | ||
import type { test } from '../../../fixtures/testFixture'; | ||
|
||
interface VerifyRedirects { | ||
page: Page; | ||
userShouldNotAccess: string[]; // List of paths that a user should not be able to access | ||
afterRedirectURL: RegExp; // RegExp that matches the URL a user should land on after redirect | ||
afterRedirectHeading: string; // H1 text a user should see after redirect | ||
currentStepPath: string; // A string at which to split the URL while preserving the LEI | ||
testLabel: string; // Label displayed in the Playwright logs | ||
test: typeof test; | ||
} | ||
|
||
/** | ||
* Ensure that, from the current Filing step, users cannot inappropriately access future steps. | ||
*/ | ||
export const verifyRedirects = async ({ | ||
page, | ||
test, | ||
userShouldNotAccess, | ||
afterRedirectURL, | ||
afterRedirectHeading, | ||
currentStepPath, | ||
testLabel, | ||
}: VerifyRedirects) => { | ||
const [baseURL] = page.url().split(currentStepPath); | ||
|
||
// Note: Tests failed when using Promise.all in place of this loop approach | ||
for (const futureStep of userShouldNotAccess) { | ||
await test.step(`${testLabel}: Verify user cannot access ${futureStep}`, async () => { | ||
await page.goto(baseURL + futureStep); | ||
await expect(page).toHaveURL(afterRedirectURL, { timeout: 10_000 }); | ||
await expect(page.locator('h1')).toContainText(afterRedirectHeading); | ||
}); | ||
} | ||
}; |
30 changes: 30 additions & 0 deletions
30
e2e/pages/filing-app/filing-step-routing/errorsLogic.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,30 @@ | ||
import { test } from '../../../fixtures/testFixture'; | ||
import { verifyRedirects } from './_shared'; | ||
|
||
const testLabel = 'Filing step routing (Errors: Logic)'; | ||
|
||
const currentStepPath = '/error'; | ||
|
||
const userShouldNotAccess = ['/warnings', '/contact', '/submit']; | ||
|
||
const afterRedirectHeading = 'Resolve errors (syntax)'; | ||
const afterRedirectURL = /.*errors\/errors-syntax$/; | ||
|
||
test( | ||
testLabel, | ||
async ({ page, navigateToLogicErrorsAfterLogicErrorsUpload }) => { | ||
test.slow(); | ||
|
||
navigateToLogicErrorsAfterLogicErrorsUpload; | ||
|
||
await verifyRedirects({ | ||
afterRedirectHeading, | ||
afterRedirectURL, | ||
currentStepPath, | ||
page, | ||
test, | ||
testLabel, | ||
userShouldNotAccess, | ||
}); | ||
}, | ||
); |
35 changes: 35 additions & 0 deletions
35
e2e/pages/filing-app/filing-step-routing/errorsSyntax.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,35 @@ | ||
import { test } from '../../../fixtures/testFixture'; | ||
import { verifyRedirects } from './_shared'; | ||
|
||
const testLabel = 'Filing step routing (Errors: Syntax)'; | ||
|
||
const currentStepPath = '/error'; | ||
|
||
const userShouldNotAccess = [ | ||
'/errors/errors-logic', | ||
'/warnings', | ||
'/contact', | ||
'/submit', | ||
]; | ||
|
||
const afterRedirectHeading = 'Resolve errors (syntax)'; | ||
const afterRedirectURL = /.*errors\/errors-syntax$/; | ||
|
||
test( | ||
testLabel, | ||
async ({ page, navigateToSyntaxErrorsAfterSyntaxErrorsUpload }) => { | ||
test.slow(); | ||
|
||
navigateToSyntaxErrorsAfterSyntaxErrorsUpload; | ||
|
||
await verifyRedirects({ | ||
afterRedirectHeading, | ||
afterRedirectURL, | ||
currentStepPath, | ||
page, | ||
test, | ||
testLabel, | ||
userShouldNotAccess, | ||
}); | ||
}, | ||
); |
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,27 @@ | ||
import { test } from '../../../fixtures/testFixture'; | ||
import { verifyRedirects } from './_shared'; | ||
|
||
const testLabel = 'Filing step routing (Upload)'; | ||
|
||
const currentStepPath = '/upload'; | ||
|
||
const userShouldNotAccess = ['/errors', '/warnings', '/contact', '/submit']; | ||
|
||
const afterRedirectHeading = 'Upload file'; | ||
const afterRedirectURL = /.*\/upload$/; | ||
|
||
test(testLabel, async ({ page, navigateToUploadFile }) => { | ||
test.slow(); | ||
|
||
navigateToUploadFile; | ||
|
||
await verifyRedirects({ | ||
afterRedirectHeading, | ||
afterRedirectURL, | ||
currentStepPath, | ||
page, | ||
test, | ||
testLabel, | ||
userShouldNotAccess, | ||
}); | ||
}); |
27 changes: 27 additions & 0 deletions
27
e2e/pages/filing-app/filing-step-routing/pointOfContact.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,27 @@ | ||
import { test } from '../../../fixtures/testFixture'; | ||
import { verifyRedirects } from './_shared'; | ||
|
||
const testLabel = 'Filing step routing (Point of Contact)'; | ||
|
||
const currentStepPath = '/contact'; | ||
|
||
const userShouldNotAccess = ['/submit']; | ||
|
||
const afterRedirectHeading = 'Provide point of contact'; | ||
const afterRedirectURL = /.*\/contact$/; | ||
|
||
test(testLabel, async ({ page, navigateToProvidePointOfContact }) => { | ||
test.slow(); | ||
|
||
navigateToProvidePointOfContact; | ||
|
||
await verifyRedirects({ | ||
testLabel, | ||
currentStepPath, | ||
userShouldNotAccess, | ||
afterRedirectHeading, | ||
afterRedirectURL, | ||
page, | ||
test, | ||
}); | ||
}); |
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,30 @@ | ||
import { test } from '../../../fixtures/testFixture'; | ||
import { verifyRedirects } from './_shared'; | ||
|
||
const testLabel = 'Filing step routing (Warnings)'; | ||
|
||
const currentStepPath = '/warnings'; | ||
|
||
const userShouldNotAccess = ['/contact', '/submit']; | ||
|
||
const afterRedirectHeading = 'Review warnings'; | ||
const afterRedirectURL = /.*\/warnings$/; | ||
|
||
test( | ||
testLabel, | ||
async ({ page, navigateToReviewWarningsAfterOnlyWarningsUpload }) => { | ||
test.slow(); | ||
|
||
navigateToReviewWarningsAfterOnlyWarningsUpload; | ||
|
||
await verifyRedirects({ | ||
afterRedirectHeading, | ||
afterRedirectURL, | ||
currentStepPath, | ||
page, | ||
test, | ||
testLabel, | ||
userShouldNotAccess, | ||
}); | ||
}, | ||
); |