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.
feat: Programmatically determine when links should open in new tabs (#…
…1100) Closes #1071 ## Changes - New hook `useIsNewTabImplied` that determines when links should open in new tabs - Codifies logic outlined in cfpb/sbl-project#295 - Update test utilities: - Rename to clarify their intent (`openLink`, `openLinkNewTab`) - New helpers (`expectLinkOpensSameTab`, `expectLinkOpensNewTab`) - Add E2E tests to verify link targets on each page - Unauthenticated homepage - Complete your user profile - Authenticated landing page - View your user profile - View your financial institution profile - Updated your financial institution profile - Filing home for each filing step - Start filing - Resolve syntax errors - Resolve logic errors - Review warnings - Provide filing details - Sign and Submit - Filing homepage for each step of the Filing process - Provide type of financial institution - Upload file - Resolve syntax errors - Resolve logic errors - Review warnings - Provide filing details - Sign and submit
- Loading branch information
Showing
25 changed files
with
1,061 additions
and
94 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
e2e/pages/filing-app/complete-user-profile/VerifyLinkTargets.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,25 @@ | ||
import { test } from '../../../fixtures/testFixture'; | ||
import { expectLinkOpensSameTab } from '../../../utils/openLink'; | ||
import { | ||
SelectorLinkText, | ||
expectAll, | ||
selectCrumbtrailLink, | ||
selectLinks, | ||
} from '../../../utils/verifyLinkTargets'; | ||
|
||
test('Complete user profile: Verify link targets', async ({ page }) => { | ||
const unauthenticatedHome = selectCrumbtrailLink( | ||
page, | ||
SelectorLinkText.crumbtrail.home, | ||
); | ||
|
||
const linksByText = selectLinks(page, [ | ||
SelectorLinkText.gleif.long, | ||
SelectorLinkText.privacyNotice, | ||
]); | ||
|
||
await expectAll( | ||
[unauthenticatedHome, ...linksByText], | ||
expectLinkOpensSameTab, | ||
); | ||
}); |
169 changes: 169 additions & 0 deletions
169
e2e/pages/filing-app/filing-home/VerifyLinkTargets.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,169 @@ | ||
import type { Page } from '@playwright/test'; | ||
import { expect } from '@playwright/test'; | ||
import { InstitutionCardTitle } from 'pages/Filing/FilingApp/InstitutionCard.helpers'; | ||
import { test } from '../../../fixtures/testFixture'; | ||
import { expectLinkOpensNewTab } from '../../../utils/openLink'; | ||
import { | ||
SelectorLinkText, | ||
expectAll, | ||
selectLinks, | ||
} from '../../../utils/verifyLinkTargets'; | ||
|
||
/** | ||
* Helpers | ||
* */ | ||
|
||
// Verify a button with the given label is visible | ||
const expectButtonVisible = async (page: Page, name: string) => { | ||
const button = page.getByRole('button', { name }); | ||
await expect(button).toBeVisible(); | ||
}; | ||
|
||
// Labels for primary home page actions | ||
const ActionLabel = { | ||
startFiling: 'Start filing', | ||
continueFiling: 'Continue filing', | ||
}; | ||
|
||
// Verify we've navigated to the Filing homepage | ||
const gotoFilingHome = async (page: Page) => { | ||
await page.goto('/filing'); | ||
|
||
await expect(page.locator('h1')).toContainText( | ||
'File your small business lending data', | ||
); | ||
}; | ||
|
||
/** | ||
* Tests - Verify the state of the Filing homepage at each stage of the Filing process | ||
* */ | ||
|
||
test('Start filing', async ({ page, navigateToFilingHome }) => { | ||
navigateToFilingHome; | ||
|
||
await expect(page.getByText(InstitutionCardTitle.start)).toBeVisible(); | ||
|
||
const links = selectLinks(page, [ | ||
SelectorLinkText.fig.long, | ||
SelectorLinkText.fig.readAboutFiling, | ||
]); | ||
|
||
await expectAll(links, expectLinkOpensNewTab); | ||
|
||
await expectButtonVisible(page, ActionLabel.startFiling); | ||
}); | ||
|
||
test('Provide type of financial institution', async ({ | ||
page, | ||
navigateToProvideTypeOfFinancialInstitution, | ||
}) => { | ||
navigateToProvideTypeOfFinancialInstitution; | ||
await gotoFilingHome(page); | ||
|
||
await expect(page.getByText(InstitutionCardTitle.start)).toBeVisible(); | ||
|
||
const links = selectLinks(page, [ | ||
SelectorLinkText.fig.long, | ||
SelectorLinkText.fig.readAboutFiling, | ||
]); | ||
|
||
await expectAll(links, expectLinkOpensNewTab); | ||
}); | ||
|
||
test('Upload file', async ({ page, navigateToUploadFile }) => { | ||
navigateToUploadFile; | ||
await gotoFilingHome(page); | ||
|
||
await expect(page.getByText(InstitutionCardTitle.upload)).toBeVisible(); | ||
await expectButtonVisible(page, ActionLabel.continueFiling); | ||
|
||
const links = selectLinks(page, [ | ||
SelectorLinkText.fig.long, | ||
SelectorLinkText.fig.readAboutFiling, | ||
]); | ||
|
||
await expectAll(links, expectLinkOpensNewTab); | ||
}); | ||
|
||
test('Logic errors', async ({ | ||
page, | ||
navigateToLogicErrorsAfterLogicErrorsUpload, | ||
}) => { | ||
navigateToLogicErrorsAfterLogicErrorsUpload; | ||
await gotoFilingHome(page); | ||
|
||
await expect(page.getByText(InstitutionCardTitle.errors)).toBeVisible(); | ||
await expectButtonVisible(page, ActionLabel.continueFiling); | ||
|
||
const links = selectLinks(page, [ | ||
SelectorLinkText.fig.long, | ||
SelectorLinkText.fig.readAboutValidations, | ||
]); | ||
|
||
await expectAll(links, expectLinkOpensNewTab); | ||
}); | ||
|
||
test('Syntax errors', async ({ | ||
page, | ||
navigateToSyntaxErrorsAfterSyntaxErrorsUpload, | ||
}) => { | ||
navigateToSyntaxErrorsAfterSyntaxErrorsUpload; | ||
await gotoFilingHome(page); | ||
|
||
await expect(page.getByText(InstitutionCardTitle.errors)).toBeVisible(); | ||
await expectButtonVisible(page, ActionLabel.continueFiling); | ||
|
||
const links = selectLinks(page, [ | ||
SelectorLinkText.fig.long, | ||
SelectorLinkText.fig.readAboutValidations, | ||
]); | ||
|
||
await expectAll(links, expectLinkOpensNewTab); | ||
}); | ||
|
||
test('Warnings', async ({ | ||
page, | ||
navigateToReviewWarningsAfterOnlyWarningsUpload, | ||
}) => { | ||
navigateToReviewWarningsAfterOnlyWarningsUpload; | ||
await gotoFilingHome(page); | ||
|
||
await expect(page.getByText(InstitutionCardTitle.warnings)).toBeVisible(); | ||
await expectButtonVisible(page, ActionLabel.continueFiling); | ||
|
||
const links = selectLinks(page, [ | ||
SelectorLinkText.fig.long, | ||
SelectorLinkText.fig.readAboutValidations, | ||
]); | ||
|
||
await expectAll(links, expectLinkOpensNewTab); | ||
}); | ||
|
||
test('Provide filing details', async ({ | ||
page, | ||
navigateToProvideFilingDetails, | ||
}) => { | ||
navigateToProvideFilingDetails; | ||
await gotoFilingHome(page); | ||
|
||
await expect( | ||
page.getByText(InstitutionCardTitle.provideDetails), | ||
).toBeVisible(); | ||
await expectButtonVisible(page, ActionLabel.continueFiling); | ||
|
||
const links = selectLinks(page, [SelectorLinkText.fig.long]); | ||
|
||
await expectAll(links, expectLinkOpensNewTab); | ||
}); | ||
|
||
test('Sign and submit', async ({ page, navigateToSignAndSubmit }) => { | ||
navigateToSignAndSubmit; | ||
await gotoFilingHome(page); | ||
|
||
await expect(page.getByText(InstitutionCardTitle.signSubmit)).toBeVisible(); | ||
await expectButtonVisible(page, ActionLabel.continueFiling); | ||
|
||
const links = selectLinks(page, [SelectorLinkText.fig.long]); | ||
|
||
await expectAll(links, expectLinkOpensNewTab); | ||
}); |
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
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.