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

[Snapshot testing - Part 3] Shared lending platform #1087

Merged
merged 37 commits into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
2e13c5f
feat: [Playwright] Support running of snapshot tests via environment …
meissadia Dec 4, 2024
9353393
task: [Playwright] Centralize check for running/skipping snapshot tes…
meissadia Dec 4, 2024
86716bb
task: [Snapshot test] Complete user profile form
meissadia Dec 4, 2024
035db97
feat: [Playwright] Support running of snapshot tests via environment …
meissadia Dec 4, 2024
22cd9bc
task: [Playwright] Centralize check for running/skipping snapshot tes…
meissadia Dec 4, 2024
4481f39
task: [Snapshot test] Complete user profile form
meissadia Dec 4, 2024
60bf075
Merge branch 'main' into 1062-snapshot__complete-user-profile
meissadia Dec 4, 2024
5b9118c
task: Update Vite environment with new ENV variable for snapshot testing
meissadia Dec 4, 2024
5fb6a2a
task: Snapshot testing - adjust default maxDiffPixels
meissadia Dec 6, 2024
ef07a8d
task: Snapshot testing - Use a more generalized masking approach (add…
meissadia Dec 6, 2024
f861537
Merge branch 'main' into 1062-snapshot__complete-user-profile
meissadia Dec 6, 2024
2e7206b
task: [Snapshot test] Filing details
meissadia Dec 6, 2024
8e2ca8f
Merge branch 'main' into 1062-snapshot__filing-details
meissadia Dec 9, 2024
3cb6713
task: [Github] Add new environment variable - SBL_ENABLE_PLAYWRIGHT_S…
meissadia Dec 9, 2024
7ad6de8
task: [Snapshot test] Filing step routing
meissadia Dec 6, 2024
d9d0b0f
task: [Snapshot test] Filing - Sign and submit
meissadia Dec 6, 2024
268d387
task: [Snapshot test - Part 5] Filing - Upload file
meissadia Dec 9, 2024
b882c9b
task: [Snapshot test - Part 6] Filing - Form alerts
meissadia Dec 9, 2024
34722c1
task: [Snapshot test - Part 7] Filing - Unavailable APIs
meissadia Dec 9, 2024
40787ae
task: [Snapshot test - Part 8] Shared Lending Platform - User Profile
meissadia Dec 9, 2024
cf4c71f
task: [Snapshot test - Part 9] Shared Lending Platform - Institution …
meissadia Dec 9, 2024
3ec943d
Merge branch 'main' into 1062-snapshot__filing-details
meissadia Dec 10, 2024
93349a6
Merge branch 'main' into 1062-snapshot__filing-details
meissadia Dec 11, 2024
d0b600d
Merge branch '1062-snapshot__3-filing-step-routing' into 1062-snapsho…
meissadia Dec 11, 2024
828aa30
Merge branch '1062-snapshot__4-sign-and-submit' into 1062-snapshot__f…
meissadia Dec 11, 2024
f29a124
Merge branch '1062-snapshot__5-upload-file' into 1062-snapshot__filin…
meissadia Dec 11, 2024
7de93c0
Merge branch '1062-snapshot__6-formAlerts' into 1062-snapshot__filing…
meissadia Dec 11, 2024
91c436c
Merge branch '1062-snapshot__7-blocked-apis' into 1062-snapshot__fili…
meissadia Dec 11, 2024
5cff835
Merge branch '1062-snapshot__8-user-profile' into 1062-snapshot__shar…
meissadia Dec 11, 2024
45a7f7e
Merge branch '1062-snapshot__9-institution-profile' into 1062-snapsho…
meissadia Dec 11, 2024
1ce0432
task: [Snapshot test - Part 10] Shared Lending Platform - Navigation
meissadia Dec 11, 2024
eb0d081
task: [Snapshot test - Part 11] Shared Lending Platform - Non-associa…
meissadia Dec 11, 2024
da5cb75
task: [Snapshot test - Part 12] Shared Lending Platform - Unauthentic…
meissadia Dec 11, 2024
9d45947
task: [Snapshot test - Part 13] Shared Lending Platform - Update inst…
meissadia Dec 11, 2024
233074b
feat: [Snapshot testing] Script to easily update snapshots
meissadia Dec 12, 2024
4e819c1
Merge branch 'main' into 1062-snapshot__shared-lending-platform
meissadia Dec 12, 2024
e49552d
Merge branch 'main' into 1062-snapshot__shared-lending-platform
meissadia Dec 19, 2024
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
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ If you'll be using VS Code, be sure to:
- `yarn test:ci` - run all unit and integration tests in CI mode
- `yarn test:e2e` - run all e2e tests with Playwright UI mode.
- `yarn test:e2e:headless` - run all e2e tests headlessly.
- `yarn test:e2e:snapshot` - run all e2e tests with snapshot testing.
- `yarn test:e2e:snapshot-update` - update all snapshots.
- `yarn test:e2e:snapshot-update <TEST_PATH>` - update snapshots for specific tests. Example: `yarn test:e2e:snapshot-update e2e/pages/shared-lending-platform/UserProfile*`
- `yarn format` - format all files with Prettier.
- `yarn lint` - runs TypeScript, ESLint and Stylelint.
- `yarn validate` - runs `lint`, `test:ci` and `test:e2e`.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { expect } from '@playwright/test';
import { test } from '../../fixtures/testFixture';
import { clickLinkWithRetry } from '../../utils/clickExternalLinkWithRetry';
import { checkSnapshot } from '../../utils/snapshotTesting';

test('Institution Profile Page', async ({ page, navigateToFilingHome }) => {
// Go to Profile page
Expand All @@ -20,6 +21,7 @@ test('Institution Profile Page', async ({ page, navigateToFilingHome }) => {
await expect(page.locator('h1'), 'h1 is correct').toContainText(
'View your financial institution profile',
);
await checkSnapshot(page);
});

// Check Detail Headings
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions e2e/pages/shared-lending-platform/Navigation.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { expect } from '@playwright/test';
import { test } from '../../fixtures/testFixture';
import { clickLinkWithRetry } from '../../utils/clickExternalLinkWithRetry';
import { checkSnapshot } from '../../utils/snapshotTesting';

// Note: Skipped snapshot tests for pages outside of the SBL site

test('Navigation', async ({ page, navigateToFilingHome }) => {
navigateToFilingHome;
Expand All @@ -14,20 +17,23 @@ test('Navigation', async ({ page, navigateToFilingHome }) => {
await expect(page.locator('h1')).toContainText(
'File your small business lending data',
);
await checkSnapshot(page);

// Test Home Link
await page
.locator('.navbar .links')
.getByRole('link', { name: 'Home', exact: false })
.click();
await expect(page.locator('h1')).toContainText('File your lending data');
await checkSnapshot(page);

// Test Profile Link
await page
.locator('.navbar .links')
.getByRole('link', { name: 'Playwright Test User' })
.click();
await expect(page.locator('h1')).toContainText('View your user profile');
await checkSnapshot(page);
});

await test.step('Breadcrumb Navigation', async () => {
Expand All @@ -38,6 +44,7 @@ test('Navigation', async ({ page, navigateToFilingHome }) => {
await expect(page.locator('h1')).toContainText(
'View your financial institution profile',
);
await checkSnapshot(page);
await page
.getByRole('link', {
name: 'Update your financial institution profile',
Expand All @@ -47,6 +54,7 @@ test('Navigation', async ({ page, navigateToFilingHome }) => {
await expect(page.locator('h1')).toContainText(
'Update your financial institution profile',
);
await checkSnapshot(page);
await page
.getByRole('link', { name: 'View your financial institution profile' })
.click();
Expand Down Expand Up @@ -244,6 +252,7 @@ test('Navigation', async ({ page, navigateToFilingHome }) => {
'Get started filing your lending data',
);
await expect(page.locator('.navbar .nav-items')).toHaveCount(0);
await checkSnapshot(page);

// Test CFPB Logo Link
await clickLinkWithRetry({ page, target: page.getByLabel('Home') });
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { expect } from '@playwright/test';
import { DefaultInputCharLimit, LeiInputCharLimit } from 'utils/constants';
import { test } from '../../fixtures/testFixture';
import { controlUnicode } from '../../utils/unicodeConstants';
import { assertTextInput } from '../../utils/inputValidators';
import { DefaultInputCharLimit, LeiInputCharLimit } from 'utils/constants';
import { checkSnapshot } from '../../utils/snapshotTesting';
import { controlUnicode } from '../../utils/unicodeConstants';

const expectedNoAssociationsSummaryUrl =
/\/profile\/complete\/summary\/submitted$/;
Expand Down Expand Up @@ -38,11 +39,13 @@ test('Complete User Profile -- No Associations -- process', async ({
await page
.getByLabel('Legal Entity Identifier (LEI)')
.fill('12345678901234567890');
await checkSnapshot(page);
await page.getByLabel('Submit User Profile').click();

// redirected to the summary page
await expect(page).toHaveURL(expectedNoAssociationsSummaryUrl);
await expect(page.locator('#Summary div').first()).toBeVisible();
await checkSnapshot(page);
});
});

Expand Down Expand Up @@ -83,5 +86,6 @@ test('Complete User Profile with Bad Unicode -- No Associations -- process', asy
expected: expectedValues.leiField,
unexpected: unexpectedValues.leiField,
});
await checkSnapshot(page);
});
});
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { expect } from '@playwright/test';
import { test } from '../../fixtures/testFixture';
import { DefaultInputCharLimit } from 'utils/constants';
import { test } from '../../fixtures/testFixture';
import { assertTextInput } from '../../utils/inputValidators';
import { checkSnapshot } from '../../utils/snapshotTesting';
import { controlUnicode } from '../../utils/unicodeConstants';

test('Update Institution Profile Page', async ({
Expand All @@ -20,6 +21,7 @@ test('Update Institution Profile Page', async ({
.getByRole('link', { name: 'RegTech Regional Reserve - ' })
.click();
});
await checkSnapshot(page);
});

// Institution Profile page
Expand All @@ -35,6 +37,7 @@ test('Update Institution Profile Page', async ({
.first()
.click();
});
await checkSnapshot(page);
});

// Update Institution Profile page
Expand Down Expand Up @@ -151,6 +154,8 @@ test('Update Institution Profile Page', async ({
page.locator('#top_holder_rssd_id'),
'Top-Holder RSSD is editable',
).toBeEditable();

await checkSnapshot(page);
});

// Reset Form
Expand All @@ -160,6 +165,8 @@ test('Update Institution Profile Page', async ({
page.getByLabel('You must enter a type of'),
'Other field reset',
).not.toBeEnabled();

await checkSnapshot(page);
});

// Add Other (again)
Expand Down Expand Up @@ -190,6 +197,8 @@ test('Update Institution Profile Page', async ({
'mailto:[email protected]?subject=[BETA] Update your financial institution profile: Questions after submitting form',
);
});

await checkSnapshot(page);
});
});

Expand Down Expand Up @@ -295,5 +304,7 @@ test('Update Institution Profile Page: Check Character Limits', async ({
expected: expectedValues.topRssdField,
unexpected: unexpectedValues.topRssdField,
});

await checkSnapshot(page);
});
});
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions e2e/pages/shared-lending-platform/UserProfile.spec.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import { expect } from '@playwright/test';
import { test } from '../../fixtures/testFixture';
import { checkSnapshot } from '../../utils/snapshotTesting';

test('User Profile Page', async ({ page, navigateToFilingHome }) => {
// Go to Profile page
await test.step('H1 Heading', async () => {
navigateToFilingHome;
await page.goto('/profile/view');
await expect(page.locator('h1')).toContainText('View your user profile');
await checkSnapshot(page);
});

await test.step('Verify nav options', async () => {
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { expect, test } from '@playwright/test';
import { webcrypto } from 'node:crypto';
import { checkSnapshot } from '../../../utils/snapshotTesting';

// this is just an example test (e2e tests should be way longer than this)
test('Unauthenticated homepage: Registering with an invalid email domain', async ({
Expand Down Expand Up @@ -37,6 +38,7 @@ test('Unauthenticated homepage: Registering with an invalid email domain', async
await expect(page.getByRole('heading')).toContainText(
'Your email domain is not authorized',
);
await checkSnapshot(page);
await expect(page.locator('#Summary div').first()).toBeVisible();
});
});
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { expect, test } from '@playwright/test';
import { checkSnapshot } from '../../../utils/snapshotTesting';
import { expectedPaperworkReductionActUrl } from '../../../utils/testFixture.utils';

test('Unauthenticated homepage: Paperwork Reduction Act', async ({ page }) => {
Expand All @@ -10,6 +11,7 @@ test('Unauthenticated homepage: Paperwork Reduction Act', async ({ page }) => {
await expect(
page.getByRole('link', { name: 'View Paperwork Reduction Act' }),
).toBeVisible();
await checkSnapshot(page);
});

await test.step('Navigates to the Paperwork Reduction Act summary', async () => {
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { expect, test } from '@playwright/test';
import { checkSnapshot } from '../../../utils/snapshotTesting';
import { expectedPrivacyNoticeUrl } from '../../../utils/testFixture.utils';

test('Unauthenticated homepage: Privacy Notice', async ({ page }) => {
Expand All @@ -8,12 +9,14 @@ test('Unauthenticated homepage: Privacy Notice', async ({ page }) => {
await expect(
page.getByRole('link', { name: 'View Privacy Notice' }),
).toBeVisible();
await checkSnapshot(page);
});

await test.step('Navigates to the Privacy Notice summary', async () => {
await page.getByRole('link', { name: 'View Privacy Notice' }).click();
await expect(page).toHaveURL(expectedPrivacyNoticeUrl);
await expect(page.getByText('/Home')).toBeVisible();
await expect(page.getByRole('heading')).toContainText('Privacy Notice');
await checkSnapshot(page);
});
});
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"test:ci": "vitest run",
"test:e2e": "chmod +x ./run-playwright.sh && sh ./run-playwright.sh",
"test:e2e:snapshot": "chmod +x ./run-playwright.sh && SBL_ENABLE_PLAYWRIGHT_SNAPSHOT_TESTING=true sh ./run-playwright.sh",
"test:e2e:snapshot-update": "SBL_ENABLE_PLAYWRIGHT_SNAPSHOT_TESTING=true yarn playwright test --update-snapshots",
"format": "prettier -uw --cache .",
"run-tsc": "tsc",
"run-eslint": "eslint --cache --fix --ignore-path .gitignore --ignore-path .eslintignore --ext .ts,.tsx .",
Expand Down
4 changes: 2 additions & 2 deletions src/components/AssociatedInstitution.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable react/require-default-props */
import { ListLink } from 'components/Link';
import { formatPipeSeparatedString } from 'utils/formatting';
import type { InstitutionDetailsApiType } from 'types/formTypes';
import { formatPipeSeparatedString } from 'utils/formatting';

export function AssociatedInstitution({
name,
Expand All @@ -17,7 +17,7 @@ export function AssociatedInstitution({
}

return (
<ListLink href={href} key={lei}>
<ListLink href={href} key={lei} className='snapshot-ignore'>
{text}
</ListLink>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ function UpdateIdentifyingInformation({
{...register(taxID)}
errorMessage={formErrors[taxID]?.message}
showError
className='snapshot-ignore'
/>
<InputEntry
id={rssdID}
Expand All @@ -94,6 +95,7 @@ function UpdateIdentifyingInformation({
value={rssdIdValue}
errorMessage={formErrors[rssdID]?.message}
showError
className='snapshot-ignore'
/>
<FieldFederalPrudentialRegulator {...{ register, data }} />
</WellContainer>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ export function FinancialInstitutionDetails({
<DisplayField
label={InstitutionDataLabels.emailDomains}
value={formatDomains(data.domains)}
className='snapshot-ignore'
/>
) : (
''
Expand Down
2 changes: 2 additions & 0 deletions src/pages/Filing/ViewUserProfile/UserInformation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,12 @@ export default function UserInformation({
<DisplayField
label='Full name'
value={<Paragraph className='mb-[0.625rem]'>{data.name}</Paragraph>}
className='snapshot-ignore'
/>
<DisplayField
label='Email address'
value={<Paragraph className='mb-[0.625rem]'>{data.email}</Paragraph>}
className='snapshot-ignore'
/>
</WellContainer>
</>
Expand Down
Loading