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

feat: Programmatically determine when links should open in new tabs #1100

Open
wants to merge 23 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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 Dec 20, 2024
39456a2
[test] Unit: AdditionalResources - Add <AuthProvider> now that our SB…
meissadia Dec 30, 2024
464cddb
[e2e] Refactor to add support to test links that open in new tab
meissadia Dec 31, 2024
c279f2d
[e2e] Verify link targets: Unauthenticated homepage
meissadia Dec 31, 2024
0f647cd
[e2e] Verify link targets: Complete your user profile
meissadia Dec 31, 2024
15e6714
[e2e] Verify link targets: Authenticated landing page
meissadia Dec 31, 2024
4e3ac70
[e2e] Verify link targets: View your user profile
meissadia Dec 31, 2024
670f920
[e2e] Verify link targets: Update your financial institution profile
meissadia Jan 2, 2025
a95c949
[e2e] Verify link targets: Filing home - Start filing
meissadia Jan 2, 2025
406e85d
[e2e] Verify link targets: Upload file
meissadia Jan 2, 2025
5f946ee
[e2e] Verify link targets: Logic errors
meissadia Jan 2, 2025
21b667a
[e2e] Verify link targets: Syntax errors
meissadia Jan 2, 2025
9c0e191
[e2e] Verify link targets: Warnings
meissadia Jan 2, 2025
25e0203
[e2e] Verify link targets: Provide filing details
meissadia Jan 2, 2025
5ad2913
[e2e] Verify link targets: Sign and submit
meissadia Jan 3, 2025
a654cd0
[e2e] Verify link targets: Provide type of financial institution
meissadia Jan 3, 2025
242899e
[e2e] task: Major refactor to reduce code duplication
meissadia Jan 7, 2025
d278783
[e2e] fix: duplicated "expect"
meissadia Jan 7, 2025
797eb87
[e2e] task: Clarify goal of testing tasks
meissadia Jan 7, 2025
9782e61
e2e: Confirm title on InstitutionCards for each filing step
meissadia Jan 14, 2025
332b86b
e2e: Update test title to improve searchability
meissadia Jan 14, 2025
3d8e2bc
task: [Link] Update comments to help our future selves understand the…
meissadia Jan 14, 2025
c97b881
Merge branch 'main' into when-to-open-links-in-new-tab
meissadia Jan 16, 2025
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
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 e2e/pages/filing-app/filing-home/VerifyLinkTargets.spec.ts
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
Copy link
Contributor

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.

Screenshot 2025-01-14 at 9 51 59 AM

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Validations added: commit

* */

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);
});
45 changes: 45 additions & 0 deletions e2e/pages/filing-app/filing-step-routing/errorsLogic.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
import { expect } from '@playwright/test';
import { test } from '../../../fixtures/testFixture';
import {
expectLinkOpensNewTab,
expectLinkOpensSameTab,
} from '../../../utils/openLink';
import { checkSnapshot } from '../../../utils/snapshotTesting';
import {
SelectorLinkText,
expectAll,
expectLogoutButtonVisible,
selectAllNavLinks,
selectLink,
} from '../../../utils/verifyLinkTargets';
import { verifyRedirects } from './_shared';

const testLabel = 'Filing step routing (Errors: Logic)';
Expand Down Expand Up @@ -28,3 +40,36 @@ test(
await checkSnapshot(page);
},
);

test('Verify link targets (Errors: Logic)', async ({
page,
navigateToLogicErrorsAfterLogicErrorsUpload,
}) => {
navigateToLogicErrorsAfterLogicErrorsUpload;

// Same tab
const navlinks = await selectAllNavLinks(page);
expect(navlinks.length).toEqual(3);
await expectAll(navlinks, expectLinkOpensSameTab);

await expectLogoutButtonVisible(page);

const uploadNewFile = selectLink(page, SelectorLinkText.upload.aNewFile);
await expectLinkOpensSameTab(uploadNewFile);

// New tab
const figErrorDefinitions = await page
.locator('.validation-info-section a')
.all();
for (const figPage of figErrorDefinitions) {
// eslint-disable-next-line no-await-in-loop
meissadia marked this conversation as resolved.
Show resolved Hide resolved
const errorLabel = await figPage.textContent();
// eslint-disable-next-line no-await-in-loop
await test.step(`FIG error description link opens new tab: ${errorLabel}`, async () => {
await expectLinkOpensNewTab(figPage);
});
}

const figDataValidation = selectLink(page, SelectorLinkText.fig.section4);
await expectLinkOpensNewTab(figDataValidation);
});
45 changes: 45 additions & 0 deletions e2e/pages/filing-app/filing-step-routing/errorsSyntax.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
import { expect } from '@playwright/test';
import { test } from '../../../fixtures/testFixture';
import {
expectLinkOpensNewTab,
expectLinkOpensSameTab,
} from '../../../utils/openLink';
import { checkSnapshot } from '../../../utils/snapshotTesting';
import {
SelectorLinkText,
expectAll,
expectLogoutButtonVisible,
selectAllNavLinks,
selectLink,
} from '../../../utils/verifyLinkTargets';
import { verifyRedirects } from './_shared';

const testLabel = 'Filing step routing (Errors: Syntax)';
Expand Down Expand Up @@ -33,3 +45,36 @@ test(
await checkSnapshot(page);
},
);

test('Verify link targets (Errors: Syntax)', async ({
page,
navigateToSyntaxErrorsAfterSyntaxErrorsUpload,
}) => {
navigateToSyntaxErrorsAfterSyntaxErrorsUpload;

// Same tab
const navlinks = await selectAllNavLinks(page);
expect(navlinks.length).toEqual(3);
await expectAll(navlinks, expectLinkOpensSameTab);

await expectLogoutButtonVisible(page);

const uploadNewFile = selectLink(page, SelectorLinkText.upload.aNewFile);
await expectLinkOpensSameTab(uploadNewFile);

// New tab
const figErrorDefinitions = await page
.locator('.validation-info-section a')
.all();
for (const figPage of figErrorDefinitions) {
// eslint-disable-next-line no-await-in-loop
const errorLabel = await figPage.textContent();
// eslint-disable-next-line no-await-in-loop
await test.step(`FIG error description link opens new tab: ${errorLabel}`, async () => {
await expectLinkOpensNewTab(figPage);
});
}

const figDataValidation = selectLink(page, SelectorLinkText.fig.section4);
await expectLinkOpensNewTab(figDataValidation);
});
41 changes: 41 additions & 0 deletions e2e/pages/filing-app/filing-step-routing/pointOfContact.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
import { expect } from '@playwright/test';
import { test } from '../../../fixtures/testFixture';
import {
expectLinkOpensNewTab,
expectLinkOpensSameTab,
} from '../../../utils/openLink';
import { checkSnapshot } from '../../../utils/snapshotTesting';
import {
SelectorLinkText,
expectAll,
expectLogoutButtonVisible,
selectAllNavLinks,
selectLink,
} from '../../../utils/verifyLinkTargets';
import { verifyRedirects } from './_shared';

const testLabel = 'Filing step routing (Point of Contact)';
Expand All @@ -25,3 +37,32 @@ test(testLabel, async ({ page, navigateToProvideFilingDetails }) => {
});
await checkSnapshot(page);
});

test('Verify link targets (Provide filing details)', async ({
page,
navigateToProvideFilingDetails,
}) => {
navigateToProvideFilingDetails;

// Same tab
const navlinks = await selectAllNavLinks(page);
expect(navlinks.length).toEqual(3);
await expectAll(navlinks, expectLinkOpensSameTab);

await expectLogoutButtonVisible(page);

// New tab
const indexRegLinks = await page.locator('a:has-text("§")').all();

for (const indexRegPage of indexRegLinks) {
// eslint-disable-next-line no-await-in-loop
const title = await indexRegPage.textContent();
// eslint-disable-next-line no-await-in-loop
await test.step(`iRegs link opens new tab: ${title}`, async () => {
await expectLinkOpensNewTab(indexRegPage);
});
}

const privacyNotice = selectLink(page, SelectorLinkText.privacyNotice);
await expectLinkOpensNewTab(privacyNotice);
});
Loading
Loading