generated from cfpb/open-source-project-template
-
Notifications
You must be signed in to change notification settings - Fork 1
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
feat: Programmatically determine when links should open in new tabs #1100
Open
meissadia
wants to merge
23
commits into
main
Choose a base branch
from
when-to-open-links-in-new-tab
base: main
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
23 commits
Select commit
Hold shift + click to select a range
e2c6403
feat: Programmatically determine when links should open in new tabs
meissadia 39456a2
[test] Unit: AdditionalResources - Add <AuthProvider> now that our SB…
meissadia 464cddb
[e2e] Refactor to add support to test links that open in new tab
meissadia c279f2d
[e2e] Verify link targets: Unauthenticated homepage
meissadia 0f647cd
[e2e] Verify link targets: Complete your user profile
meissadia 15e6714
[e2e] Verify link targets: Authenticated landing page
meissadia 4e3ac70
[e2e] Verify link targets: View your user profile
meissadia 670f920
[e2e] Verify link targets: Update your financial institution profile
meissadia a95c949
[e2e] Verify link targets: Filing home - Start filing
meissadia 406e85d
[e2e] Verify link targets: Upload file
meissadia 5f946ee
[e2e] Verify link targets: Logic errors
meissadia 21b667a
[e2e] Verify link targets: Syntax errors
meissadia 9c0e191
[e2e] Verify link targets: Warnings
meissadia 25e0203
[e2e] Verify link targets: Provide filing details
meissadia 5ad2913
[e2e] Verify link targets: Sign and submit
meissadia a654cd0
[e2e] Verify link targets: Provide type of financial institution
meissadia 242899e
[e2e] task: Major refactor to reduce code duplication
meissadia d278783
[e2e] fix: duplicated "expect"
meissadia 797eb87
[e2e] task: Clarify goal of testing tasks
meissadia 9782e61
e2e: Confirm title on InstitutionCards for each filing step
meissadia 332b86b
e2e: Update test title to improve searchability
meissadia 3d8e2bc
task: [Link] Update comments to help our future selves understand the…
meissadia c97b881
Merge branch 'main' into when-to-open-links-in-new-tab
meissadia 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
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.
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.
Very thorough @meissadia and I super appreciate checking out all these card links!
Could you do me a favor, and while we're here, can we confirm the heading text on the card for these different states? Good way of confirming you're in the state you're expecting for each of these cards, and I'd be great to have some coverage on that.
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.
Validations added: commit