Skip to content

Commit

Permalink
[Review First][e2e] [Upload] Tests for syntax errors, logic errors an…
Browse files Browse the repository at this point in the history
…d to verify a downloadable report (#938)

closes #777 
closes #802
closes #937 
closes #958

## Changes
- Adds e2e test to check the navigation of when a user uploads a csv
that produces syntax errors
- Adds e2e test to check the navigation of when a user uploads a csv
that produces logic errors
- e2e: Verifies - a user can download a validation report after a syntax
error has been upload
- enhancement: Improves TypeScript handing in `playwright.config.ts`
- feat: deletes individual reports in the
`e2e/pages/filing-app/uploadFile/downloads` directory after the download
report test finishes
- chore: updated `uploadFile.ts` to be DRY
- feat: Integrate `uploadFile.ts` with completeUploadLogicErrors.spec.ts
- feat: Integrate `uploadFile.ts` with
completeUploadSyntaxErrors.spec.ts
- feat: Update `unavailableApis.spec.ts` with `uploadFile.ts`
accordingly

## How to Test
- Run `npx playwright test --ui`
- Run the `completeSyntaxErrors.spec.ts` test
- Run the `completeLogicErrors.spec.ts` test
- Run the `unavailableApis.spec.ts` test
- **Verify downloaded reports are being <ins>deleted</ins> from
`e2e/pages/filing-app/uploadFile/downloads`**

## Screenshot
<img width="1392" alt="Screenshot 2024-09-20 at 2 15 50 PM"
src="https://github.com/user-attachments/assets/2ea68bc9-e780-4934-8bd6-bca8fd9dc4d4">
  • Loading branch information
shindigira authored Oct 9, 2024
1 parent a4aaaac commit 1ab3869
Show file tree
Hide file tree
Showing 10 changed files with 459 additions and 74 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ coverage
.stylelintcache
cypress/videos
package-lock.json
e2e/pages/filing-app/uploadFile/downloads/*
e2e/utils/downloads/*

.yarn/*
!.yarn/cache
Expand Down
2 changes: 1 addition & 1 deletion e2e/fixtures/testFixture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ export const test = baseTest.extend<{
);
await expect(page.getByText('File upload in progress')).toBeVisible();
await expect(page.getByText('File upload successful')).toBeVisible({
timeout: 10_000,
timeout: 30_000,
});
await expect(
page.getByText('Validation checks in progress'),
Expand Down
12 changes: 10 additions & 2 deletions e2e/pages/filing-app/unavailableApis.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { expect } from '@playwright/test';
import { test } from '../../fixtures/testFixture';
import { blockApi } from '../../utils/blockApi';
import uploadFile from '../../utils/uploadFile';
import { ResultUploadMessage, uploadFile } from '../../utils/uploadFile';

test('Form Alerts and API', async ({
page,
Expand Down Expand Up @@ -82,7 +82,15 @@ test('Form Alerts and API', async ({
});

// Upload file
await uploadFile(page, true, null);
await uploadFile({
testUsed: test,
pageUsed: page,
newUpload: true,
testTitle: 'Upload file',
filePath:
'../test-data/sample-sblar-files/sbl-validations-all-pass-small.csv',
resultMessage: ResultUploadMessage.warning,
});

// Continue to next page
await test.step('Click: Continue', async () => {
Expand Down
57 changes: 57 additions & 0 deletions e2e/pages/filing-app/uploadFile/completeUploadLogicErrors.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import { expect } from '@playwright/test';
import { test } from '../../../fixtures/testFixture';
import { ResultUploadMessage, uploadFile } from '../../../utils/uploadFile';
import { verifyDownloadableReport } from '../../../utils/verifyDownloadableReport';

test('Resolve Errors (Logic)', async ({ page, navigateToUploadFile }) => {
test.slow();

navigateToUploadFile;

await test.step('Upload file: navigate to Resolve Errors (Logic) after upload', async () => {
await uploadFile({
testUsed: test,
pageUsed: page,
newUpload: true,
testTitle:
'Upload file: upload small file with only warnings (logic-errors_medium.csv)',
filePath:
'../test-data/sample-sblar-files/logic-errors_single&multi_and_warnings.csv',
resultMessage: ResultUploadMessage.logic,
});

await test.step('Verify Resolve Errors (syntax) and zero errors', async () => {
await page.getByRole('button', { name: 'Continue to next step' }).click();
await expect(page.locator('h1')).toContainText(
'Resolve errors (syntax)',
{
timeout: 30_000,
},
);
await expect(
page.getByText('Your register contains no syntax errors'),
).toBeVisible({ timeout: 40_000 });
});

await test.step('Verify Resolve Errors (logic) and number of errors', async () => {
await page.getByRole('button', { name: 'Continue' }).click();
await expect(page.locator('h1')).toContainText('Resolve errors (logic)', {
timeout: 30_000,
});
await expect(page.locator('#error-header-alert')).toContainText(
'Your register contains logic errors',
);
await expect(page.locator('#single-field-errors')).toContainText(
'Single-field errors: 1 found',
);
await expect(page.locator('#register-level-errors')).toContainText(
'Register-level errors: 2 found',
);
await expect(page.locator('#multi-field-errors')).toContainText(
'Multi-field errors: 52 found',
);
});

await verifyDownloadableReport({ testUsed: test, pageUsed: page });
});
});
43 changes: 43 additions & 0 deletions e2e/pages/filing-app/uploadFile/completeUploadSyntaxErrors.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { expect } from '@playwright/test';
import { test } from '../../../fixtures/testFixture';
import { ResultUploadMessage, uploadFile } from '../../../utils/uploadFile';
import { verifyDownloadableReport } from '../../../utils/verifyDownloadableReport';

test('Resolve Errors (Syntax)', async ({ page, navigateToUploadFile }) => {
test.slow();

navigateToUploadFile;

await test.step('Upload file: navigate to Resolve Errors (syntax) after upload', async () => {
await uploadFile({
testUsed: test,
pageUsed: page,
newUpload: true,
testTitle:
'Upload file: upload small file with only warnings (all_syntax_errors.csv)',
filePath: '../test-data/sample-sblar-files/all_syntax_errors.csv',
resultMessage: ResultUploadMessage.syntax,
});

await test.step('Verify Resolve Errors (syntax) and number of errors', async () => {
await page.getByRole('button', { name: 'Continue to next step' }).click();
await expect(page.locator('h1')).toContainText(
'Resolve errors (syntax)',
{
timeout: 30_000,
},
);
await expect(page.locator('#error-header-alert')).toBeVisible({
timeout: 30_000,
});
await expect(page.locator('h2')).toContainText(
'Single-field errors: 136 found',
{
timeout: 20_000,
},
);
});

await verifyDownloadableReport({ testUsed: test, pageUsed: page });
});
});
Loading

0 comments on commit 1ab3869

Please sign in to comment.