diff --git a/cypress/helpers/authentication/login-as-helpers.ts b/cypress/helpers/authentication/login-as-helpers.ts
index f16143b64af..e0175319390 100644
--- a/cypress/helpers/authentication/login-as-helpers.ts
+++ b/cypress/helpers/authentication/login-as-helpers.ts
@@ -59,7 +59,7 @@ export function loginAsIrsPractitioner1() {
}
export function loginAsPetitioner(
- petitionerUser: 'petitioner' | 'petitioner1' = 'petitioner1',
+ petitionerUser: 'petitioner' | 'petitioner1' | 'petitioner7' = 'petitioner1',
) {
cy.login(petitionerUser);
cy.get('[data-testid="file-a-petition"]').should('exist');
diff --git a/cypress/helpers/fileAPetition/petitioner-creates-electronic-case-updated.ts b/cypress/helpers/fileAPetition/petitioner-creates-electronic-case-updated.ts
index 903e18e7e55..5530ccbf537 100644
--- a/cypress/helpers/fileAPetition/petitioner-creates-electronic-case-updated.ts
+++ b/cypress/helpers/fileAPetition/petitioner-creates-electronic-case-updated.ts
@@ -12,7 +12,7 @@ export function petitionerCreatesElectronicCaseUpdated(
cy.get('[data-testid="contactPrimary.city"]').type('Orlando');
cy.get('[data-testid="contactPrimary.state"]').select('AL');
cy.get('[data-testid="contactPrimary.postalCode"]').type('12345');
- cy.get('[data-testid="contactPrimary.placeOfLegalResidence"]').select('AL');
+ cy.get('[data-testid="contactPrimary-placeOfLegalResidence"]').select('AL');
cy.get('[data-testid="contact-primary-phone"]').type('1111111111');
cy.get('[data-testid="step-1-next-button"]').click();
@@ -105,7 +105,7 @@ export function petitionerAttemptsToUploadCorruptPdfUpdated() {
cy.get('[data-testid="contactPrimary.city"]').type('Orlando');
cy.get('[data-testid="contactPrimary.state"]').select('AL');
cy.get('[data-testid="contactPrimary.postalCode"]').type('12345');
- cy.get('[data-testid="contactPrimary.placeOfLegalResidence"]').select('AL');
+ cy.get('[data-testid="contactPrimary-placeOfLegalResidence"]').select('AL');
cy.get('[data-testid="contact-primary-phone"]').type('1111111111');
cy.get('[data-testid="step-1-next-button"]').click();
diff --git a/cypress/local-only/tests/accessibility/petitionGeneration/petition-generation-before-filing-a-case.cy.ts b/cypress/local-only/tests/accessibility/petitionGeneration/petition-generation-before-filing-a-case.cy.ts
new file mode 100644
index 00000000000..f774cca06ac
--- /dev/null
+++ b/cypress/local-only/tests/accessibility/petitionGeneration/petition-generation-before-filing-a-case.cy.ts
@@ -0,0 +1,15 @@
+import { checkA11y } from '../../../support/generalCommands/checkA11y';
+import { loginAsPetitioner } from '../../../../helpers/authentication/login-as-helpers';
+
+describe('Petition generation - intro pages', () => {
+ it('welcome to dawson: should be free of a11y issues', () => {
+ loginAsPetitioner('petitioner7');
+ checkA11y();
+ });
+
+ it('before filing a case: should be free of a11y issues', () => {
+ loginAsPetitioner();
+ cy.visit('/before-filing-a-petition');
+ checkA11y();
+ });
+});
diff --git a/cypress/local-only/tests/accessibility/petitionGeneration/petition-generation-step-1.cy.ts b/cypress/local-only/tests/accessibility/petitionGeneration/petition-generation-step-1.cy.ts
new file mode 100644
index 00000000000..f1f854b2670
--- /dev/null
+++ b/cypress/local-only/tests/accessibility/petitionGeneration/petition-generation-step-1.cy.ts
@@ -0,0 +1,146 @@
+import { checkA11y } from '../../../support/generalCommands/checkA11y';
+import { loginAsPetitioner } from '../../../../helpers/authentication/login-as-helpers';
+
+describe('Petition generation - step 1', () => {
+ beforeEach(() => {
+ loginAsPetitioner();
+ cy.visit('/file-a-petition/new');
+ });
+
+ describe('Myself', () => {
+ it('Myself - domestic: should be free of a11y issues', () => {
+ cy.get('[data-testid="filing-type-0"').click();
+ checkA11y();
+ });
+
+ it('Myself - international: should be free of a11y issues', () => {
+ cy.get('[data-testid="filing-type-0"').click();
+ cy.get('[data-testid="international-country-btn"]').click();
+ checkA11y();
+ });
+ });
+ describe('Myself and my spouse', () => {
+ it('Myself and my spouse - deceased: should be free of a11y issues', () => {
+ cy.get('[data-testid="filing-type-1"').click();
+ cy.get('[data-testid="is-spouse-deceased-0"]').click();
+ checkA11y();
+ });
+
+ it('Myself and my spouse - not deceased: should be free of a11y issues', () => {
+ cy.get('[data-testid="filing-type-1"').click();
+ cy.get('[data-testid="is-spouse-deceased-1"]').click();
+ cy.get('[data-testid="have-spouse-consent-label"').click();
+ checkA11y();
+ });
+ });
+ describe('Business', () => {
+ it('Corporation: should be free of a11y issues', () => {
+ cy.get('[data-testid="filing-type-2"').click();
+ cy.get('.business-type-radio-option').eq(0).click();
+ checkA11y();
+ });
+
+ it('Partnership (as the Tax Matters Partner): should be free of a11y issues', () => {
+ cy.get('[data-testid="filing-type-2"').click();
+ cy.get('.business-type-radio-option').eq(1).click();
+ checkA11y();
+ });
+
+ it('Partnership (as a partner other than Tax Matters Partner): should be free of a11y issues', () => {
+ cy.get('[data-testid="filing-type-2"').click();
+ cy.get('.business-type-radio-option').eq(2).click();
+ checkA11y();
+ });
+
+ it('Partnership (as a partnership representative under BBA): should be free of a11y issues', () => {
+ cy.get('[data-testid="filing-type-2"').click();
+ cy.get('.business-type-radio-option').eq(3).click();
+ checkA11y();
+ });
+ });
+ describe('Other', () => {
+ describe('An estate or trust', () => {
+ it('Estate with an executor/personal representative/fiduciary/etc.: should be free of a11y issues: should be free of a11y issues', () => {
+ cy.get('[data-testid="filing-type-3"').click();
+ cy.get('[data-testid="other-type-radio-option-0"]').click();
+ cy.get('[data-testid="estate-type-radio-option-0"]').click();
+ checkA11y();
+ });
+
+ it('Estate without an executor/personal representative/fiduciary/etc.: should be free of a11y issues', () => {
+ cy.get('[data-testid="filing-type-3"').click();
+ cy.get('[data-testid="other-type-radio-option-0"]').click();
+ cy.get('[data-testid="estate-type-radio-option-1"]').click();
+ checkA11y();
+ });
+
+ it('Trust: should be free of a11y issues', () => {
+ cy.get('[data-testid="filing-type-3"').click();
+ cy.get('[data-testid="other-type-radio-option-0"]').click();
+ cy.get('[data-testid="estate-type-radio-option-2"]').click();
+ checkA11y();
+ });
+ });
+
+ describe('A minor or legally incompetent person', () => {
+ it('Conservator: should be free of a11y issues', () => {
+ cy.get('[data-testid="filing-type-3"').click();
+ cy.get('[data-testid="other-type-radio-option-1"]').click();
+ cy.get('[data-testid="minor-incompetent-type-radio-option-0"]').click();
+ checkA11y();
+ });
+
+ it('Guardian: should be free of a11y issues', () => {
+ cy.get('[data-testid="filing-type-3"').click();
+ cy.get('[data-testid="other-type-radio-option-1"]').click();
+ cy.get('[data-testid="minor-incompetent-type-radio-option-1"]').click();
+ checkA11y();
+ });
+
+ it('Custodian: should be free of a11y issues', () => {
+ cy.get('[data-testid="filing-type-3"').click();
+ cy.get('[data-testid="other-type-radio-option-1"]').click();
+ cy.get('[data-testid="minor-incompetent-type-radio-option-2"]').click();
+ checkA11y();
+ });
+
+ it('Next friend for a minor (without a guardian, conservator, or other like fiduciary): should be free of a11y issues', () => {
+ cy.get('[data-testid="filing-type-3"').click();
+ cy.get('[data-testid="other-type-radio-option-1"]').click();
+ cy.get('[data-testid="minor-incompetent-type-radio-option-3"]').click();
+ checkA11y();
+ });
+
+ it('Next friend for a legally incompetent person (without a guardian, conservator, or other like fiduciary): should be free of a11y issues', () => {
+ cy.get('[data-testid="filing-type-3"').click();
+ cy.get('[data-testid="other-type-radio-option-1"]').click();
+ cy.get('[data-testid="minor-incompetent-type-radio-option-4"]').click();
+ checkA11y();
+ });
+ });
+
+ describe('Donor', () => {
+ it('Donor: should be free of a11y issues', () => {
+ cy.get('[data-testid="filing-type-3"').click();
+ cy.get('[data-testid="other-type-radio-option-2"]').click();
+ checkA11y();
+ });
+ });
+
+ describe('Transferee', () => {
+ it('Transferee: should be free of a11y issues', () => {
+ cy.get('[data-testid="filing-type-3"').click();
+ cy.get('[data-testid="other-type-radio-option-3"]').click();
+ checkA11y();
+ });
+ });
+
+ describe('Deceased Spouse', () => {
+ it('Deceased Spouse: should be free of a11y issues', () => {
+ cy.get('[data-testid="filing-type-3"').click();
+ cy.get('[data-testid="other-type-radio-option-4"]').click();
+ checkA11y();
+ });
+ });
+ });
+});
diff --git a/cypress/local-only/tests/accessibility/petitionGeneration/petition-generation-step-2.cy.ts b/cypress/local-only/tests/accessibility/petitionGeneration/petition-generation-step-2.cy.ts
new file mode 100644
index 00000000000..2c449ba8af3
--- /dev/null
+++ b/cypress/local-only/tests/accessibility/petitionGeneration/petition-generation-step-2.cy.ts
@@ -0,0 +1,22 @@
+import { checkA11y } from '../../../support/generalCommands/checkA11y';
+import { fillPetitionerInformation } from '../../integration/fileAPetitionUpdated/petition-helper';
+import { loginAsPetitioner } from '../../../../helpers/authentication/login-as-helpers';
+
+describe('Petition generation - step 2', () => {
+ beforeEach(() => {
+ loginAsPetitioner();
+ cy.visit('/file-a-petition/new');
+ fillPetitionerInformation();
+ });
+
+ it('Auto generate Petition: should be free of a11y issues', () => {
+ cy.get('[data-testid="add-another-reason-link-button"').click();
+ cy.get('[data-testid="add-another-fact-link-button"').click();
+ checkA11y();
+ });
+
+ it('Upload PDF Petition: should be free of a11y issues', () => {
+ cy.get('[data-testid="upload-a-petition-label"').click();
+ checkA11y();
+ });
+});
diff --git a/cypress/local-only/tests/accessibility/petitionGeneration/petition-generation-step-3.cy.ts b/cypress/local-only/tests/accessibility/petitionGeneration/petition-generation-step-3.cy.ts
new file mode 100644
index 00000000000..06f9870b518
--- /dev/null
+++ b/cypress/local-only/tests/accessibility/petitionGeneration/petition-generation-step-3.cy.ts
@@ -0,0 +1,27 @@
+import { checkA11y } from '../../../support/generalCommands/checkA11y';
+import {
+ fillPetitionFileInformation,
+ fillPetitionerInformation,
+} from '../../integration/fileAPetitionUpdated/petition-helper';
+import { loginAsPetitioner } from '../../../../helpers/authentication/login-as-helpers';
+
+describe('Petition generation - step 3', () => {
+ const VALID_FILE = '../../helpers/file/sample.pdf';
+
+ beforeEach(() => {
+ loginAsPetitioner();
+ cy.visit('/file-a-petition/new');
+ fillPetitionerInformation();
+ fillPetitionFileInformation(VALID_FILE);
+ });
+
+ it('IRS Notice Provided: should be free of a11y issues', () => {
+ cy.get('[data-testid="irs-notice-Yes"]').click();
+ checkA11y();
+ });
+
+ it('IRS Notice not Provided: should be free of a11y issues', () => {
+ cy.get('[data-testid="irs-notice-No"]').click();
+ checkA11y();
+ });
+});
diff --git a/cypress/local-only/tests/accessibility/petitionGeneration/petition-generation-step-4.cy.ts b/cypress/local-only/tests/accessibility/petitionGeneration/petition-generation-step-4.cy.ts
new file mode 100644
index 00000000000..7c26dd96834
--- /dev/null
+++ b/cypress/local-only/tests/accessibility/petitionGeneration/petition-generation-step-4.cy.ts
@@ -0,0 +1,28 @@
+import { checkA11y } from '../../../support/generalCommands/checkA11y';
+import {
+ fillIrsNoticeInformation,
+ fillPetitionFileInformation,
+ fillPetitionerInformation,
+} from '../../integration/fileAPetitionUpdated/petition-helper';
+import { loginAsPetitioner } from '../../../../helpers/authentication/login-as-helpers';
+
+describe('Petition generation - step 4', () => {
+ const VALID_FILE = '../../helpers/file/sample.pdf';
+
+ beforeEach(() => {
+ loginAsPetitioner();
+ cy.visit('/file-a-petition/new');
+ fillPetitionerInformation();
+ fillPetitionFileInformation(VALID_FILE);
+ fillIrsNoticeInformation(VALID_FILE);
+ });
+
+ it('Regular Case: should be free of a11y issues', () => {
+ checkA11y();
+ });
+
+ it('Small Case: should be free of a11y issues', () => {
+ cy.get('[data-testid="procedure-type-1"]').click();
+ checkA11y();
+ });
+});
diff --git a/cypress/local-only/tests/accessibility/petitionGeneration/petition-generation-step-5.cy.ts b/cypress/local-only/tests/accessibility/petitionGeneration/petition-generation-step-5.cy.ts
new file mode 100644
index 00000000000..b928abbb017
--- /dev/null
+++ b/cypress/local-only/tests/accessibility/petitionGeneration/petition-generation-step-5.cy.ts
@@ -0,0 +1,25 @@
+import { checkA11y } from '../../../support/generalCommands/checkA11y';
+import {
+ fillCaseProcedureInformation,
+ fillIrsNoticeInformation,
+ fillPetitionFileInformation,
+ fillPetitionerInformation,
+} from '../../integration/fileAPetitionUpdated/petition-helper';
+import { loginAsPetitioner } from '../../../../helpers/authentication/login-as-helpers';
+
+describe('Petition generation - step 5', () => {
+ const VALID_FILE = '../../helpers/file/sample.pdf';
+
+ beforeEach(() => {
+ loginAsPetitioner();
+ cy.visit('/file-a-petition/new');
+ fillPetitionerInformation();
+ fillPetitionFileInformation(VALID_FILE);
+ fillIrsNoticeInformation(VALID_FILE);
+ fillCaseProcedureInformation();
+ });
+
+ it('Upload STIN: should be free of a11y issues', () => {
+ checkA11y();
+ });
+});
diff --git a/cypress/local-only/tests/accessibility/petitionGeneration/petition-generation-step-6.cy.ts b/cypress/local-only/tests/accessibility/petitionGeneration/petition-generation-step-6.cy.ts
new file mode 100644
index 00000000000..d98ccb92de9
--- /dev/null
+++ b/cypress/local-only/tests/accessibility/petitionGeneration/petition-generation-step-6.cy.ts
@@ -0,0 +1,27 @@
+import { checkA11y } from '../../../support/generalCommands/checkA11y';
+import {
+ fillCaseProcedureInformation,
+ fillIrsNoticeInformation,
+ fillPetitionFileInformation,
+ fillPetitionerInformation,
+ fillStinInformation,
+} from '../../integration/fileAPetitionUpdated/petition-helper';
+import { loginAsPetitioner } from '../../../../helpers/authentication/login-as-helpers';
+
+describe('Petition generation - step 6', () => {
+ const VALID_FILE = '../../helpers/file/sample.pdf';
+
+ beforeEach(() => {
+ loginAsPetitioner();
+ cy.visit('/file-a-petition/new');
+ fillPetitionerInformation();
+ fillPetitionFileInformation(VALID_FILE);
+ fillIrsNoticeInformation(VALID_FILE);
+ fillCaseProcedureInformation();
+ fillStinInformation(VALID_FILE);
+ });
+
+ it('Review Page: should be free of a11y issues', () => {
+ checkA11y();
+ });
+});
diff --git a/cypress/local-only/tests/accessibility/petitionGeneration/petition-generation-step-7.cy.ts b/cypress/local-only/tests/accessibility/petitionGeneration/petition-generation-step-7.cy.ts
new file mode 100644
index 00000000000..fc723e17c32
--- /dev/null
+++ b/cypress/local-only/tests/accessibility/petitionGeneration/petition-generation-step-7.cy.ts
@@ -0,0 +1,31 @@
+import { checkA11y } from '../../../support/generalCommands/checkA11y';
+import {
+ fillCaseProcedureInformation,
+ fillIrsNoticeInformation,
+ fillPetitionFileInformation,
+ fillPetitionerInformation,
+ fillStinInformation,
+} from '../../integration/fileAPetitionUpdated/petition-helper';
+import { loginAsPetitioner } from '../../../../helpers/authentication/login-as-helpers';
+
+describe('Petition generation - step 7', () => {
+ const VALID_FILE = '../../helpers/file/sample.pdf';
+
+ beforeEach(() => {
+ loginAsPetitioner();
+ cy.visit('/file-a-petition/new');
+ fillPetitionerInformation();
+ fillPetitionFileInformation(VALID_FILE);
+ fillIrsNoticeInformation(VALID_FILE);
+ fillCaseProcedureInformation();
+ fillStinInformation(VALID_FILE);
+ cy.get('[data-testid="step-6-next-button"]').click();
+ });
+
+ it('Pay filing fee: should be free of a11y issues', () => {
+ cy.intercept('POST', '**/cases').as('postCase');
+ cy.wait('@postCase').then(() => {
+ checkA11y();
+ });
+ });
+});
diff --git a/cypress/local-only/tests/integration/fileAPetitionUpdated/file-a-petition-all-steps.cy.ts b/cypress/local-only/tests/integration/fileAPetitionUpdated/file-a-petition-all-steps.cy.ts
new file mode 100644
index 00000000000..7fdc9333588
--- /dev/null
+++ b/cypress/local-only/tests/integration/fileAPetitionUpdated/file-a-petition-all-steps.cy.ts
@@ -0,0 +1,55 @@
+import {
+ fillCaseProcedureInformation,
+ fillGeneratePetitionFileInformation,
+ fillIrsNoticeInformation,
+ fillPetitionerInformation,
+ fillStinInformation,
+} from './petition-helper';
+import { loginAsPetitioner } from '../../../../helpers/authentication/login-as-helpers';
+
+describe('File a petition', () => {
+ const VALID_FILE = '../../helpers/file/sample.pdf';
+
+ describe('File a petition', () => {
+ const caseTypes = [
+ 'Deficiency',
+ 'CDP (Lien/Levy)',
+ 'Other',
+ 'Partnership (Section 6228)',
+ 'Disclosure2',
+ 'Passport',
+ 'Innocent Spouse',
+ 'Worker Classification',
+ 'Whistleblower',
+ 'Interest Abatement',
+ 'Disclosure1',
+ 'Partnership (BBA Section 1101)',
+ 'Partnership (Section 6226)',
+ ];
+
+ caseTypes.forEach(caseType => {
+ it(`should file a petition for case type: ${caseType}`, () => {
+ loginAsPetitioner();
+ cy.visit('/file-a-petition/new');
+ fillPetitionerInformation();
+ fillGeneratePetitionFileInformation();
+ fillIrsNoticeInformation(VALID_FILE, caseType);
+ fillCaseProcedureInformation();
+ fillStinInformation(VALID_FILE);
+
+ cy.intercept('POST', '**/cases').as('postCase');
+
+ cy.get('[data-testid="step-6-next-button"]').click();
+ cy.wait('@postCase').then(({ response }) => {
+ if (!response) throw Error('Did not find resposne');
+ expect(response.body).to.have.property('docketNumber');
+ const createdDocketNumber = response.body.docketNumber;
+ cy.get('.usa-alert__heading').should(
+ 'contain.text',
+ `Your case has been assigned docket number ${createdDocketNumber}`,
+ );
+ });
+ });
+ });
+ });
+});
diff --git a/cypress/local-only/tests/integration/fileAPetitionUpdated/file-a-petition-step-1-myself.cy.ts b/cypress/local-only/tests/integration/fileAPetitionUpdated/file-a-petition-step-1-myself.cy.ts
index ec749ca4048..eef6ec182b7 100644
--- a/cypress/local-only/tests/integration/fileAPetitionUpdated/file-a-petition-step-1-myself.cy.ts
+++ b/cypress/local-only/tests/integration/fileAPetitionUpdated/file-a-petition-step-1-myself.cy.ts
@@ -39,7 +39,7 @@ describe('File a petition', () => {
});
it('should display an input for "place of legal residence"', () => {
- cy.get('[data-testid="contactPrimary.placeOfLegalResidence"]').should(
+ cy.get('[data-testid="contactPrimary-placeOfLegalResidence"]').should(
'exist',
);
});
diff --git a/cypress/local-only/tests/integration/fileAPetitionUpdated/file-a-petition-step-2.cy.ts b/cypress/local-only/tests/integration/fileAPetitionUpdated/file-a-petition-step-2.cy.ts
index 489f633d3ee..ca21fa7cda3 100644
--- a/cypress/local-only/tests/integration/fileAPetitionUpdated/file-a-petition-step-2.cy.ts
+++ b/cypress/local-only/tests/integration/fileAPetitionUpdated/file-a-petition-step-2.cy.ts
@@ -91,6 +91,31 @@ describe('File a petition', () => {
cy.get('[data-testid="step-indicator-current-step-3-icon"]');
});
});
+
+ describe('add facts and reasons', () => {
+ it('should display empty textbox when text is removed', () => {
+ cy.get('[data-testid="petition-reason--1"]').focus();
+ cy.get('[data-testid="petition-reason--1"]').type('REASON 1');
+ cy.get('[data-testid="petition-reason--1"]').blur();
+ cy.get('[data-testid="petition-reason--1"]').focus();
+ cy.get('[data-testid="petition-reason--1"]').type(
+ '{selectall}{backspace}',
+ );
+ cy.get('[data-testid="petition-reason--1"]').should('be.visible');
+
+ cy.get('[data-testid="petition-fact--1"]').focus();
+ cy.get('[data-testid="petition-fact--1"]').type('FACT 1');
+ cy.get('[data-testid="add-another-fact-link-button"]').click();
+ cy.get('[data-testid="petition-fact-0"]').focus();
+ cy.get('[data-testid="petition-fact-0"]').type('FACT 2');
+ cy.get('[data-testid="petition-fact-0"]').blur();
+ cy.get('[data-testid="petition-fact-0"]').focus();
+ cy.get('[data-testid="petition-fact-0"]').type(
+ '{selectall}{backspace}',
+ );
+ cy.get('[data-testid="petition-fact-0"]').should('be.visible');
+ });
+ });
});
describe('Upload PDF', () => {
diff --git a/cypress/local-only/tests/integration/fileAPetitionUpdated/file-a-petition-step-6-petitioner-info-business.cy.ts b/cypress/local-only/tests/integration/fileAPetitionUpdated/file-a-petition-step-6-petitioner-info-business.cy.ts
index e333cfa826c..1b67b32c9cf 100644
--- a/cypress/local-only/tests/integration/fileAPetitionUpdated/file-a-petition-step-6-petitioner-info-business.cy.ts
+++ b/cypress/local-only/tests/integration/fileAPetitionUpdated/file-a-petition-step-6-petitioner-info-business.cy.ts
@@ -24,7 +24,7 @@ describe('File a petition - Step 6 Review & Submit Case', () => {
fillBusinessandOtherContact({
fillInCareOf: true,
});
- cy.get('[data-testid="contactPrimary.placeOfLegalResidence"]').select(
+ cy.get('[data-testid="contactPrimary-placeOfLegalResidence"]').select(
contactInfo.placeOfLegalResidence,
);
cy.get('[data-testid="contact-primary-phone"]').type(contactInfo.phone);
@@ -64,7 +64,7 @@ describe('File a petition - Step 6 Review & Submit Case', () => {
fillBusinessandOtherContact({
fillSecondaryName: true,
});
- cy.get('[data-testid="contactPrimary.placeOfLegalResidence"]').select(
+ cy.get('[data-testid="contactPrimary-placeOfLegalResidence"]').select(
contactInfo.placeOfLegalResidence,
);
cy.get('[data-testid="contact-primary-phone"]').type(contactInfo.phone);
@@ -118,7 +118,7 @@ describe('File a petition - Step 6 Review & Submit Case', () => {
fillBusinessandOtherContact({
fillSecondaryName: true,
});
- cy.get('[data-testid="contactPrimary.placeOfLegalResidence"]').select(
+ cy.get('[data-testid="contactPrimary-placeOfLegalResidence"]').select(
contactInfo.placeOfLegalResidence,
);
cy.get('[data-testid="contact-primary-phone"]').type(contactInfo.phone);
@@ -172,7 +172,7 @@ describe('File a petition - Step 6 Review & Submit Case', () => {
fillBusinessandOtherContact({
fillSecondaryName: true,
});
- cy.get('[data-testid="contactPrimary.placeOfLegalResidence"]').select(
+ cy.get('[data-testid="contactPrimary-placeOfLegalResidence"]').select(
contactInfo.placeOfLegalResidence,
);
cy.get('[data-testid="contact-primary-phone"]').type(contactInfo.phone);
diff --git a/cypress/local-only/tests/integration/fileAPetitionUpdated/file-a-petition-step-6-petitioner-info-other.cy.ts b/cypress/local-only/tests/integration/fileAPetitionUpdated/file-a-petition-step-6-petitioner-info-other.cy.ts
index 1f9fb54521a..ac4b0bb9869 100644
--- a/cypress/local-only/tests/integration/fileAPetitionUpdated/file-a-petition-step-6-petitioner-info-other.cy.ts
+++ b/cypress/local-only/tests/integration/fileAPetitionUpdated/file-a-petition-step-6-petitioner-info-other.cy.ts
@@ -28,7 +28,7 @@ describe('File a petition - Step 6 Review & Submit Case', () => {
fillSecondaryName: true,
fillTitle: true,
});
- cy.get('[data-testid="contactPrimary.placeOfLegalResidence"]').select(
+ cy.get('[data-testid="contactPrimary-placeOfLegalResidence"]').select(
'AK',
);
cy.get('[data-testid="contact-primary-phone"]').type('3232323232');
@@ -70,7 +70,7 @@ describe('File a petition - Step 6 Review & Submit Case', () => {
fillBusinessandOtherContact({
fillInCareOf: true,
});
- cy.get('[data-testid="contactPrimary.placeOfLegalResidence"]').select(
+ cy.get('[data-testid="contactPrimary-placeOfLegalResidence"]').select(
'AK',
);
cy.get('[data-testid="contact-primary-phone"]').type('3232323232');
@@ -112,7 +112,7 @@ describe('File a petition - Step 6 Review & Submit Case', () => {
fillBusinessandOtherContact({
fillSecondaryName: true,
});
- cy.get('[data-testid="contactPrimary.placeOfLegalResidence"]').select(
+ cy.get('[data-testid="contactPrimary-placeOfLegalResidence"]').select(
'AK',
);
cy.get('[data-testid="contact-primary-phone"]').type('3232323232');
@@ -174,7 +174,7 @@ describe('File a petition - Step 6 Review & Submit Case', () => {
fillSecondaryName: true,
});
cy.get(
- '[data-testid="contactPrimary.placeOfLegalResidence"]',
+ '[data-testid="contactPrimary-placeOfLegalResidence"]',
).select(contactInfo.placeOfLegalResidence);
cy.get('[data-testid="contact-primary-phone"]').type(
contactInfo.phone,
@@ -269,7 +269,7 @@ describe('File a petition - Step 6 Review & Submit Case', () => {
cy.get('[data-testid="filing-type-3"]').click();
cy.get('[data-testid="other-type-radio-option-4"]').click();
fillBusinessandOtherContact({ fillSecondaryName: true });
- cy.get('[data-testid="contactPrimary.placeOfLegalResidence"]').select(
+ cy.get('[data-testid="contactPrimary-placeOfLegalResidence"]').select(
contactInfo.placeOfLegalResidence,
);
cy.get('[data-testid="contact-primary-phone"]').type(contactInfo.phone);
diff --git a/cypress/local-only/tests/integration/fileAPetitionUpdated/petition-helper.ts b/cypress/local-only/tests/integration/fileAPetitionUpdated/petition-helper.ts
index 769a03f5f07..1c087953b8b 100644
--- a/cypress/local-only/tests/integration/fileAPetitionUpdated/petition-helper.ts
+++ b/cypress/local-only/tests/integration/fileAPetitionUpdated/petition-helper.ts
@@ -83,7 +83,7 @@ export function fillPetitionerAndSpouseInformation(addPhone: boolean = false) {
cy.get('[data-testid="contactPrimary.city"]').type('Orlando');
cy.get('[data-testid="contactPrimary.state"]').select('AL');
cy.get('[data-testid="contactPrimary.postalCode"]').type('33233');
- cy.get('[data-testid="contactPrimary.placeOfLegalResidence"]').select('AL');
+ cy.get('[data-testid="contactPrimary-placeOfLegalResidence"]').select('AL');
cy.get('[data-testid="contact-primary-phone"]').type('3232323232');
cy.get('[data-testid="is-spouse-deceased-0"]').click();
cy.get('[data-testid="contact-secondary-name"]').type('John Spouse');
@@ -91,7 +91,7 @@ export function fillPetitionerAndSpouseInformation(addPhone: boolean = false) {
if (addPhone) {
cy.get('[data-testid="contact-secondary-phone"]').type('1232323232');
}
- cy.get('[data-testid="contactSecondary.placeOfLegalResidence"]').select('AK');
+ cy.get('[data-testid="contactSecondary-placeOfLegalResidence"]').select('AK');
cy.get('[data-testid="step-1-next-button"]').click();
}
@@ -145,10 +145,13 @@ export function fillPetitionerInformation() {
cy.get('[data-testid="step-1-next-button"]').click();
}
-export function fillIrsNoticeInformation(filePath: string) {
+export function fillIrsNoticeInformation(
+ filePath: string,
+ caseType: string = 'Deficiency',
+) {
cy.get('[data-testid="irs-notice-Yes"]').click();
cy.get('[data-testid="irs-notice-upload-0"]').attachFile(filePath);
- cy.get('[data-testid="case-type-select"]').select('Deficiency');
+ cy.get('[data-testid="case-type-select"]').select(caseType);
cy.get('[data-testid="redaction-acknowledgement-label"]').click();
cy.get('[data-testid="step-3-next-button"]').click();
}
@@ -255,7 +258,7 @@ export function fillPrimaryContact() {
cy.get('[data-testid="contactPrimary.postalCode"]').type(
contactInfo.postalCode,
);
- cy.get('[data-testid="contactPrimary.placeOfLegalResidence"]').select(
+ cy.get('[data-testid="contactPrimary-placeOfLegalResidence"]').select(
contactInfo.placeOfLegalResidence,
);
cy.get('[data-testid="contact-primary-phone"]').type(contactInfo.phone);
@@ -314,7 +317,7 @@ export function fillSecondaryContact(useSameAddress = true) {
secondaryContactInfo.postalCode,
);
}
- cy.get('[data-testid="contactSecondary.placeOfLegalResidence"]').select(
+ cy.get('[data-testid="contactSecondary-placeOfLegalResidence"]').select(
secondaryContactInfo.placeOfLegalResidence,
);
diff --git a/shared/src/business/entities/EntityConstants.ts b/shared/src/business/entities/EntityConstants.ts
index 1095fba7b1f..8a7cb6e74ac 100644
--- a/shared/src/business/entities/EntityConstants.ts
+++ b/shared/src/business/entities/EntityConstants.ts
@@ -1150,7 +1150,8 @@ export type AbbrevatedStates =
| keyof typeof US_STATES
| keyof typeof US_STATES_OTHER;
-export const STATE_NOT_AVAILABLE = 'N/A';
+export const NOT_AVAILABLE_OPTION = 'N/A';
+export const STATE_NOT_AVAILABLE = NOT_AVAILABLE_OPTION;
export const PARTY_TYPES = {
conservator: 'Conservator',
@@ -1628,6 +1629,11 @@ export const JUDGE_TITLES = [
] as const;
export type JudgeTitle = (typeof JUDGE_TITLES)[number];
+export const PETITION_TYPES = {
+ autoGenerated: 'autoGenerated',
+ userUploaded: 'userUploaded',
+};
+
export type FileUploadProgressType = {
file: any;
uploadProgress: (progressEvent: any) => void;
diff --git a/shared/src/business/entities/cases/ElectronicPetition.test.ts b/shared/src/business/entities/cases/ElectronicPetition.test.ts
index edcc79ad2ec..4768e35e7ca 100644
--- a/shared/src/business/entities/cases/ElectronicPetition.test.ts
+++ b/shared/src/business/entities/cases/ElectronicPetition.test.ts
@@ -4,9 +4,9 @@ import {
MAX_FILE_SIZE_BYTES,
MAX_FILE_SIZE_MB,
PARTY_TYPES,
+ PETITION_TYPES,
} from '../EntityConstants';
import { ElectronicPetition } from './ElectronicPetition';
-import { PETITION_TYPES } from '@web-client/presenter/actions/setupPetitionStateAction';
import { applicationContext } from '../../test/createTestApplicationContext';
describe('ElectronicPetition entity', () => {
diff --git a/shared/src/business/entities/cases/ElectronicPetition.ts b/shared/src/business/entities/cases/ElectronicPetition.ts
index 6164dc4de11..00a528db64e 100644
--- a/shared/src/business/entities/cases/ElectronicPetition.ts
+++ b/shared/src/business/entities/cases/ElectronicPetition.ts
@@ -4,7 +4,9 @@ import {
LEGACY_TRIAL_CITY_STRINGS,
MAX_FILE_SIZE_BYTES,
MAX_FILE_SIZE_MB,
+ NOT_AVAILABLE_OPTION,
PARTY_TYPES,
+ PETITION_TYPES,
PROCEDURE_TYPES,
ROLES,
TRIAL_CITY_STRINGS,
@@ -13,7 +15,6 @@ import {
import { ContactFactory } from '../contacts/ContactFactory';
import { JoiValidationConstants } from '../JoiValidationConstants';
import { JoiValidationEntity } from '../JoiValidationEntity';
-import { PETITION_TYPES } from '@web-client/presenter/actions/setupPetitionStateAction';
import { getContactPrimary, getContactSecondary } from './Case';
import joi from 'joi';
@@ -34,7 +35,6 @@ export class ElectronicPetition extends JoiValidationEntity {
public petitionFile?: object;
public petitionFileSize?: number;
public petitionFileId?: string;
- public petitionRedactionAcknowledgement?: boolean;
public preferredTrialCity: string;
public procedureType: string;
public stinFile?: object;
@@ -63,8 +63,6 @@ export class ElectronicPetition extends JoiValidationEntity {
this.petitionFile = rawCase.petitionFile;
this.petitionFileSize = rawCase.petitionFileSize;
this.petitionFileId = rawCase.petitionFileId;
- this.petitionRedactionAcknowledgement =
- rawCase.petitionRedactionAcknowledgement;
this.petitionType = rawCase.petitionType || PETITION_TYPES.userUploaded;
this.corporateDisclosureFile = rawCase.corporateDisclosureFile;
@@ -80,11 +78,9 @@ export class ElectronicPetition extends JoiValidationEntity {
});
this.petitioners = [contacts.primary];
-
if (contacts.secondary) {
- if (!contacts.secondary.phone) {
- contacts.secondary.phone = 'N/A';
- }
+ contacts.secondary.phone =
+ contacts.secondary.phone || NOT_AVAILABLE_OPTION;
this.petitioners.push(contacts.secondary);
}
}
@@ -178,11 +174,6 @@ export class ElectronicPetition extends JoiValidationEntity {
'*': 'Your Petition file size is empty',
'number.max': `Your Petition file size is too big. The maximum file size is ${MAX_FILE_SIZE_MB}MB.`,
}),
- petitionRedactionAcknowledgement: joi.boolean().when('petitionType', {
- is: JoiValidationConstants.STRING.valid(PETITION_TYPES.userUploaded),
- otherwise: joi.optional(),
- then: joi.boolean().optional().invalid(false),
- }),
petitionType: JoiValidationConstants.STRING.required().valid(
...Object.values(PETITION_TYPES),
),
diff --git a/shared/src/business/entities/cases/ElectronicPetitionInformationFactory.test.ts b/shared/src/business/entities/cases/ElectronicPetitionInformationFactory.test.ts
index 61e6b245a92..7ae0f72a765 100644
--- a/shared/src/business/entities/cases/ElectronicPetitionInformationFactory.test.ts
+++ b/shared/src/business/entities/cases/ElectronicPetitionInformationFactory.test.ts
@@ -5,9 +5,9 @@ import {
MAX_FILE_SIZE_BYTES,
MAX_FILE_SIZE_MB,
PARTY_TYPES,
+ PETITION_TYPES,
} from '../EntityConstants';
import { ElectronicPetitionInformationFactory } from './ElectronicPetitionInformationFactory';
-import { PETITION_TYPES } from '@web-client/presenter/actions/setupPetitionStateAction';
import { applicationContext } from '../../test/createTestApplicationContext';
describe('ElectronicPetitionInformationFactory entity', () => {
diff --git a/shared/src/business/entities/cases/ElectronicPetitionInformationFactory.ts b/shared/src/business/entities/cases/ElectronicPetitionInformationFactory.ts
index 2cc334cd3fa..89f6f6b1d79 100644
--- a/shared/src/business/entities/cases/ElectronicPetitionInformationFactory.ts
+++ b/shared/src/business/entities/cases/ElectronicPetitionInformationFactory.ts
@@ -2,7 +2,7 @@ import { ContactFactory } from '../contacts/ContactFactory';
import { ElectronicPetition } from './ElectronicPetition';
import { JoiValidationConstants } from '../JoiValidationConstants';
import { JoiValidationEntity } from '../JoiValidationEntity';
-import { PETITION_TYPES } from '@web-client/presenter/actions/setupPetitionStateAction';
+import { PETITION_TYPES } from '@shared/business/entities/EntityConstants';
import { getContactPrimary, getContactSecondary } from './Case';
import joi from 'joi';
diff --git a/shared/src/business/entities/cases/PaperPetition.ts b/shared/src/business/entities/cases/PaperPetition.ts
index 63b282e99e8..17e3ec0ccc1 100644
--- a/shared/src/business/entities/cases/PaperPetition.ts
+++ b/shared/src/business/entities/cases/PaperPetition.ts
@@ -2,6 +2,7 @@ import {
CASE_TYPES,
FILING_TYPES,
MAX_FILE_SIZE_MB,
+ NOT_AVAILABLE_OPTION,
PARTY_TYPES,
PAYMENT_STATUS,
PROCEDURE_TYPES,
@@ -145,9 +146,8 @@ export class PaperPetition extends JoiValidationEntity {
});
this.petitioners = [contacts.primary];
if (contacts.secondary) {
- if (!contacts.secondary.phone) {
- contacts.secondary.phone = 'N/A';
- }
+ contacts.secondary.phone =
+ contacts.secondary.phone || NOT_AVAILABLE_OPTION;
this.petitioners.push(contacts.secondary);
}
}
diff --git a/shared/src/business/entities/startCase/GeneratePetitionPdf.test.ts b/shared/src/business/entities/startCase/GeneratePetitionPdf.test.ts
new file mode 100644
index 00000000000..83a76c3b91e
--- /dev/null
+++ b/shared/src/business/entities/startCase/GeneratePetitionPdf.test.ts
@@ -0,0 +1,53 @@
+import { GeneratePetitionPdf } from '@shared/business/entities/startCase/GeneratePetitionPdf';
+
+describe('GeneratePetitionPdf', () => {
+ const VALID_ENTITY = {
+ caseCaptionExtension: 'TEST_caseCaptionExtension',
+ caseTitle: 'TEST_caseTitle',
+ contactPrimary: {
+ address1: 'test_address1',
+ city: 'test_city',
+ contactType: 'primary',
+ country: 'test_country',
+ countryType: 'test_countryType',
+ email: 'test_email',
+ name: 'test_name',
+ phone: 'test_phone',
+ postalCode: 'test_postalCode',
+ state: 'test_state',
+ },
+ hasIrsNotice: true,
+ hasUploadedIrsNotice: true,
+ originalCaseType: 'Deficiency',
+ petitionFacts: ['TEST_petitionFacts'],
+ petitionReasons: ['TEST_petitionReasons'],
+ preferredTrialCity: 'TEST_preferredTrialCity',
+ procedureType: 'Regular',
+ };
+
+ it('should create a valid instance of "GeneratePetitionPdf" entity', () => {
+ const entity = new GeneratePetitionPdf(VALID_ENTITY);
+
+ expect(entity).toBeDefined();
+
+ const errors = entity.getFormattedValidationErrors();
+ expect(errors).toEqual(null);
+ });
+
+ it('should throw validation errors when data is not valid', () => {
+ const entity = new GeneratePetitionPdf({});
+ const errors = entity.getFormattedValidationErrors();
+ expect(errors).toEqual({
+ caseCaptionExtension: '"caseCaptionExtension" is required',
+ caseTitle: '"caseTitle" is required',
+ contactPrimary: '"contactPrimary" is required',
+ hasIrsNotice: '"hasIrsNotice" is required',
+ hasUploadedIrsNotice: '"hasUploadedIrsNotice" is required',
+ originalCaseType: '"originalCaseType" is required',
+ petitionFacts: '"petitionFacts" is required',
+ petitionReasons: '"petitionReasons" is required',
+ preferredTrialCity: '"preferredTrialCity" is required',
+ procedureType: '"procedureType" is required',
+ });
+ });
+});
diff --git a/shared/src/business/entities/startCase/GeneratePetitionPdf.ts b/shared/src/business/entities/startCase/GeneratePetitionPdf.ts
new file mode 100644
index 00000000000..bf38dbfbc89
--- /dev/null
+++ b/shared/src/business/entities/startCase/GeneratePetitionPdf.ts
@@ -0,0 +1,75 @@
+import { CASE_TYPES, PARTY_TYPES, PROCEDURE_TYPES } from '../EntityConstants';
+import {
+ Contact,
+ ContactSecondary,
+ IrsNotice,
+} from '@shared/business/useCases/generatePetitionPdfInteractor';
+import { JoiValidationConstants } from '@shared/business/entities/JoiValidationConstants';
+import { JoiValidationEntity } from '@shared/business/entities/JoiValidationEntity';
+import joi from 'joi';
+
+export class GeneratePetitionPdf extends JoiValidationEntity {
+ public caseCaptionExtension: string;
+ public caseTitle: string;
+ public contactPrimary: Contact;
+ public contactSecondary?: ContactSecondary;
+ public hasUploadedIrsNotice: boolean;
+ public partyType: string;
+ public petitionFacts: string[];
+ public petitionReasons: string[];
+ public preferredTrialCity: string;
+ public procedureType: string;
+ public hasIrsNotice: boolean;
+ public originalCaseType: string;
+ public irsNotices: IrsNotice[];
+
+ constructor(rawProps) {
+ super('GeneratePetitionPdf');
+
+ this.caseCaptionExtension = rawProps.caseCaptionExtension;
+ this.caseTitle = rawProps.caseTitle;
+ this.contactPrimary = rawProps.contactPrimary;
+ this.contactSecondary = rawProps.contactSecondary;
+ this.hasUploadedIrsNotice = rawProps.hasUploadedIrsNotice;
+ this.partyType = rawProps.partyType;
+ this.petitionFacts = rawProps.petitionFacts;
+ this.petitionReasons = rawProps.petitionReasons;
+ this.preferredTrialCity = rawProps.preferredTrialCity;
+ this.procedureType = rawProps.procedureType;
+ this.hasIrsNotice = rawProps.hasIrsNotice;
+ this.originalCaseType = rawProps.originalCaseType;
+ this.irsNotices = rawProps.irsNotices;
+ }
+
+ static VALIDATION_RULES = {
+ caseCaptionExtension: joi.string().required(),
+ caseTitle: joi.string().required(),
+ contactPrimary: joi.object().required(),
+ contactSecondary: joi.object().optional(),
+ hasIrsNotice: joi.boolean().required(),
+ hasUploadedIrsNotice: joi.boolean().required(),
+ irsNotices: joi.array(),
+ originalCaseType: JoiValidationConstants.STRING.valid(
+ ...CASE_TYPES,
+ 'Disclosure1',
+ 'Disclosure2',
+ ).required(),
+ partyType: JoiValidationConstants.STRING.valid(
+ ...Object.values(PARTY_TYPES),
+ ),
+ petitionFacts: joi.array().min(1).items(joi.string()).required(),
+ petitionReasons: joi.array().min(1).items(joi.string()).required(),
+ preferredTrialCity: joi.string().required(),
+ procedureType: JoiValidationConstants.STRING.valid(
+ ...PROCEDURE_TYPES,
+ ).required(),
+ };
+
+ getValidationRules() {
+ return GeneratePetitionPdf.VALIDATION_RULES;
+ }
+}
+
+export type RawGeneratePetitionPdf = ExcludeMethods<
+ Omit {taxYear || 'N/A'} {irsNotices[0].taxYear || NOT_AVAILABLE_OPTION}
{irsNotices.map(irsNotice => (
) : (
-
{petitionReasons.map(reason => {
- return
{petitionFacts.map(fact => {
- return
@@ -274,7 +267,7 @@ const renderIrsNotice = irsNotice => {
} else {
return (
- {`${irsNotice.noticeIssuedDateFormatted || 'N/A'} - ${irsNotice.cityAndStateIssuingOffice || 'N/A'}`}
+ {`${irsNotice.noticeIssuedDateFormatted || NOT_AVAILABLE_OPTION} - ${irsNotice.cityAndStateIssuingOffice || NOT_AVAILABLE_OPTION}`}
);
}
diff --git a/shared/src/proxies/generatePetitionPdfProxy.ts b/shared/src/proxies/generatePetitionPdfProxy.ts
index b5514287e6d..9e2f1e74fe4 100644
--- a/shared/src/proxies/generatePetitionPdfProxy.ts
+++ b/shared/src/proxies/generatePetitionPdfProxy.ts
@@ -1,28 +1,29 @@
+import {
+ IrsNotice,
+ PetitionPdfBase,
+} from '@shared/business/useCases/generatePetitionPdfInteractor';
import { post } from '@shared/proxies/requests';
export const generatePetitionPdfInteractor = (
- applicationContext: IApplicationContext,
+ applicationContext,
{
caseCaptionExtension,
- caseDescription,
caseTitle,
contactPrimary,
contactSecondary,
hasIrsNotice,
hasUploadedIrsNotice,
irsNotices,
+ originalCaseType,
partyType,
petitionFacts,
petitionReasons,
preferredTrialCity,
procedureType,
- taxYear,
- }: {
- //TODO: Type remaining properties
- [key: string]: any;
- caseDescription: string;
+ }: PetitionPdfBase & {
hasIrsNotice: boolean;
- hasUploadedIrsNotice: boolean;
+ originalCaseType: string;
+ irsNotices: IrsNotice[];
},
): Promise<{
fileId: string;
@@ -31,19 +32,18 @@ export const generatePetitionPdfInteractor = (
applicationContext,
body: {
caseCaptionExtension,
- caseDescription,
caseTitle,
contactPrimary,
contactSecondary,
hasIrsNotice,
hasUploadedIrsNotice,
irsNotices,
+ originalCaseType,
partyType,
petitionFacts,
petitionReasons,
preferredTrialCity,
procedureType,
- taxYear,
},
endpoint: '/cases/generate-petition',
});
diff --git a/web-client/src/presenter/actions/CaseCreation/updatedSetupFilesForCaseCreationAction.ts b/web-client/src/presenter/actions/CaseCreation/updatedSetupFilesForCaseCreationAction.ts
index d8596eceeae..b2935977f42 100644
--- a/web-client/src/presenter/actions/CaseCreation/updatedSetupFilesForCaseCreationAction.ts
+++ b/web-client/src/presenter/actions/CaseCreation/updatedSetupFilesForCaseCreationAction.ts
@@ -14,7 +14,7 @@ export const updatedSetupFilesForCaseCreationAction = ({
requestForPlaceOfTrialFile,
stinFile,
} = petitionMetadata;
- // need to do this elsewhere?
+
const attachmentsToPetition: File[] | undefined = hasIrsNotice
? (irsNotices
?.map(irsNotice => irsNotice.file)
diff --git a/web-client/src/presenter/actions/StartCase/setDefaultContactStateAction.ts b/web-client/src/presenter/actions/StartCase/setDefaultContactStateAction.ts
index dd702f09f32..81e17352d99 100644
--- a/web-client/src/presenter/actions/StartCase/setDefaultContactStateAction.ts
+++ b/web-client/src/presenter/actions/StartCase/setDefaultContactStateAction.ts
@@ -38,16 +38,11 @@ export const setDefaultContactStateAction = ({
store.unset(state.form.useSameAsPrimary);
store.unset(state.form.isSpouseDeceased);
store.unset(state.form.hasSpouseConsent);
- return;
- }
-
- if (showContactSecondary) {
- store.set(state.form.contactSecondary, {});
- store.set(state.form.hasSpouseConsent, false);
- store.set(state.form.useSameAsPrimary, true);
} else {
+ const useSameAsPrimary = showContactSecondary;
+
store.set(state.form.contactSecondary, {});
store.set(state.form.hasSpouseConsent, false);
- store.set(state.form.useSameAsPrimary, false);
+ store.set(state.form.useSameAsPrimary, useSameAsPrimary);
}
};
diff --git a/web-client/src/presenter/actions/StartCase/updatePartyTypeActionUpdated.ts b/web-client/src/presenter/actions/StartCase/updatePartyTypeActionUpdated.ts
index 9dc02416c6b..5eb0e1a1d0c 100644
--- a/web-client/src/presenter/actions/StartCase/updatePartyTypeActionUpdated.ts
+++ b/web-client/src/presenter/actions/StartCase/updatePartyTypeActionUpdated.ts
@@ -26,8 +26,7 @@ export const updatePartyTypeActionUpdated = ({
};
const handleFilingType = () => {
- const { value } = props;
- if (value === 'Myself' || value === 'Individual petitioner') {
+ if (props.value === 'Myself' || props.value === 'Individual petitioner') {
updatePartyType(PARTY_TYPES.petitioner);
}
resetFormFields();
@@ -49,16 +48,15 @@ export const updatePartyTypeActionUpdated = ({
store.unset(state.form.minorIncompetentType);
store.unset(state.form.partyType);
- const { value } = props;
- store.set(state.form.otherType, value);
+ store.set(state.form.otherType, props.value);
- if (value === 'Deceased Spouse') {
+ if (props.value === 'Deceased Spouse') {
updatePartyType(PARTY_TYPES.survivingSpouse);
return;
}
- if (value === 'Donor' || value === 'Transferee') {
- updatePartyType(value);
+ if (props.value === 'Donor' || props.value === 'Transferee') {
+ updatePartyType(props.value);
}
};
diff --git a/web-client/src/presenter/actions/StartCaseInternal/resetContactSecondaryAddressAction.test.ts b/web-client/src/presenter/actions/StartCaseInternal/resetContactSecondaryAddressAction.test.ts
deleted file mode 100644
index 166cbaab0d6..00000000000
--- a/web-client/src/presenter/actions/StartCaseInternal/resetContactSecondaryAddressAction.test.ts
+++ /dev/null
@@ -1,26 +0,0 @@
-import { resetContactSecondaryAddressAction } from '@web-client/presenter/actions/StartCaseInternal/resetContactSecondaryAddressAction';
-import { runAction } from '@web-client/presenter/test.cerebral';
-
-describe('resetContactSecondaryAddressAction', () => {
- it('should clear state correctly', async () => {
- const results = await runAction(resetContactSecondaryAddressAction, {
- state: {
- form: {
- contactSecondary: {
- address1: 'TEST_address1',
- address2: 'TEST_address2',
- address3: 'TEST_address3',
- city: 'TEST_city',
- phone: 'TEST_phone',
- placeOfLegalResidence: 'TEST_placeOfLegalResidence',
- postalCode: 'TEST_postalCode',
- state: 'TEST_state',
- },
- },
- },
- });
-
- const { contactSecondary } = results.state.form;
- expect(contactSecondary).toEqual({});
- });
-});
diff --git a/web-client/src/presenter/actions/StartCaseInternal/resetContactSecondaryAddressAction.ts b/web-client/src/presenter/actions/StartCaseInternal/resetContactSecondaryAddressAction.ts
deleted file mode 100644
index a592a4dc17f..00000000000
--- a/web-client/src/presenter/actions/StartCaseInternal/resetContactSecondaryAddressAction.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-import { state } from '@web-client/presenter/app.cerebral';
-
-export const resetContactSecondaryAddressAction = ({ store }: ActionProps) => {
- store.unset(state.form.contactSecondary.address1);
- store.unset(state.form.contactSecondary.address2);
- store.unset(state.form.contactSecondary.address3);
- store.unset(state.form.contactSecondary.city);
- store.unset(state.form.contactSecondary.phone);
- store.unset(state.form.contactSecondary.placeOfLegalResidence);
- store.unset(state.form.contactSecondary.postalCode);
- store.unset(state.form.contactSecondary.state);
-};
diff --git a/web-client/src/presenter/actions/addAnotherIrsNoticeToFormAction.ts b/web-client/src/presenter/actions/addAnotherIrsNoticeToFormAction.ts
index b7267248088..89535d4ca57 100644
--- a/web-client/src/presenter/actions/addAnotherIrsNoticeToFormAction.ts
+++ b/web-client/src/presenter/actions/addAnotherIrsNoticeToFormAction.ts
@@ -6,11 +6,14 @@ export const addAnotherIrsNoticeToFormAction = ({
get,
store,
}: ActionProps) => {
- const data = get(state.irsNoticeUploadFormInfo);
- if (data.length >= 5) return;
- data.push({
+ const irsNoticeUploadFormInfo = get(state.irsNoticeUploadFormInfo);
+
+ const MAX_NUMBER_OF_IRS_NOTICE = 5;
+ if (irsNoticeUploadFormInfo.length >= MAX_NUMBER_OF_IRS_NOTICE) return;
+
+ irsNoticeUploadFormInfo.push({
key: applicationContext.getUniqueId(),
todayDate: applicationContext.getUtilities().formatNow(FORMATS.YYYYMMDD),
});
- store.set(state.irsNoticeUploadFormInfo, data);
+ store.set(state.irsNoticeUploadFormInfo, irsNoticeUploadFormInfo);
};
diff --git a/web-client/src/presenter/actions/formatPetitionAction.test.ts b/web-client/src/presenter/actions/formatPetitionAction.test.ts
index 26491da04bf..3da96571ddd 100644
--- a/web-client/src/presenter/actions/formatPetitionAction.test.ts
+++ b/web-client/src/presenter/actions/formatPetitionAction.test.ts
@@ -6,21 +6,22 @@ import { runAction } from '@web-client/presenter/test.cerebral';
describe('formatPetitionAction', () => {
const PROPS = {
- step1Data: {
+ createPetitionStep1Data: {
contactPrimary: {},
},
- step2Data: {},
- step3Data: {
+ createPetitionStep2Data: {},
+ createPetitionStep3Data: {
caseType: CASE_TYPES_MAP.cdp,
irsNotices: [
{
+ caseType: CASE_TYPES_MAP.cdp,
noticeIssuedDate: 'TEST_noticeIssuedDate',
taxYear: 'TEST_taxYear',
},
],
},
- step4Data: {},
- step5Data: {},
+ createPetitionStep4Data: {},
+ createPetitionStep5Data: {},
};
const TEST_CASE_CAPTION = 'TEST_CASE_CAPTION';
@@ -52,7 +53,6 @@ describe('formatPetitionAction', () => {
expect(results.state.petitionFormatted).toEqual({
caseCaption: 'TEST_CASE_CAPTION',
caseCaptionExtension: '',
- caseDescription: 'Collection (Lien/Levy)',
caseTitle: 'TEST_CASE_CAPTION',
caseType: CASE_TYPES_MAP.cdp,
contactPrimary: {
@@ -60,12 +60,13 @@ describe('formatPetitionAction', () => {
},
irsNotices: [
{
+ caseType: CASE_TYPES_MAP.cdp,
noticeIssuedDate: 'TEST_noticeIssuedDate',
+ originalCaseType: CASE_TYPES_MAP.cdp,
taxYear: 'TEST_taxYear',
},
],
- noticeIssuedDate: 'TEST_noticeIssuedDate',
- taxYear: 'TEST_taxYear',
+ originalCaseType: CASE_TYPES_MAP.cdp,
});
});
@@ -87,7 +88,6 @@ describe('formatPetitionAction', () => {
expect(results.state.petitionFormatted).toEqual({
caseCaption: '',
caseCaptionExtension: '',
- caseDescription: 'Collection (Lien/Levy)',
caseTitle: '',
caseType: CASE_TYPES_MAP.cdp,
contactPrimary: {
@@ -95,22 +95,24 @@ describe('formatPetitionAction', () => {
},
irsNotices: [
{
+ caseType: CASE_TYPES_MAP.cdp,
noticeIssuedDate: 'TEST_noticeIssuedDate',
+ originalCaseType: CASE_TYPES_MAP.cdp,
taxYear: 'TEST_taxYear',
},
],
- noticeIssuedDate: 'TEST_noticeIssuedDate',
- taxYear: 'TEST_taxYear',
+ originalCaseType: CASE_TYPES_MAP.cdp,
});
});
it('should update caseType if caseType is a disclosure', async () => {
const propsWithDisclosure = {
...PROPS,
- step3Data: {
+ createPetitionStep3Data: {
caseType: 'Disclosure1',
irsNotices: [
{
+ caseType: 'Disclosure1',
noticeIssuedDate: 'TEST_noticeIssuedDate',
taxYear: 'TEST_taxYear',
},
@@ -137,19 +139,20 @@ describe('formatPetitionAction', () => {
},
irsNotices: [
{
+ caseType: CASE_TYPES_MAP.disclosure,
noticeIssuedDate: 'TEST_noticeIssuedDate',
+ originalCaseType: 'Disclosure1',
taxYear: 'TEST_taxYear',
},
],
- noticeIssuedDate: 'TEST_noticeIssuedDate',
- taxYear: 'TEST_taxYear',
+ originalCaseType: 'Disclosure1',
});
});
it('should set noticeIssuedDate and taxYear as undefined if there is no irsNotice', async () => {
const propsWithoutIrsNotice = {
...PROPS,
- step3Data: {
+ createPetitionStep3Data: {
caseType: CASE_TYPES_MAP.deficiency,
irsNotices: [],
},
@@ -167,15 +170,13 @@ describe('formatPetitionAction', () => {
expect(results.state.petitionFormatted).toEqual({
caseCaption: 'TEST_CASE_CAPTION',
caseCaptionExtension: '',
- caseDescription: 'Deficiency',
caseTitle: 'TEST_CASE_CAPTION',
caseType: CASE_TYPES_MAP.deficiency,
contactPrimary: {
email: 'TEST_EMAIL',
},
irsNotices: [],
- noticeIssuedDate: undefined,
- taxYear: undefined,
+ originalCaseType: CASE_TYPES_MAP.deficiency,
});
});
});
diff --git a/web-client/src/presenter/actions/formatPetitionAction.ts b/web-client/src/presenter/actions/formatPetitionAction.ts
index 6da456f301b..d71ab160909 100644
--- a/web-client/src/presenter/actions/formatPetitionAction.ts
+++ b/web-client/src/presenter/actions/formatPetitionAction.ts
@@ -1,7 +1,4 @@
-import {
- CASE_TYPE_DESCRIPTIONS_WITHOUT_IRS_NOTICE,
- CASE_TYPE_DESCRIPTIONS_WITH_IRS_NOTICE,
-} from '@shared/business/entities/EntityConstants';
+import { CASE_TYPES_MAP } from '@shared/business/entities/EntityConstants';
import { getCaseCaptionMeta } from '@shared/business/utilities/getCaseCaptionMeta';
import { state } from '@web-client/presenter/app.cerebral';
@@ -11,11 +8,11 @@ export const formatPetitionAction = ({
store,
}: ActionProps) => {
const petitionInfo = {
- ...props.step1Data,
- ...props.step2Data,
- ...props.step3Data,
- ...props.step4Data,
- ...props.step5Data,
+ ...props.createPetitionStep1Data,
+ ...props.createPetitionStep2Data,
+ ...props.createPetitionStep3Data,
+ ...props.createPetitionStep4Data,
+ ...props.createPetitionStep5Data,
};
const caseCaption =
@@ -27,37 +24,35 @@ export const formatPetitionAction = ({
caseCaption,
});
- const caseDescription = petitionInfo.hasIrsNotice
- ? CASE_TYPE_DESCRIPTIONS_WITH_IRS_NOTICE[petitionInfo.caseType]
- : CASE_TYPE_DESCRIPTIONS_WITHOUT_IRS_NOTICE[petitionInfo.caseType];
-
- const { CASE_TYPES_MAP } = applicationContext.getConstants();
- const disclosureCaseTypes = ['Disclosure1', 'Disclosure2'];
-
- if (disclosureCaseTypes.includes(petitionInfo.caseType)) {
- petitionInfo.caseType = CASE_TYPES_MAP.disclosure;
- }
+ petitionInfo.originalCaseType = petitionInfo.caseType;
+ petitionInfo.caseType = formatCaseType(petitionInfo.caseType);
const { contactPrimary, irsNotices } = petitionInfo;
const user = applicationContext.getCurrentUser();
contactPrimary.email = user.email;
- let noticeIssuedDate;
- let taxYear;
-
- if (irsNotices[0]) {
- ({ noticeIssuedDate, taxYear } = irsNotices[0]);
- }
+ const irsNoticesWithCaseTypes = irsNotices.map(irsNotice => {
+ return {
+ ...irsNotice,
+ caseType: formatCaseType(irsNotice.caseType),
+ originalCaseType: irsNotice.caseType,
+ };
+ });
store.set(state.petitionFormatted, {
...petitionInfo,
caseCaption,
caseCaptionExtension,
- caseDescription,
caseTitle,
contactPrimary,
- noticeIssuedDate,
- taxYear,
+ irsNotices: irsNoticesWithCaseTypes,
});
};
+
+function formatCaseType(caseType: string) {
+ if (caseType === 'Disclosure1' || caseType === 'Disclosure2') {
+ return CASE_TYPES_MAP.disclosure;
+ }
+ return caseType;
+}
diff --git a/web-client/src/presenter/actions/formatPetitionFactsAndReasonsAction.test.ts b/web-client/src/presenter/actions/formatPetitionFactsAndReasonsAction.test.ts
new file mode 100644
index 00000000000..a9267bfeb10
--- /dev/null
+++ b/web-client/src/presenter/actions/formatPetitionFactsAndReasonsAction.test.ts
@@ -0,0 +1,35 @@
+import { formatPetitionFactsAndReasonsAction } from '@web-client/presenter/actions/formatPetitionFactsAndReasonsAction';
+import { runAction } from '@web-client/presenter/test.cerebral';
+
+describe('formatPetitionFactsAndReasonsAction', () => {
+ it('should filter empty reasons and facts', async () => {
+ const results = await runAction(formatPetitionFactsAndReasonsAction, {
+ state: {
+ form: {
+ petitionFacts: ['fact1', '', 'fact2', 'fact3'],
+ petitionReasons: ['reason1', '', 'reason2', ''],
+ },
+ },
+ });
+
+ const { petitionFacts, petitionReasons } = results.state.form;
+
+ expect(petitionFacts).toEqual(['fact1', 'fact2', 'fact3']);
+ expect(petitionReasons).toEqual(['reason1', 'reason2']);
+ });
+
+ it('should default reasons and facts when no values are present', async () => {
+ const results = await runAction(formatPetitionFactsAndReasonsAction, {
+ state: {
+ form: {
+ petitionFacts: ['', '', '', ''],
+ petitionReasons: ['', ''],
+ },
+ },
+ });
+
+ const { petitionFacts, petitionReasons } = results.state.form;
+ expect(petitionFacts).toEqual(['']);
+ expect(petitionReasons).toEqual(['']);
+ });
+});
diff --git a/web-client/src/presenter/actions/formatPetitionFactsAndReasonsAction.ts b/web-client/src/presenter/actions/formatPetitionFactsAndReasonsAction.ts
new file mode 100644
index 00000000000..3c1411c8953
--- /dev/null
+++ b/web-client/src/presenter/actions/formatPetitionFactsAndReasonsAction.ts
@@ -0,0 +1,19 @@
+import { state } from '@web-client/presenter/app.cerebral';
+
+export const formatPetitionFactsAndReasonsAction = ({
+ get,
+ store,
+}: ActionProps) => {
+ const { petitionFacts, petitionReasons } = get(state.form);
+
+ const filteredPetitionReasons = filterAndDefault(petitionReasons);
+ const filteredPetitionFacts = filterAndDefault(petitionFacts);
+
+ store.set(state.form.petitionReasons, filteredPetitionReasons);
+ store.set(state.form.petitionFacts, filteredPetitionFacts);
+};
+
+function filterAndDefault(arr) {
+ const filteredArr = arr.filter(r => !!r.trim());
+ return filteredArr.length > 0 ? filteredArr : [''];
+}
diff --git a/web-client/src/presenter/actions/generatePetitionPdfAction.test.ts b/web-client/src/presenter/actions/generatePetitionPdfAction.test.ts
index 370f8865bbb..3d3c37ce2b9 100644
--- a/web-client/src/presenter/actions/generatePetitionPdfAction.test.ts
+++ b/web-client/src/presenter/actions/generatePetitionPdfAction.test.ts
@@ -1,27 +1,20 @@
-import { FORMATS } from '@shared/business/utilities/DateHandler';
-import { PETITION_TYPES } from '@web-client/presenter/actions/setupPetitionStateAction';
+import { PETITION_TYPES } from '@shared/business/entities/EntityConstants';
import { applicationContextForClient as applicationContext } from '@web-client/test/createClientTestApplicationContext';
import { generatePetitionPdfAction } from '@web-client/presenter/actions/generatePetitionPdfAction';
import { presenter } from '../presenter-mock';
import { runAction } from '@web-client/presenter/test.cerebral';
describe('generatePetitionPdfAction', () => {
- beforeAll(() => {
+ beforeEach(() => {
applicationContext
.getUseCases()
- .generatePetitionPdfInteractor.mockImplementation(
- () =>
- new Promise(resolve =>
- resolve({
- fileId: 'TEST_FILE_ID',
- url: 'TEST_URL',
- }),
- ),
- );
-
- applicationContext
- .getUtilities()
- .formatDateString.mockImplementation(() => 'RESULTS_formatDateString');
+ .generatePetitionPdfInteractor.mockImplementation(() => {
+ return new Promise(resolve =>
+ resolve({
+ fileId: 'TEST_FILE_ID',
+ }),
+ );
+ });
presenter.providers.applicationContext = applicationContext;
});
@@ -33,18 +26,34 @@ describe('generatePetitionPdfAction', () => {
},
state: {
petitionFormatted: {
- petitionType: 'NOT AUTO GENERATED',
+ petitionType: PETITION_TYPES.userUploaded,
},
},
});
-
const generatePetitionPdfInteractorCalls =
applicationContext.getUseCases().generatePetitionPdfInteractor.mock.calls;
+
expect(generatePetitionPdfInteractorCalls.length).toEqual(0);
expect(results.output).toEqual(undefined);
});
+ it('should throw an error if data is invalid', async () => {
+ await expect(
+ runAction(generatePetitionPdfAction, {
+ modules: {
+ presenter,
+ },
+ state: {
+ petitionFormatted: {
+ petitionType: PETITION_TYPES.autoGenerated,
+ testData: 'test',
+ },
+ },
+ }),
+ ).rejects.toThrow('Petition PDF generation failed due to invalid data.');
+ });
+
it('should generate the petition and save id in state when petition is auto generated', async () => {
const results = await runAction(generatePetitionPdfAction, {
modules: {
@@ -52,29 +61,87 @@ describe('generatePetitionPdfAction', () => {
},
state: {
petitionFormatted: {
- noticeIssuedDate: 'TEST_noticeIssuedDate',
+ caseCaptionExtension: 'TEST_caseCaptionExtension',
+ caseTitle: 'TEST_caseTitle',
+ contactPrimary: {},
+ hasIrsNotice: true,
+ hasUploadedIrsNotice: true,
+ originalCaseType: 'Deficiency',
+ petitionFacts: ['TEST_petitionFacts'],
petitionFileId: undefined,
petitionProp: 'TEST_PROP',
+ petitionReasons: ['TEST_petitionReasons'],
petitionType: PETITION_TYPES.autoGenerated,
+ preferredTrialCity: 'TEST_preferredTrialCity',
+ procedureType: 'Regular',
},
},
});
const generatePetitionPdfInteractorCalls =
applicationContext.getUseCases().generatePetitionPdfInteractor.mock.calls;
+
expect(generatePetitionPdfInteractorCalls.length).toEqual(1);
expect(generatePetitionPdfInteractorCalls[0][1]).toEqual({
- noticeIssuedDate: 'RESULTS_formatDateString',
- petitionFileId: undefined,
- petitionProp: 'TEST_PROP',
- petitionType: 'autoGenerated',
+ caseCaptionExtension: 'TEST_caseCaptionExtension',
+ caseTitle: 'TEST_caseTitle',
+ contactPrimary: {},
+ entityName: 'GeneratePetitionPdf',
+ hasIrsNotice: true,
+ hasUploadedIrsNotice: true,
+ originalCaseType: 'Deficiency',
+ petitionFacts: ['TEST_petitionFacts'],
+ petitionReasons: ['TEST_petitionReasons'],
+ preferredTrialCity: 'TEST_preferredTrialCity',
+ procedureType: 'Regular',
});
- const formatDateStringCalls =
- applicationContext.getUtilities().formatDateString.mock.calls;
- expect(formatDateStringCalls.length).toEqual(1);
- expect(formatDateStringCalls[0][0]).toEqual('TEST_noticeIssuedDate');
- expect(formatDateStringCalls[0][1]).toEqual(FORMATS.MMDDYY);
+ expect(results.state.petitionFormatted.petitionFileId).toEqual(
+ 'TEST_FILE_ID',
+ );
+ });
+
+ it('should generate the petition for disclosure case types', async () => {
+ const results = await runAction(generatePetitionPdfAction, {
+ modules: {
+ presenter,
+ },
+ state: {
+ petitionFormatted: {
+ caseCaptionExtension: 'TEST_caseCaptionExtension',
+ caseTitle: 'TEST_caseTitle',
+ contactPrimary: {},
+ hasIrsNotice: true,
+ hasUploadedIrsNotice: true,
+ originalCaseType: 'Disclosure1',
+ petitionFacts: ['TEST_petitionFacts'],
+ petitionFileId: undefined,
+ petitionProp: 'TEST_PROP',
+ petitionReasons: ['TEST_petitionReasons'],
+ petitionType: PETITION_TYPES.autoGenerated,
+ preferredTrialCity: 'TEST_preferredTrialCity',
+ procedureType: 'Regular',
+ },
+ },
+ });
+
+ const generatePetitionPdfInteractorCalls =
+ applicationContext.getUseCases().generatePetitionPdfInteractor.mock.calls;
+
+ expect(generatePetitionPdfInteractorCalls.length).toEqual(1);
+ expect(generatePetitionPdfInteractorCalls[0][1]).toEqual({
+ caseCaptionExtension: 'TEST_caseCaptionExtension',
+ caseTitle: 'TEST_caseTitle',
+ contactPrimary: {},
+ entityName: 'GeneratePetitionPdf',
+ hasIrsNotice: true,
+ hasUploadedIrsNotice: true,
+ originalCaseType: 'Disclosure1',
+ petitionFacts: ['TEST_petitionFacts'],
+ petitionReasons: ['TEST_petitionReasons'],
+ preferredTrialCity: 'TEST_preferredTrialCity',
+ procedureType: 'Regular',
+ });
expect(results.state.petitionFormatted.petitionFileId).toEqual(
'TEST_FILE_ID',
diff --git a/web-client/src/presenter/actions/generatePetitionPdfAction.ts b/web-client/src/presenter/actions/generatePetitionPdfAction.ts
index 264d038abe9..da19e716799 100644
--- a/web-client/src/presenter/actions/generatePetitionPdfAction.ts
+++ b/web-client/src/presenter/actions/generatePetitionPdfAction.ts
@@ -1,5 +1,5 @@
-import { FORMATS } from '@shared/business/utilities/DateHandler';
-import { PETITION_TYPES } from '@web-client/presenter/actions/setupPetitionStateAction';
+import { GeneratePetitionPdf } from '@shared/business/entities/startCase/GeneratePetitionPdf';
+import { PETITION_TYPES } from '@shared/business/entities/EntityConstants';
import { state } from '@web-client/presenter/app.cerebral';
export const generatePetitionPdfAction = async ({
@@ -11,17 +11,21 @@ export const generatePetitionPdfAction = async ({
const { petitionType } = petition;
- if (petitionType === PETITION_TYPES.autoGenerated) {
- const { fileId } = await applicationContext
- .getUseCases()
- .generatePetitionPdfInteractor(applicationContext, {
- ...petition,
- // do this in interactor
- noticeIssuedDate: applicationContext
- .getUtilities()
- .formatDateString(petition.noticeIssuedDate || '', FORMATS.MMDDYY),
- });
+ if (petitionType !== PETITION_TYPES.autoGenerated) return;
- store.set(state.petitionFormatted.petitionFileId, fileId);
+ const generatePetitionPdfEntity = new GeneratePetitionPdf(petition);
+ const errors = generatePetitionPdfEntity.getFormattedValidationErrors();
+ if (errors) {
+ throw Error(
+ `Petition PDF generation failed due to invalid data. ${JSON.stringify(errors)}`,
+ );
}
+
+ const generatePetitionPdfData = generatePetitionPdfEntity.toRawObject();
+
+ const { fileId } = await applicationContext
+ .getUseCases()
+ .generatePetitionPdfInteractor(applicationContext, generatePetitionPdfData);
+
+ store.set(state.petitionFormatted.petitionFileId, fileId);
};
diff --git a/web-client/src/presenter/actions/generatePetitionPreviewPdfUrlAction.test.ts b/web-client/src/presenter/actions/generatePetitionPreviewPdfUrlAction.test.ts
index e3ee7768153..04349ee66e4 100644
--- a/web-client/src/presenter/actions/generatePetitionPreviewPdfUrlAction.test.ts
+++ b/web-client/src/presenter/actions/generatePetitionPreviewPdfUrlAction.test.ts
@@ -55,11 +55,15 @@ describe('generatePetitionPreviewPdfUrlAction', () => {
corporateDisclosureFile: b64File,
hasIrsNotice: true,
irsNotices: [{ file: b64File }],
+ petitionFile: b64File,
stinFile: b64File,
},
},
});
+ expect(result.state.petitionFormatted.petitionFileUrl).toEqual(
+ 'fakePdfUri',
+ );
expect(result.state.petitionFormatted.stinFileUrl).toEqual('fakePdfUri');
expect(result.state.petitionFormatted.corporateDisclosureFileUrl).toEqual(
'fakePdfUri',
diff --git a/web-client/src/presenter/actions/generatePetitionPreviewPdfUrlAction.ts b/web-client/src/presenter/actions/generatePetitionPreviewPdfUrlAction.ts
index 332a83069d0..adc27194377 100644
--- a/web-client/src/presenter/actions/generatePetitionPreviewPdfUrlAction.ts
+++ b/web-client/src/presenter/actions/generatePetitionPreviewPdfUrlAction.ts
@@ -6,41 +6,29 @@ export const generatePetitionPreviewPdfUrlAction = async ({
store,
}: ActionProps) => {
const petitionFormatted = get(state.petitionFormatted);
- if (petitionFormatted.corporateDisclosureFile) {
- const url = await generatePdfUrl(
- petitionFormatted.corporateDisclosureFile,
- applicationContext,
- );
- store.set(state.petitionFormatted.corporateDisclosureFileUrl, url);
- }
- if (petitionFormatted.stinFile) {
- const url = await generatePdfUrl(
- petitionFormatted.stinFile,
- applicationContext,
- );
- store.set(state.petitionFormatted.stinFileUrl, url);
- }
+ const KEYS = ['corporateDisclosureFile', 'stinFile', 'petitionFile'];
+ for (let index = 0; index < KEYS.length; index++) {
+ const key = KEYS[index];
+ if (!petitionFormatted[key]) continue;
- if (petitionFormatted.petitionFile) {
const url = await generatePdfUrl(
- petitionFormatted.petitionFile,
+ petitionFormatted[key],
applicationContext,
);
- store.set(state.petitionFormatted.petitionFileUrl, url);
- }
- if (petitionFormatted.hasIrsNotice && petitionFormatted.irsNotices?.length) {
- petitionFormatted.irsNotices.forEach(async (irsNotice, index) => {
- if (irsNotice.file) {
- const url = await generatePdfUrl(irsNotice.file, applicationContext);
- store.set(
- state.petitionFormatted.irsNotices![index].irsNoticeFileUrl,
- url,
- );
- }
- });
+ const stateKey = `${key}Url`;
+ store.set(state.petitionFormatted[stateKey], url);
}
+
+ if (!petitionFormatted.hasIrsNotice || !petitionFormatted.irsNotices?.length)
+ return;
+
+ petitionFormatted.irsNotices.forEach(async (irsNotice, index) => {
+ if (!irsNotice.file) return;
+ const url = await generatePdfUrl(irsNotice.file, applicationContext);
+ store.set(state.petitionFormatted.irsNotices![index].irsNoticeFileUrl, url);
+ });
};
function generatePdfUrl(file, applicationContext) {
diff --git a/web-client/src/presenter/actions/getStep1DataAction.test.ts b/web-client/src/presenter/actions/getCreatePetitionStep1DataAction.test.ts
similarity index 87%
rename from web-client/src/presenter/actions/getStep1DataAction.test.ts
rename to web-client/src/presenter/actions/getCreatePetitionStep1DataAction.test.ts
index 7b6d4728e8f..82663538546 100644
--- a/web-client/src/presenter/actions/getStep1DataAction.test.ts
+++ b/web-client/src/presenter/actions/getCreatePetitionStep1DataAction.test.ts
@@ -1,8 +1,8 @@
import { CONTACT_TYPES } from '@shared/business/entities/EntityConstants';
-import { getStep1DataAction } from '@web-client/presenter/actions/getStep1DataAction';
+import { getCreatePetitionStep1DataAction } from '@web-client/presenter/actions/getCreatePetitionStep1DataAction';
import { runAction } from '@web-client/presenter/test.cerebral';
-describe('getStep1DataAction', () => {
+describe('getCreatePetitionStep1DataAction', () => {
const STATE_FORM = {
businessType: 'TEST_businessType',
corporateDisclosureFile: 'TEST_corporateDisclosureFile',
@@ -19,7 +19,7 @@ describe('getStep1DataAction', () => {
};
it('should fetch step 2 related data from state.form when useSameAsPrimary is true', async () => {
- const results = await runAction(getStep1DataAction, {
+ const results = await runAction(getCreatePetitionStep1DataAction, {
state: {
form: {
...STATE_FORM,
@@ -43,8 +43,8 @@ describe('getStep1DataAction', () => {
},
});
- const { step1Data } = results.output;
- expect(step1Data).toEqual({
+ const { createPetitionStep1Data } = results.output;
+ expect(createPetitionStep1Data).toEqual({
businessType: 'TEST_businessType',
contactPrimary: {
address1: 'TEST_PRIMARY_address1',
@@ -87,7 +87,7 @@ describe('getStep1DataAction', () => {
});
it('should fetch step 2 related data from state.form when useSameAsPrimary is false', async () => {
- const results = await runAction(getStep1DataAction, {
+ const results = await runAction(getCreatePetitionStep1DataAction, {
state: {
form: {
...STATE_FORM,
@@ -110,8 +110,8 @@ describe('getStep1DataAction', () => {
},
});
- const { step1Data } = results.output;
- expect(step1Data).toEqual({
+ const { createPetitionStep1Data } = results.output;
+ expect(createPetitionStep1Data).toEqual({
businessType: 'TEST_businessType',
contactPrimary: {
address2: 'TEST_PRIMARY_address2',
@@ -145,7 +145,7 @@ describe('getStep1DataAction', () => {
});
it('should set contact type for secondary contact when a secondary contact is present', async () => {
- const results = await runAction(getStep1DataAction, {
+ const results = await runAction(getCreatePetitionStep1DataAction, {
state: {
form: {
...STATE_FORM,
@@ -167,14 +167,14 @@ describe('getStep1DataAction', () => {
},
},
});
- const { step1Data } = results.output;
- expect(step1Data.contactSecondary.contactType).toEqual(
+ const { createPetitionStep1Data } = results.output;
+ expect(createPetitionStep1Data.contactSecondary.contactType).toEqual(
CONTACT_TYPES.secondary,
);
});
it('should not set contact type for secondary contact when a secondary contact is not present', async () => {
- const results = await runAction(getStep1DataAction, {
+ const results = await runAction(getCreatePetitionStep1DataAction, {
state: {
form: {
...STATE_FORM,
@@ -186,7 +186,7 @@ describe('getStep1DataAction', () => {
},
},
});
- const { step1Data } = results.output;
- expect(step1Data.contactSecondary).toBeUndefined();
+ const { createPetitionStep1Data } = results.output;
+ expect(createPetitionStep1Data.contactSecondary).toBeUndefined();
});
});
diff --git a/web-client/src/presenter/actions/getStep1DataAction.ts b/web-client/src/presenter/actions/getCreatePetitionStep1DataAction.ts
similarity index 91%
rename from web-client/src/presenter/actions/getStep1DataAction.ts
rename to web-client/src/presenter/actions/getCreatePetitionStep1DataAction.ts
index e11775eedd8..9e9af25988d 100644
--- a/web-client/src/presenter/actions/getStep1DataAction.ts
+++ b/web-client/src/presenter/actions/getCreatePetitionStep1DataAction.ts
@@ -2,7 +2,7 @@ import { CONTACT_TYPES } from '@shared/business/entities/EntityConstants';
import { pick } from 'lodash';
import { state } from '@web-client/presenter/app.cerebral';
-export const getStep1DataAction = ({ get }: ActionProps) => {
+export const getCreatePetitionStep1DataAction = ({ get }: ActionProps) => {
const {
businessType,
contactPrimary,
@@ -28,7 +28,7 @@ export const getStep1DataAction = ({ get }: ActionProps) => {
}
: contactSecondary;
- const step1Data = {
+ const createPetitionStep1Data = {
businessType,
contactPrimary: {
...contactPrimary,
@@ -64,6 +64,6 @@ export const getStep1DataAction = ({ get }: ActionProps) => {
};
return {
- step1Data,
+ createPetitionStep1Data,
};
};
diff --git a/web-client/src/presenter/actions/getStep2DataAction.test.ts b/web-client/src/presenter/actions/getCreatePetitionStep2DataAction.test.ts
similarity index 73%
rename from web-client/src/presenter/actions/getStep2DataAction.test.ts
rename to web-client/src/presenter/actions/getCreatePetitionStep2DataAction.test.ts
index 774e7101030..52f51abd9ee 100644
--- a/web-client/src/presenter/actions/getStep2DataAction.test.ts
+++ b/web-client/src/presenter/actions/getCreatePetitionStep2DataAction.test.ts
@@ -1,9 +1,9 @@
-import { getStep2DataAction } from '@web-client/presenter/actions/getStep2DataAction';
+import { getCreatePetitionStep2DataAction } from '@web-client/presenter/actions/getCreatePetitionStep2DataAction';
import { runAction } from '@web-client/presenter/test.cerebral';
-describe('getStep2DataAction', () => {
+describe('getCreatePetitionStep2DataAction', () => {
it('should fetch Petition Information related data from state.form', async () => {
- const results = await runAction(getStep2DataAction, {
+ const results = await runAction(getCreatePetitionStep2DataAction, {
state: {
form: {
petitionFacts: 'TEST_petitionFacts',
@@ -20,8 +20,8 @@ describe('getStep2DataAction', () => {
},
});
- const { step2Data } = results.output;
- expect(step2Data).toEqual({
+ const { createPetitionStep2Data } = results.output;
+ expect(createPetitionStep2Data).toEqual({
petitionFacts: 'TEST_petitionFacts',
petitionFile: 'TEST_petitionFile',
petitionFileSize: 'TEST_petitionFileSize',
diff --git a/web-client/src/presenter/actions/getStep2DataAction.ts b/web-client/src/presenter/actions/getCreatePetitionStep2DataAction.ts
similarity index 73%
rename from web-client/src/presenter/actions/getStep2DataAction.ts
rename to web-client/src/presenter/actions/getCreatePetitionStep2DataAction.ts
index 2cf71534917..df7622ce0d5 100644
--- a/web-client/src/presenter/actions/getStep2DataAction.ts
+++ b/web-client/src/presenter/actions/getCreatePetitionStep2DataAction.ts
@@ -1,6 +1,6 @@
import { state } from '@web-client/presenter/app.cerebral';
-export const getStep2DataAction = ({ get }: ActionProps) => {
+export const getCreatePetitionStep2DataAction = ({ get }: ActionProps) => {
const {
petitionFacts,
petitionFile,
@@ -10,7 +10,7 @@ export const getStep2DataAction = ({ get }: ActionProps) => {
petitionType,
} = get(state.form);
- const step2Data = {
+ const createPetitionStep2Data = {
petitionFacts,
petitionFile,
petitionFileSize,
@@ -20,6 +20,6 @@ export const getStep2DataAction = ({ get }: ActionProps) => {
};
return {
- step2Data,
+ createPetitionStep2Data,
};
};
diff --git a/web-client/src/presenter/actions/getStep3DataAction.test.ts b/web-client/src/presenter/actions/getCreatePetitionStep3DataAction.test.ts
similarity index 78%
rename from web-client/src/presenter/actions/getStep3DataAction.test.ts
rename to web-client/src/presenter/actions/getCreatePetitionStep3DataAction.test.ts
index d1b957000e5..165dc6abd4b 100644
--- a/web-client/src/presenter/actions/getStep3DataAction.test.ts
+++ b/web-client/src/presenter/actions/getCreatePetitionStep3DataAction.test.ts
@@ -1,9 +1,9 @@
-import { getStep3DataAction } from '@web-client/presenter/actions/getStep3DataAction';
+import { getCreatePetitionStep3DataAction } from '@web-client/presenter/actions/getCreatePetitionStep3DataAction';
import { runAction } from '@web-client/presenter/test.cerebral';
-describe('getStep3DataAction', () => {
+describe('getCreatePetitionStep3DataAction', () => {
it('should fetch step 3 related data from state.form when user has IRS notice', async () => {
- const results = await runAction(getStep3DataAction, {
+ const results = await runAction(getCreatePetitionStep3DataAction, {
state: {
form: {
caseType: 'ROOT_LEVEL_CASE_TYPE',
@@ -24,8 +24,8 @@ describe('getStep3DataAction', () => {
},
});
- const { step3Data } = results.output;
- expect(step3Data).toEqual({
+ const { createPetitionStep3Data } = results.output;
+ expect(createPetitionStep3Data).toEqual({
caseType: 'IRS_NOTICE_CASE_TYPE',
hasIrsNotice: 'TEST_hasIrsNotice',
hasUploadedIrsNotice: true,
@@ -45,7 +45,7 @@ describe('getStep3DataAction', () => {
});
it('should fetch step 3 related data from state.form when user does not have IRS notice', async () => {
- const results = await runAction(getStep3DataAction, {
+ const results = await runAction(getCreatePetitionStep3DataAction, {
state: {
form: {
caseType: 'ROOT_LEVEL_CASE_TYPE',
@@ -58,8 +58,8 @@ describe('getStep3DataAction', () => {
},
});
- const { step3Data } = results.output;
- expect(step3Data).toEqual({
+ const { createPetitionStep3Data } = results.output;
+ expect(createPetitionStep3Data).toEqual({
caseType: 'ROOT_LEVEL_CASE_TYPE',
hasIrsNotice: false,
hasUploadedIrsNotice: false,
diff --git a/web-client/src/presenter/actions/getStep3DataAction.ts b/web-client/src/presenter/actions/getCreatePetitionStep3DataAction.ts
similarity index 88%
rename from web-client/src/presenter/actions/getStep3DataAction.ts
rename to web-client/src/presenter/actions/getCreatePetitionStep3DataAction.ts
index 2b919f2acdb..0a20664d222 100644
--- a/web-client/src/presenter/actions/getStep3DataAction.ts
+++ b/web-client/src/presenter/actions/getCreatePetitionStep3DataAction.ts
@@ -4,7 +4,7 @@ import {
} from '@shared/business/utilities/DateHandler';
import { state } from '@web-client/presenter/app.cerebral';
-export const getStep3DataAction = ({
+export const getCreatePetitionStep3DataAction = ({
get,
}: ActionProps<{ selectedPage: number }>) => {
const { caseType, hasIrsNotice, irsNoticesRedactionAcknowledgement } = get(
@@ -21,7 +21,7 @@ export const getStep3DataAction = ({
};
});
- const step3Data = {
+ const createPetitionStep3Data = {
caseType: hasIrsNotice ? irsNotices[0].caseType : caseType,
hasIrsNotice,
hasUploadedIrsNotice,
@@ -30,6 +30,6 @@ export const getStep3DataAction = ({
};
return {
- step3Data,
+ createPetitionStep3Data,
};
};
diff --git a/web-client/src/presenter/actions/getStep4DataAction.test.ts b/web-client/src/presenter/actions/getCreatePetitionStep4DataAction.test.ts
similarity index 56%
rename from web-client/src/presenter/actions/getStep4DataAction.test.ts
rename to web-client/src/presenter/actions/getCreatePetitionStep4DataAction.test.ts
index 6c136cd19f2..17c358e0cff 100644
--- a/web-client/src/presenter/actions/getStep4DataAction.test.ts
+++ b/web-client/src/presenter/actions/getCreatePetitionStep4DataAction.test.ts
@@ -1,9 +1,9 @@
-import { getStep4DataAction } from '@web-client/presenter/actions/getStep4DataAction';
+import { getCreatePetitionStep4DataAction } from '@web-client/presenter/actions/getCreatePetitionStep4DataAction';
import { runAction } from '@web-client/presenter/test.cerebral';
-describe('getStep4DataAction', () => {
+describe('getCreatePetitionStep4DataAction', () => {
it('should fetch step 4 related data from state.form', async () => {
- const results = await runAction(getStep4DataAction, {
+ const results = await runAction(getCreatePetitionStep4DataAction, {
state: {
form: {
preferredTrialCity: 'TEST_preferredTrialCity',
@@ -13,8 +13,8 @@ describe('getStep4DataAction', () => {
},
});
- const { step4Data } = results.output;
- expect(step4Data).toEqual({
+ const { createPetitionStep4Data } = results.output;
+ expect(createPetitionStep4Data).toEqual({
preferredTrialCity: 'TEST_preferredTrialCity',
procedureType: 'TEST_procedureType',
});
diff --git a/web-client/src/presenter/actions/getStep4DataAction.ts b/web-client/src/presenter/actions/getCreatePetitionStep4DataAction.ts
similarity index 68%
rename from web-client/src/presenter/actions/getStep4DataAction.ts
rename to web-client/src/presenter/actions/getCreatePetitionStep4DataAction.ts
index 27a5051f588..5b9fea35e98 100644
--- a/web-client/src/presenter/actions/getStep4DataAction.ts
+++ b/web-client/src/presenter/actions/getCreatePetitionStep4DataAction.ts
@@ -1,16 +1,16 @@
import { state } from '@web-client/presenter/app.cerebral';
-export const getStep4DataAction = ({
+export const getCreatePetitionStep4DataAction = ({
get,
}: ActionProps<{ selectedPage: number }>) => {
const { preferredTrialCity, procedureType } = get(state.form);
- const step4Data = {
+ const createPetitionStep4Data = {
preferredTrialCity,
procedureType,
};
return {
- step4Data,
+ createPetitionStep4Data,
};
};
diff --git a/web-client/src/presenter/actions/getStep5DataAction.test.ts b/web-client/src/presenter/actions/getCreatePetitionStep5DataAction.test.ts
similarity index 52%
rename from web-client/src/presenter/actions/getStep5DataAction.test.ts
rename to web-client/src/presenter/actions/getCreatePetitionStep5DataAction.test.ts
index f8e0339d0d2..e1f03f2b806 100644
--- a/web-client/src/presenter/actions/getStep5DataAction.test.ts
+++ b/web-client/src/presenter/actions/getCreatePetitionStep5DataAction.test.ts
@@ -1,9 +1,9 @@
-import { getStep5DataAction } from '@web-client/presenter/actions/getStep5DataAction';
+import { getCreatePetitionStep5DataAction } from '@web-client/presenter/actions/getCreatePetitionStep5DataAction';
import { runAction } from '@web-client/presenter/test.cerebral';
-describe('getStep5DataAction', () => {
+describe('getCreatePetitionStep5DataAction', () => {
it('should fetch step 5 related data from state.form', async () => {
- const results = await runAction(getStep5DataAction, {
+ const results = await runAction(getCreatePetitionStep5DataAction, {
state: {
form: {
stinFile: 'TEST_stinFile',
@@ -12,8 +12,8 @@ describe('getStep5DataAction', () => {
},
});
- const { step5Data } = results.output;
- expect(step5Data).toEqual({
+ const { createPetitionStep5Data } = results.output;
+ expect(createPetitionStep5Data).toEqual({
stinFile: 'TEST_stinFile',
stinFileSize: 'TEST_stinFileSize',
});
diff --git a/web-client/src/presenter/actions/getStep5DataAction.ts b/web-client/src/presenter/actions/getCreatePetitionStep5DataAction.ts
similarity index 66%
rename from web-client/src/presenter/actions/getStep5DataAction.ts
rename to web-client/src/presenter/actions/getCreatePetitionStep5DataAction.ts
index e2af6eebc4a..4b207a1fea7 100644
--- a/web-client/src/presenter/actions/getStep5DataAction.ts
+++ b/web-client/src/presenter/actions/getCreatePetitionStep5DataAction.ts
@@ -1,16 +1,16 @@
import { state } from '@web-client/presenter/app.cerebral';
-export const getStep5DataAction = ({
+export const getCreatePetitionStep5DataAction = ({
get,
}: ActionProps<{ selectedPage: number }>) => {
const { stinFile, stinFileSize } = get(state.form);
- const step5Data = {
+ const createPetitionStep5Data = {
stinFile,
stinFileSize,
};
return {
- step5Data,
+ createPetitionStep5Data,
};
};
diff --git a/web-client/src/presenter/actions/saveAndSubmitCaseAction.test.ts b/web-client/src/presenter/actions/saveAndSubmitCaseAction.test.ts
index 7f08384e37e..ecd812683b2 100644
--- a/web-client/src/presenter/actions/saveAndSubmitCaseAction.test.ts
+++ b/web-client/src/presenter/actions/saveAndSubmitCaseAction.test.ts
@@ -1,4 +1,4 @@
-import { PETITION_TYPES } from '@web-client/presenter/actions/setupPetitionStateAction';
+import { PETITION_TYPES } from '@shared/business/entities/EntityConstants';
import { applicationContextForClient as applicationContext } from '@web-client/test/createClientTestApplicationContext';
import { presenter } from '@web-client/presenter/presenter-mock';
import { runAction } from '@web-client/presenter/test.cerebral';
diff --git a/web-client/src/presenter/actions/saveAndSubmitCaseAction.ts b/web-client/src/presenter/actions/saveAndSubmitCaseAction.ts
index 710de9c7ec4..e73f44f1131 100644
--- a/web-client/src/presenter/actions/saveAndSubmitCaseAction.ts
+++ b/web-client/src/presenter/actions/saveAndSubmitCaseAction.ts
@@ -2,8 +2,8 @@ import { ElectronicCreatedCaseType } from '@shared/business/useCases/createCaseI
import {
FileUploadProgressType,
FileUploadProgressValueType,
+ PETITION_TYPES,
} from '@shared/business/entities/EntityConstants';
-import { PETITION_TYPES } from '@web-client/presenter/actions/setupPetitionStateAction';
import { state } from '@web-client/presenter/app.cerebral';
export const saveAndSubmitCaseAction = async ({
diff --git a/web-client/src/presenter/actions/setFormValueAction.test.ts b/web-client/src/presenter/actions/setFormValueAction.test.ts
index a7e3b305b2b..edf4aa1ff9e 100644
--- a/web-client/src/presenter/actions/setFormValueAction.test.ts
+++ b/web-client/src/presenter/actions/setFormValueAction.test.ts
@@ -55,6 +55,18 @@ describe('setFormValueAction', () => {
expect(result.state.form.appleType).toEqual(undefined);
});
+ it('sets the state.form[props.key] if the passed in props.value is empty string and allowEmptyString is set to true', async () => {
+ const result = await runAction(setFormValueAction, {
+ props: {
+ allowEmptyString: true,
+ key: 'appleType',
+ value: '',
+ },
+ state: { form: { appleType: 'Fuji' } },
+ });
+ expect(result.state.form.appleType).toEqual('');
+ });
+
it('unsets the state.form[props.key] if the passed in props.value is null', async () => {
const result = await runAction(setFormValueAction, {
props: {
diff --git a/web-client/src/presenter/actions/setFormValueAction.ts b/web-client/src/presenter/actions/setFormValueAction.ts
index 80ebbbac6d9..45b851cd412 100644
--- a/web-client/src/presenter/actions/setFormValueAction.ts
+++ b/web-client/src/presenter/actions/setFormValueAction.ts
@@ -1,13 +1,23 @@
import { state } from '@web-client/presenter/app.cerebral';
-export const setFormValueAction = ({ props, store }: ActionProps) => {
- if (props.value !== '' && props.value !== null) {
- if (props.index || props.index === 0) {
- store.set(state.form[props.key][props.index], props.value);
- } else {
- store.set(state.form[props.key], props.value);
- }
- } else {
- store.unset(state.form[props.key]);
+export const setFormValueAction = ({
+ props,
+ store,
+}: ActionProps<{
+ allowEmptyString?: boolean;
+ index?: number;
+ key: string;
+ value: any;
+}>) => {
+ const { allowEmptyString, index, key, value } = props;
+
+ if ((!allowEmptyString && value === '') || value === null) {
+ return store.unset(state.form[key]);
+ }
+
+ if (typeof index === 'number') {
+ return store.set(state.form[key][index], value);
}
+
+ store.set(state.form[key], value);
};
diff --git a/web-client/src/presenter/actions/setPetitionFormValueAction.test.ts b/web-client/src/presenter/actions/setPetitionFormValueAction.test.ts
deleted file mode 100644
index 5630321ed8e..00000000000
--- a/web-client/src/presenter/actions/setPetitionFormValueAction.test.ts
+++ /dev/null
@@ -1,74 +0,0 @@
-import { runAction } from '@web-client/presenter/test.cerebral';
-import { setPetitionFormValueAction } from '@web-client/presenter/actions/setPetitionFormValueAction';
-
-describe('setPetitionFormValueAction', () => {
- const KEY = 'KEY';
-
- it('should set state properly when value is truthy and index is a number', async () => {
- const { state } = await runAction(setPetitionFormValueAction, {
- props: {
- index: 0,
- key: KEY,
- value: 'TEST_VALUE',
- },
- state: {
- form: {
- [KEY]: [],
- },
- },
- });
-
- expect(state.form[KEY]).toEqual(['TEST_VALUE']);
- });
-
- it('should set state properly when value is truthy and index is a string', async () => {
- const { state } = await runAction(setPetitionFormValueAction, {
- props: {
- index: 'prop1',
- key: KEY,
- value: 'TEST_VALUE',
- },
- state: {
- form: {
- [KEY]: {},
- },
- },
- });
-
- expect(state.form[KEY]).toEqual({ prop1: 'TEST_VALUE' });
- });
-
- it('should set state properly when value is truthy and index is undefined', async () => {
- const { state } = await runAction(setPetitionFormValueAction, {
- props: {
- index: undefined,
- key: KEY,
- value: 'TEST_VALUE',
- },
- state: {
- form: {
- [KEY]: undefined,
- },
- },
- });
-
- expect(state.form[KEY]).toEqual('TEST_VALUE');
- });
-
- it('should unset state correctly if the value is null', async () => {
- const { state } = await runAction(setPetitionFormValueAction, {
- props: {
- index: undefined,
- key: KEY,
- value: null,
- },
- state: {
- form: {
- [KEY]: 'PREVIOUS VALUE',
- },
- },
- });
-
- expect(state.form[KEY]).toEqual(undefined);
- });
-});
diff --git a/web-client/src/presenter/actions/setPetitionFormValueAction.ts b/web-client/src/presenter/actions/setPetitionFormValueAction.ts
deleted file mode 100644
index 6c45f410b7c..00000000000
--- a/web-client/src/presenter/actions/setPetitionFormValueAction.ts
+++ /dev/null
@@ -1,17 +0,0 @@
-import { state } from '@web-client/presenter/app.cerebral';
-
-export const setPetitionFormValueAction = ({
- props,
- store,
-}: ActionProps<{ index: number; key: string; value: any }>) => {
- const { index, key, value } = props;
- if (value !== null) {
- if (index || index === 0) {
- store.set(state.form[key][index], value);
- } else {
- store.set(state.form[key], value);
- }
- } else {
- store.unset(state.form[key]);
- }
-};
diff --git a/web-client/src/presenter/actions/setupPetitionStateAction.test.ts b/web-client/src/presenter/actions/setupPetitionStateAction.test.ts
index ec2231f6206..0a738949b3c 100644
--- a/web-client/src/presenter/actions/setupPetitionStateAction.test.ts
+++ b/web-client/src/presenter/actions/setupPetitionStateAction.test.ts
@@ -1,8 +1,6 @@
-import {
- PETITION_TYPES,
- setupPetitionStateAction,
-} from '@web-client/presenter/actions/setupPetitionStateAction';
+import { PETITION_TYPES } from '@shared/business/entities/EntityConstants';
import { runAction } from '@web-client/presenter/test.cerebral';
+import { setupPetitionStateAction } from '@web-client/presenter/actions/setupPetitionStateAction';
describe('setupPetitionStateAction', () => {
it('should setup state correctly', async () => {
diff --git a/web-client/src/presenter/actions/setupPetitionStateAction.ts b/web-client/src/presenter/actions/setupPetitionStateAction.ts
index fdcb6b1e05f..8a2b0de2290 100644
--- a/web-client/src/presenter/actions/setupPetitionStateAction.ts
+++ b/web-client/src/presenter/actions/setupPetitionStateAction.ts
@@ -1,12 +1,6 @@
-// import { COUNTRY_TYPES } from '@shared/business/entities/EntityConstants';
+import { PETITION_TYPES } from '@shared/business/entities/EntityConstants';
import { state } from '@web-client/presenter/app.cerebral';
-// use GENERATION_TYPES instead? either way, this should be in entityConstants
-export const PETITION_TYPES = {
- autoGenerated: 'autoGenerated',
- userUploaded: 'userUploaded',
-};
-
export type InitialPetitionFormState = {
petitionFacts: string[];
petitionReasons: string[];
@@ -15,7 +9,6 @@ export type InitialPetitionFormState = {
};
export const setupPetitionStateAction = ({ store }: ActionProps) => {
- // should this live in state?
const initialPetitionForm: InitialPetitionFormState = {
filingType: undefined,
petitionFacts: [''],
diff --git a/web-client/src/presenter/actions/updateIrsNoticeUploadedFileAction.test.ts b/web-client/src/presenter/actions/updateIrsNoticeUploadedFileAction.test.ts
new file mode 100644
index 00000000000..4b000a9ad46
--- /dev/null
+++ b/web-client/src/presenter/actions/updateIrsNoticeUploadedFileAction.test.ts
@@ -0,0 +1,112 @@
+import { applicationContextForClient as applicationContext } from '@web-client/test/createClientTestApplicationContext';
+import { presenter } from '@web-client/presenter/presenter-mock';
+import { runAction } from '@web-client/presenter/test.cerebral';
+import { updateIrsNoticeIndexPropertyAction } from '@web-client/presenter/actions/updateIrsNoticeUploadedFileAction';
+
+describe('updateIrsNoticeIndexPropertyAction', () => {
+ presenter.providers.applicationContext = applicationContext;
+
+ it('should set an initial value of irs notice info', async () => {
+ const results = await runAction(updateIrsNoticeIndexPropertyAction, {
+ modules: {
+ presenter,
+ },
+ props: {
+ key: 0,
+ property: 'caseType',
+ toFormat: undefined,
+ value: 'CDP (Lien/Levy)',
+ },
+ });
+
+ expect(results.state.irsNoticeUploadFormInfo).toEqual({
+ 0: { caseType: 'CDP (Lien/Levy)' },
+ });
+ });
+
+ it('should update an existing property on irs notice info', async () => {
+ const results = await runAction(updateIrsNoticeIndexPropertyAction, {
+ modules: {
+ presenter,
+ },
+ props: {
+ key: 0,
+ property: 'caseType',
+ toFormat: undefined,
+ value: 'Deficiency',
+ },
+ state: {
+ 0: { caseType: 'CDP (Lien/Levy)', taxYear: '2023' },
+ },
+ });
+
+ expect(results.state.irsNoticeUploadFormInfo).toEqual({
+ 0: { caseType: 'Deficiency' },
+ });
+ });
+
+ it('should add a new entry to irs notice info', async () => {
+ const results = await runAction(updateIrsNoticeIndexPropertyAction, {
+ modules: {
+ presenter,
+ },
+ props: {
+ key: 1,
+ property: 'caseType',
+ toFormat: undefined,
+ value: 'Deficiency',
+ },
+ state: {
+ irsNoticeUploadFormInfo: {
+ 0: { caseType: 'CDP (Lien/Levy)', taxYear: '2023' },
+ },
+ },
+ });
+ expect(results.state.irsNoticeUploadFormInfo).toEqual({
+ 0: { caseType: 'CDP (Lien/Levy)', taxYear: '2023' },
+ 1: { caseType: 'Deficiency' },
+ });
+ });
+
+ it('should remove a property from an existing irs notice info', async () => {
+ const results = await runAction(updateIrsNoticeIndexPropertyAction, {
+ modules: {
+ presenter,
+ },
+ props: {
+ key: 1,
+ property: 'taxYear',
+ toFormat: undefined,
+ value: undefined,
+ },
+ state: {
+ irsNoticeUploadFormInfo: {
+ 0: { caseType: 'CDP (Lien/Levy)', taxYear: '2023' },
+ 1: { caseType: 'CDP (Lien/Levy)', taxYear: '2024' },
+ },
+ },
+ });
+ expect(results.state.irsNoticeUploadFormInfo).toEqual({
+ 0: { caseType: 'CDP (Lien/Levy)', taxYear: '2023' },
+ 1: { caseType: 'CDP (Lien/Levy)' },
+ });
+ });
+
+ it('should format and set a date property correctly', async () => {
+ const results = await runAction(updateIrsNoticeIndexPropertyAction, {
+ modules: {
+ presenter,
+ },
+ props: {
+ key: '0',
+ property: 'noticeIssuedDate',
+ toFormat: "yyyy-MM-dd'T'HH:mm:ss.SSSZZ",
+ value: '07/30/2024',
+ },
+ });
+
+ expect(results.state.irsNoticeUploadFormInfo).toEqual({
+ 0: { noticeIssuedDate: '2024-07-30T00:00:00.000-04:00' },
+ });
+ });
+});
diff --git a/web-client/src/presenter/actions/updatedValidatePetitionAction.ts b/web-client/src/presenter/actions/updatedValidatePetitionAction.ts
index 4e5ca9a2b48..de2ad753ef2 100644
--- a/web-client/src/presenter/actions/updatedValidatePetitionAction.ts
+++ b/web-client/src/presenter/actions/updatedValidatePetitionAction.ts
@@ -4,7 +4,7 @@ export const updatedValidatePetitionAction = ({
applicationContext,
get,
path,
-}: ActionProps) => {
+}: ActionProps<{}, IApplicationContext>) => {
const petition = get(state.petitionFormatted);
const errors = applicationContext
@@ -13,9 +13,7 @@ export const updatedValidatePetitionAction = ({
petition,
});
- if (!errors) {
- return path.success();
- } else {
+ if (errors) {
return path.error({
alertError: {
title: 'Errors were found. Please correct your form and resubmit.',
@@ -23,4 +21,6 @@ export const updatedValidatePetitionAction = ({
errors,
});
}
+
+ return path.success();
};
diff --git a/web-client/src/presenter/actions/validateUploadPetitionStep1Action.test.ts b/web-client/src/presenter/actions/validateUploadPetitionStep1Action.test.ts
index 514812415fb..12f40ae75f4 100644
--- a/web-client/src/presenter/actions/validateUploadPetitionStep1Action.test.ts
+++ b/web-client/src/presenter/actions/validateUploadPetitionStep1Action.test.ts
@@ -28,7 +28,7 @@ describe('validateUploadPetitionStep1Action', () => {
presenter,
},
props: {
- step1Data: {
+ createPetitionStep1Data: {
countryType: COUNTRY_TYPES.DOMESTIC,
filingType: FILING_TYPES[ROLES.petitioner][0],
partyType: PARTY_TYPES.petitioner,
@@ -46,7 +46,7 @@ describe('validateUploadPetitionStep1Action', () => {
presenter,
},
props: {
- step1Data: {},
+ createPetitionStep1Data: {},
},
});
diff --git a/web-client/src/presenter/actions/validateUploadPetitionStep1Action.ts b/web-client/src/presenter/actions/validateUploadPetitionStep1Action.ts
index 6f2d0ac0bf4..d1d612f2c8b 100644
--- a/web-client/src/presenter/actions/validateUploadPetitionStep1Action.ts
+++ b/web-client/src/presenter/actions/validateUploadPetitionStep1Action.ts
@@ -3,33 +3,33 @@ import { UploadPetitionStep1 } from '@shared/business/entities/startCase/UploadP
export const validateUploadPetitionStep1Action = ({
path,
props,
-}: ActionProps<{ step1Data: any }>) => {
- const { step1Data } = props;
+}: ActionProps<{ createPetitionStep1Data: any }>) => {
+ const { createPetitionStep1Data } = props;
const errors = new UploadPetitionStep1(
- step1Data,
+ createPetitionStep1Data,
).getFormattedValidationErrors();
- if (!errors) {
- return path.success();
- }
+ if (errors) {
+ const errorDisplayOrder = [
+ 'name',
+ 'secondaryName',
+ 'inCareOf',
+ 'title',
+ 'address1',
+ 'city',
+ 'state',
+ 'postalCode',
+ 'placeOfLegalResidence',
+ 'phone',
+ 'paperPetitionEmail',
+ ];
- const errorDisplayOrder = [
- 'name',
- 'secondaryName',
- 'inCareOf',
- 'title',
- 'address1',
- 'city',
- 'state',
- 'postalCode',
- 'placeOfLegalResidence',
- 'phone',
- 'paperPetitionEmail',
- ];
+ return path.error({
+ errorDisplayOrder,
+ errors,
+ });
+ }
- return path.error({
- errorDisplayOrder,
- errors,
- });
+ return path.success();
};
diff --git a/web-client/src/presenter/actions/validateUploadPetitionStep2Action.test.ts b/web-client/src/presenter/actions/validateUploadPetitionStep2Action.test.ts
index eb565732433..5b2f0ed39ae 100644
--- a/web-client/src/presenter/actions/validateUploadPetitionStep2Action.test.ts
+++ b/web-client/src/presenter/actions/validateUploadPetitionStep2Action.test.ts
@@ -1,4 +1,4 @@
-import { PETITION_TYPES } from '@web-client/presenter/actions/setupPetitionStateAction';
+import { PETITION_TYPES } from '@shared/business/entities/EntityConstants';
import { applicationContextForClient as applicationContext } from '@web-client/test/createClientTestApplicationContext';
import { presenter } from '../presenter-mock';
import { runAction } from '@web-client/presenter/test.cerebral';
@@ -23,7 +23,7 @@ describe('validateUploadPetitionStep2Action', () => {
presenter,
},
props: {
- step2Data: {
+ createPetitionStep2Data: {
petitionFacts: ['Fact goes here'],
petitionReasons: ['Reason goes here'],
petitionType: PETITION_TYPES.autoGenerated,
@@ -48,7 +48,7 @@ describe('validateUploadPetitionStep2Action', () => {
presenter,
},
props: {
- step2Data: {
+ createPetitionStep2Data: {
petitionFacts: [''],
petitionFile: {},
petitionFileSize: 1,
@@ -79,7 +79,7 @@ describe('validateUploadPetitionStep2Action', () => {
presenter,
},
props: {
- step2Data: {
+ createPetitionStep2Data: {
petitionFacts: [''],
petitionReasons: [''],
petitionType: PETITION_TYPES.autoGenerated,
@@ -97,46 +97,4 @@ describe('validateUploadPetitionStep2Action', () => {
expect(mockErrorPath.mock.calls.length).toEqual(1);
expect(mockSuccessPath).not.toHaveBeenCalled();
});
-
- it('should filter out empty petition facts or reasons, except for the first one, and set them on state', async () => {
- const { state } = await runAction(validateUploadPetitionStep2Action, {
- modules: {
- presenter,
- },
- props: {
- step2Data: {
- petitionFacts: ['Fact goes here', '', 'Second fact here'],
- petitionReasons: [
- 'Reason goes here',
- '',
- '',
- '',
- 'Second reason here',
- ],
- petitionType: PETITION_TYPES.autoGenerated,
- },
- },
- state: {
- form: {
- petitionFacts: ['Fact goes here', '', 'Second fact here'],
- petitionReasons: [
- 'Reason goes here',
- '',
- '',
- '',
- 'Second reason here',
- ],
- petitionType: PETITION_TYPES.autoGenerated,
- },
- },
- });
- expect(state.form).toEqual({
- petitionFacts: ['Fact goes here', 'Second fact here'],
- petitionReasons: ['Reason goes here', 'Second reason here'],
- petitionType: PETITION_TYPES.autoGenerated,
- });
-
- expect(mockSuccessPath.mock.calls.length).toEqual(1);
- expect(mockErrorPath).not.toHaveBeenCalled();
- });
});
diff --git a/web-client/src/presenter/actions/validateUploadPetitionStep2Action.ts b/web-client/src/presenter/actions/validateUploadPetitionStep2Action.ts
index 47acd95e921..1d02e50ccf9 100644
--- a/web-client/src/presenter/actions/validateUploadPetitionStep2Action.ts
+++ b/web-client/src/presenter/actions/validateUploadPetitionStep2Action.ts
@@ -1,32 +1,20 @@
import { UploadPetitionStep2 } from '@shared/business/entities/startCase/UploadPetitionStep2';
-import { state } from '@web-client/presenter/app.cerebral';
export const validateUploadPetitionStep2Action = ({
path,
props,
- store,
-}: ActionProps<{ step2Data: any }>) => {
- const { step2Data } = props;
+}: ActionProps<{ createPetitionStep2Data: any }>) => {
+ const { createPetitionStep2Data } = props;
- // move this logic to new action?
- step2Data.petitionReasons = (arr => (arr.length > 0 ? arr : ['']))(
- step2Data.petitionReasons.filter(r => r.length >= 1),
- );
-
- step2Data.petitionFacts = (arr => (arr.length > 0 ? arr : ['']))(
- step2Data.petitionFacts.filter(r => r.length >= 1),
- );
-
- store.set(state.form.petitionReasons, step2Data.petitionReasons);
- store.set(state.form.petitionFacts, step2Data.petitionFacts);
-
- let errors = new UploadPetitionStep2(
- step2Data,
+ const errors = new UploadPetitionStep2(
+ createPetitionStep2Data,
).getFormattedValidationErrors();
+
if (errors) {
return path.error({
errors,
});
}
+
return path.success();
};
diff --git a/web-client/src/presenter/actions/validateUploadPetitionStep3Action.test.ts b/web-client/src/presenter/actions/validateUploadPetitionStep3Action.test.ts
index 1d155b07d70..641856331ff 100644
--- a/web-client/src/presenter/actions/validateUploadPetitionStep3Action.test.ts
+++ b/web-client/src/presenter/actions/validateUploadPetitionStep3Action.test.ts
@@ -23,7 +23,7 @@ describe('validateUploadPetitionStep3Action', () => {
presenter,
},
props: {
- step3Data: {
+ createPetitionStep3Data: {
caseType: CASE_TYPES_MAP.cdp,
hasIrsNotice: false,
hasUploadedIrsNotice: false,
@@ -41,7 +41,7 @@ describe('validateUploadPetitionStep3Action', () => {
presenter,
},
props: {
- step3Data: {},
+ createPetitionStep3Data: {},
},
});
diff --git a/web-client/src/presenter/actions/validateUploadPetitionStep3Action.ts b/web-client/src/presenter/actions/validateUploadPetitionStep3Action.ts
index 718852bf10b..16bec84bbdc 100644
--- a/web-client/src/presenter/actions/validateUploadPetitionStep3Action.ts
+++ b/web-client/src/presenter/actions/validateUploadPetitionStep3Action.ts
@@ -3,16 +3,18 @@ import { UploadPetitionStep3 } from '@shared/business/entities/startCase/UploadP
export const validateUploadPetitionStep3Action = ({
path,
props,
-}: ActionProps<{ step3Data: any }>) => {
- const { step3Data } = props;
+}: ActionProps<{ createPetitionStep3Data: any }>) => {
+ const { createPetitionStep3Data } = props;
const errors = new UploadPetitionStep3(
- step3Data,
+ createPetitionStep3Data,
).getFormattedValidationErrors();
- return errors
- ? path.error({
- errors,
- })
- : path.success();
+ if (errors) {
+ return path.error({
+ errors,
+ });
+ }
+
+ return path.success();
};
diff --git a/web-client/src/presenter/actions/validateUploadPetitionStep4Action.test.ts b/web-client/src/presenter/actions/validateUploadPetitionStep4Action.test.ts
index 8d07a07ad5a..52fa70d7bca 100644
--- a/web-client/src/presenter/actions/validateUploadPetitionStep4Action.test.ts
+++ b/web-client/src/presenter/actions/validateUploadPetitionStep4Action.test.ts
@@ -26,7 +26,7 @@ describe('validateUploadPetitionStep4Action', () => {
presenter,
},
props: {
- step4Data: {
+ createPetitionStep4Data: {
preferredTrialCity: TRIAL_CITY_STRINGS[0],
procedureType: PROCEDURE_TYPES_MAP.regular,
},
@@ -43,7 +43,7 @@ describe('validateUploadPetitionStep4Action', () => {
presenter,
},
props: {
- step4Data: {},
+ createPetitionStep4Data: {},
},
});
diff --git a/web-client/src/presenter/actions/validateUploadPetitionStep4Action.ts b/web-client/src/presenter/actions/validateUploadPetitionStep4Action.ts
index d2d16ab4896..bfdb645a81c 100644
--- a/web-client/src/presenter/actions/validateUploadPetitionStep4Action.ts
+++ b/web-client/src/presenter/actions/validateUploadPetitionStep4Action.ts
@@ -3,16 +3,18 @@ import { UploadPetitionStep4 } from '@shared/business/entities/startCase/UploadP
export const validateUploadPetitionStep4Action = ({
path,
props,
-}: ActionProps<{ step4Data: any }>) => {
- const { step4Data } = props;
+}: ActionProps<{ createPetitionStep4Data: any }>) => {
+ const { createPetitionStep4Data } = props;
const errors = new UploadPetitionStep4(
- step4Data,
+ createPetitionStep4Data,
).getFormattedValidationErrors();
- return errors
- ? path.error({
- errors,
- })
- : path.success();
+ if (errors) {
+ return path.error({
+ errors,
+ });
+ }
+
+ return path.success();
};
diff --git a/web-client/src/presenter/actions/validateUploadPetitionStep5Action.test.ts b/web-client/src/presenter/actions/validateUploadPetitionStep5Action.test.ts
index 1fc8dbb5307..e4371f4ba0f 100644
--- a/web-client/src/presenter/actions/validateUploadPetitionStep5Action.test.ts
+++ b/web-client/src/presenter/actions/validateUploadPetitionStep5Action.test.ts
@@ -22,7 +22,7 @@ describe('validateUploadPetitionStep5Action', () => {
presenter,
},
props: {
- step5Data: {
+ createPetitionStep5Data: {
stinFile: {},
stinFileSize: 1,
},
@@ -39,7 +39,7 @@ describe('validateUploadPetitionStep5Action', () => {
presenter,
},
props: {
- step5Data: {},
+ createPetitionStep5Data: {},
},
});
diff --git a/web-client/src/presenter/actions/validateUploadPetitionStep5Action.ts b/web-client/src/presenter/actions/validateUploadPetitionStep5Action.ts
index 31848696b59..cee4375db18 100644
--- a/web-client/src/presenter/actions/validateUploadPetitionStep5Action.ts
+++ b/web-client/src/presenter/actions/validateUploadPetitionStep5Action.ts
@@ -3,16 +3,18 @@ import { UploadPetitionStep5 } from '@shared/business/entities/startCase/UploadP
export const validateUploadPetitionStep5Action = ({
path,
props,
-}: ActionProps<{ step5Data: any }>) => {
- const { step5Data } = props;
+}: ActionProps<{ createPetitionStep5Data: any }>) => {
+ const { createPetitionStep5Data } = props;
const errors = new UploadPetitionStep5(
- step5Data,
+ createPetitionStep5Data,
).getFormattedValidationErrors();
- return errors
- ? path.error({
- errors,
- })
- : path.success();
+ if (errors) {
+ return path.error({
+ errors,
+ });
+ }
+
+ return path.success();
};
diff --git a/web-client/src/presenter/computeds/showContactsHelperUpdated.ts b/web-client/src/presenter/computeds/showContactsHelperUpdated.ts
index f152350e580..d835948861c 100644
--- a/web-client/src/presenter/computeds/showContactsHelperUpdated.ts
+++ b/web-client/src/presenter/computeds/showContactsHelperUpdated.ts
@@ -39,11 +39,13 @@ function getShowContactPrimary(partyType, PARTY_TYPES, filingType) {
filingType === 'Myself'
);
}
+
function getShowContactSecondary(partyType, PARTY_TYPES, props) {
const isContactSecondaryPartyType = [
PARTY_TYPES.petitionerDeceasedSpouse,
PARTY_TYPES.petitionerSpouse,
].includes(partyType);
+
if (!isContactSecondaryPartyType) return false;
if (props.key !== 'isSpouseDeceased') return false;
if (props.value !== 'Yes') return false;
diff --git a/web-client/src/presenter/computeds/validationHelper.test.ts b/web-client/src/presenter/computeds/validationHelper.test.ts
new file mode 100644
index 00000000000..8b5f865d28f
--- /dev/null
+++ b/web-client/src/presenter/computeds/validationHelper.test.ts
@@ -0,0 +1,84 @@
+import { collectInputElements } from '@web-client/presenter/computeds/validationHelper';
+
+describe('validationHelper', () => {
+ const element1 = (window.document.createElement('input').id =
+ 'test-element') as unknown as HTMLElement;
+ const element2 = (window.document.createElement('input').id =
+ 'test-element2') as unknown as HTMLElement;
+ const element3 = (window.document.createElement('input').id =
+ 'test-element3') as unknown as HTMLElement;
+
+ it('should return an array of elements needing focus due to errors', () => {
+ const errors = {
+ test1: 'This is error 1',
+ test2: 'This is error 2',
+ };
+ const refs = {
+ current: {
+ test1: element1,
+ test2: element2,
+ test3: element3,
+ },
+ };
+ const elements = collectInputElements(errors, refs);
+ expect(elements).toEqual(['test-element', 'test-element2']);
+ });
+
+ it('should return an array of elements needing focus due to nested errors', () => {
+ const nestedErrors = {
+ nested: {
+ test2: 'This is another test error',
+ },
+ test1: 'This is a test error',
+ test3: 'This is error 3',
+ };
+
+ const nestedRefs = {
+ current: {
+ 'nested.test2': element2,
+ test1: element1,
+ test3: element3,
+ },
+ };
+
+ const nestedElements = collectInputElements(nestedErrors, nestedRefs);
+ expect(nestedElements).toEqual([
+ 'test-element2',
+ 'test-element',
+ 'test-element3',
+ ]);
+ });
+
+ it('should return an array of elements needing focus with a specific custom function', () => {
+ const specificCustomFunction = (
+ errorValue,
+ refs,
+ elementsToFocus,
+ errorKey,
+ ) => {
+ if (
+ errorValue === 'Specific error' &&
+ refs.current[errorKey.slice(0, -1)]
+ ) {
+ elementsToFocus.push(refs.current[errorKey.slice(0, -1)]);
+ }
+ };
+
+ const errors = {
+ test1: 'Specific error',
+ test2: 'Another error',
+ test3: 'Specific error',
+ };
+
+ const refs = {
+ current: {
+ test1: element1,
+ test2: element2,
+ test3: element3,
+ },
+ };
+
+ const elements = collectInputElements(errors, refs, specificCustomFunction);
+ expect(elements).toEqual([element1, element3]);
+ });
+});
diff --git a/web-client/src/presenter/computeds/validationHelper.ts b/web-client/src/presenter/computeds/validationHelper.ts
new file mode 100644
index 00000000000..61595a8e7e5
--- /dev/null
+++ b/web-client/src/presenter/computeds/validationHelper.ts
@@ -0,0 +1,31 @@
+import { MutableRefObject } from 'react';
+
+export const collectInputElements = (
+ errors: object,
+ refs: MutableRefObject<{ [key: string]: HTMLElement }>,
+ customFunction?: (
+ errorValue: any,
+ customRefs: MutableRefObject<{ [key: string]: HTMLElement }>,
+ elementsToFocus: HTMLElement[],
+ errorKey: string,
+ ) => void,
+ prefix: string = '',
+) => {
+ const elementsToFocus: HTMLElement[] = [];
+
+ const formatErrors = (err, pre = '') => {
+ if (typeof err === 'object' && err !== null) {
+ for (const key in err) {
+ if (customFunction)
+ customFunction(err[key], refs, elementsToFocus, `${pre}${key}.`);
+ else if (typeof err[key] === 'object' && err[key] !== null) {
+ formatErrors(err[key], `${pre}${key}.`);
+ } else if (err[key] && refs.current[`${pre}${key}`]) {
+ elementsToFocus.push(refs.current[`${pre}${key}`]);
+ }
+ }
+ }
+ };
+ formatErrors(errors, prefix);
+ return elementsToFocus;
+};
diff --git a/web-client/src/presenter/presenter.ts b/web-client/src/presenter/presenter.ts
index fa9e7bf10f4..271858a65b1 100644
--- a/web-client/src/presenter/presenter.ts
+++ b/web-client/src/presenter/presenter.ts
@@ -534,7 +534,6 @@ import { updateModalValueSequence } from './sequences/updateModalValueSequence';
import { updateOrderForDesignatingPlaceOfTrialSequence } from './sequences/updateOrderForDesignatingPlaceOfTrialSequence';
import { updatePaperServiceProgressSequence } from './sequences/updatePaperServiceProgressSequence';
import { updatePartyViewTabSequence } from './sequences/updatePartyViewTabSequence';
-import { updatePetitionFormValueSequence } from '@web-client/presenter/sequences/updatePetitionFormValueSequence';
import { updatePetitionPaymentFormValueSequence } from './sequences/updatePetitionPaymentFormValueSequence';
import { updateQcCompleteForTrialSequence } from './sequences/updateQcCompleteForTrialSequence';
import { updateScreenMetadataSequence } from './sequences/updateScreenMetadataSequence';
@@ -1492,8 +1491,6 @@ export const presenterSequences = {
updatePaperServiceProgressSequence:
updatePaperServiceProgressSequence as unknown as Function,
updatePartyViewTabSequence: updatePartyViewTabSequence as unknown as Function,
- updatePetitionFormValueSequence:
- updatePetitionFormValueSequence as unknown as Function,
updatePetitionPaymentFormValueSequence:
updatePetitionPaymentFormValueSequence as unknown as Function,
updateQcCompleteForTrialSequence:
diff --git a/web-client/src/presenter/sequences/petitionGenerationLiveValidationSequence.ts b/web-client/src/presenter/sequences/petitionGenerationLiveValidationSequence.ts
index 89f0cd86115..bc0c55bc425 100644
--- a/web-client/src/presenter/sequences/petitionGenerationLiveValidationSequence.ts
+++ b/web-client/src/presenter/sequences/petitionGenerationLiveValidationSequence.ts
@@ -1,8 +1,8 @@
import { determineStepPathAction } from '@web-client/presenter/actions/determineStepPathAction';
-import { getStep1DataAction } from '@web-client/presenter/actions/getStep1DataAction';
-import { getStep2DataAction } from '@web-client/presenter/actions/getStep2DataAction';
-import { getStep3DataAction } from '@web-client/presenter/actions/getStep3DataAction';
-import { getStep4DataAction } from '@web-client/presenter/actions/getStep4DataAction';
+import { getCreatePetitionStep1DataAction } from '@web-client/presenter/actions/getCreatePetitionStep1DataAction';
+import { getCreatePetitionStep2DataAction } from '@web-client/presenter/actions/getCreatePetitionStep2DataAction';
+import { getCreatePetitionStep3DataAction } from '@web-client/presenter/actions/getCreatePetitionStep3DataAction';
+import { getCreatePetitionStep4DataAction } from '@web-client/presenter/actions/getCreatePetitionStep4DataAction';
import { setSingleValidationErrorAction } from '@web-client/presenter/actions/setSingleValidationErrorAction';
import { startShowValidationAction } from '@web-client/presenter/actions/startShowValidationAction';
import { validateUploadPetitionStep1Action } from '@web-client/presenter/actions/validateUploadPetitionStep1Action';
@@ -25,22 +25,22 @@ export const petitionGenerationLiveValidationSequence = [
determineStepPathAction,
{
step1: [
- getStep1DataAction,
+ getCreatePetitionStep1DataAction,
validateUploadPetitionStep1Action,
handleValidationErrorsRoute,
],
step2: [
- getStep2DataAction,
+ getCreatePetitionStep2DataAction,
validateUploadPetitionStep2Action,
handleValidationErrorsRoute,
],
step3: [
- getStep3DataAction,
+ getCreatePetitionStep3DataAction,
validateUploadPetitionStep3Action,
handleValidationErrorsRoute,
],
step4: [
- getStep4DataAction,
+ getCreatePetitionStep4DataAction,
validateUploadPetitionStep4Action,
handleValidationErrorsRoute,
],
diff --git a/web-client/src/presenter/sequences/updateFormValueSequence.ts b/web-client/src/presenter/sequences/updateFormValueSequence.ts
index 3f532dfacdd..7a818fe004d 100644
--- a/web-client/src/presenter/sequences/updateFormValueSequence.ts
+++ b/web-client/src/presenter/sequences/updateFormValueSequence.ts
@@ -1,3 +1,10 @@
import { setFormValueAction } from '../actions/setFormValueAction';
-export const updateFormValueSequence = [setFormValueAction];
+export const updateFormValueSequence = [
+ setFormValueAction,
+] as unknown as (props: {
+ index: number;
+ key: string;
+ value: any;
+ allowEmptyString?: boolean;
+}) => void;
diff --git a/web-client/src/presenter/sequences/updatePetitionFormValueSequence.ts b/web-client/src/presenter/sequences/updatePetitionFormValueSequence.ts
deleted file mode 100644
index e7b46f2fc1b..00000000000
--- a/web-client/src/presenter/sequences/updatePetitionFormValueSequence.ts
+++ /dev/null
@@ -1,3 +0,0 @@
-import { setPetitionFormValueAction } from '@web-client/presenter/actions/setPetitionFormValueAction';
-//TODO: type here instead of presenter.ts
-export const updatePetitionFormValueSequence = [setPetitionFormValueAction];
diff --git a/web-client/src/presenter/sequences/updatedFilePetitionCompleteStep1Sequence.ts b/web-client/src/presenter/sequences/updatedFilePetitionCompleteStep1Sequence.ts
index 991f9bcb656..85e12a7d661 100644
--- a/web-client/src/presenter/sequences/updatedFilePetitionCompleteStep1Sequence.ts
+++ b/web-client/src/presenter/sequences/updatedFilePetitionCompleteStep1Sequence.ts
@@ -1,5 +1,5 @@
import { clearAlertsAction } from '../actions/clearAlertsAction';
-import { getStep1DataAction } from '@web-client/presenter/actions/getStep1DataAction';
+import { getCreatePetitionStep1DataAction } from '@web-client/presenter/actions/getCreatePetitionStep1DataAction';
import { incrementCurrentStepIndicatorAction } from '@web-client/presenter/actions/incrementCurrentStepIndicatorAction';
import { setValidationErrorsAction } from '../actions/setValidationErrorsAction';
import { startShowValidationAction } from '../actions/startShowValidationAction';
@@ -8,7 +8,7 @@ import { validateUploadPetitionStep1Action } from '@web-client/presenter/actions
export const updatedFilePetitionCompleteStep1Sequence = [
startShowValidationAction,
- getStep1DataAction,
+ getCreatePetitionStep1DataAction,
validateUploadPetitionStep1Action,
{
error: [setValidationErrorsAction],
diff --git a/web-client/src/presenter/sequences/updatedFilePetitionCompleteStep2Sequence.ts b/web-client/src/presenter/sequences/updatedFilePetitionCompleteStep2Sequence.ts
index 2ef645650d2..e1264bb3d8b 100644
--- a/web-client/src/presenter/sequences/updatedFilePetitionCompleteStep2Sequence.ts
+++ b/web-client/src/presenter/sequences/updatedFilePetitionCompleteStep2Sequence.ts
@@ -1,5 +1,6 @@
import { clearAlertsAction } from '../actions/clearAlertsAction';
-import { getStep2DataAction } from '@web-client/presenter/actions/getStep2DataAction';
+import { formatPetitionFactsAndReasonsAction } from '@web-client/presenter/actions/formatPetitionFactsAndReasonsAction';
+import { getCreatePetitionStep2DataAction } from '@web-client/presenter/actions/getCreatePetitionStep2DataAction';
import { incrementCurrentStepIndicatorAction } from '@web-client/presenter/actions/incrementCurrentStepIndicatorAction';
import { setValidationErrorsAction } from '../actions/setValidationErrorsAction';
import { startShowValidationAction } from '../actions/startShowValidationAction';
@@ -8,7 +9,8 @@ import { validateUploadPetitionStep2Action } from '@web-client/presenter/actions
export const updatedFilePetitionCompleteStep2Sequence = [
startShowValidationAction,
- getStep2DataAction,
+ formatPetitionFactsAndReasonsAction,
+ getCreatePetitionStep2DataAction,
validateUploadPetitionStep2Action,
{
error: [setValidationErrorsAction],
diff --git a/web-client/src/presenter/sequences/updatedFilePetitionCompleteStep3Sequence.ts b/web-client/src/presenter/sequences/updatedFilePetitionCompleteStep3Sequence.ts
index a3433f739c0..462d9992077 100644
--- a/web-client/src/presenter/sequences/updatedFilePetitionCompleteStep3Sequence.ts
+++ b/web-client/src/presenter/sequences/updatedFilePetitionCompleteStep3Sequence.ts
@@ -1,5 +1,5 @@
import { clearAlertsAction } from '../actions/clearAlertsAction';
-import { getStep3DataAction } from '@web-client/presenter/actions/getStep3DataAction';
+import { getCreatePetitionStep3DataAction } from '@web-client/presenter/actions/getCreatePetitionStep3DataAction';
import { incrementCurrentStepIndicatorAction } from '@web-client/presenter/actions/incrementCurrentStepIndicatorAction';
import { setValidationErrorsAction } from '../actions/setValidationErrorsAction';
import { startShowValidationAction } from '../actions/startShowValidationAction';
@@ -8,7 +8,7 @@ import { validateUploadPetitionStep3Action } from '@web-client/presenter/actions
export const updatedFilePetitionCompleteStep3Sequence = [
startShowValidationAction,
- getStep3DataAction,
+ getCreatePetitionStep3DataAction,
validateUploadPetitionStep3Action,
{
error: [setValidationErrorsAction],
diff --git a/web-client/src/presenter/sequences/updatedFilePetitionCompleteStep4Sequence.ts b/web-client/src/presenter/sequences/updatedFilePetitionCompleteStep4Sequence.ts
index 8a386733f04..a2b71e96d92 100644
--- a/web-client/src/presenter/sequences/updatedFilePetitionCompleteStep4Sequence.ts
+++ b/web-client/src/presenter/sequences/updatedFilePetitionCompleteStep4Sequence.ts
@@ -1,5 +1,5 @@
import { clearAlertsAction } from '../actions/clearAlertsAction';
-import { getStep4DataAction } from '@web-client/presenter/actions/getStep4DataAction';
+import { getCreatePetitionStep4DataAction } from '@web-client/presenter/actions/getCreatePetitionStep4DataAction';
import { incrementCurrentStepIndicatorAction } from '@web-client/presenter/actions/incrementCurrentStepIndicatorAction';
import { setValidationErrorsAction } from '../actions/setValidationErrorsAction';
import { startShowValidationAction } from '../actions/startShowValidationAction';
@@ -8,7 +8,7 @@ import { validateUploadPetitionStep4Action } from '@web-client/presenter/actions
export const updatedFilePetitionCompleteStep4Sequence = [
startShowValidationAction,
- getStep4DataAction,
+ getCreatePetitionStep4DataAction,
validateUploadPetitionStep4Action,
{
error: [setValidationErrorsAction],
diff --git a/web-client/src/presenter/sequences/updatedFilePetitionCompleteStep5Sequence.ts b/web-client/src/presenter/sequences/updatedFilePetitionCompleteStep5Sequence.ts
index 36527c96476..27f64297c62 100644
--- a/web-client/src/presenter/sequences/updatedFilePetitionCompleteStep5Sequence.ts
+++ b/web-client/src/presenter/sequences/updatedFilePetitionCompleteStep5Sequence.ts
@@ -1,11 +1,11 @@
import { clearAlertsAction } from '../actions/clearAlertsAction';
import { formatPetitionAction } from '@web-client/presenter/actions/formatPetitionAction';
import { generatePetitionPreviewPdfUrlAction } from '@web-client/presenter/actions/generatePetitionPreviewPdfUrlAction';
-import { getStep1DataAction } from '@web-client/presenter/actions/getStep1DataAction';
-import { getStep2DataAction } from '@web-client/presenter/actions/getStep2DataAction';
-import { getStep3DataAction } from '@web-client/presenter/actions/getStep3DataAction';
-import { getStep4DataAction } from '@web-client/presenter/actions/getStep4DataAction';
-import { getStep5DataAction } from '@web-client/presenter/actions/getStep5DataAction';
+import { getCreatePetitionStep1DataAction } from '@web-client/presenter/actions/getCreatePetitionStep1DataAction';
+import { getCreatePetitionStep2DataAction } from '@web-client/presenter/actions/getCreatePetitionStep2DataAction';
+import { getCreatePetitionStep3DataAction } from '@web-client/presenter/actions/getCreatePetitionStep3DataAction';
+import { getCreatePetitionStep4DataAction } from '@web-client/presenter/actions/getCreatePetitionStep4DataAction';
+import { getCreatePetitionStep5DataAction } from '@web-client/presenter/actions/getCreatePetitionStep5DataAction';
import { incrementCurrentStepIndicatorAction } from '@web-client/presenter/actions/incrementCurrentStepIndicatorAction';
import { setValidationErrorsAction } from '../actions/setValidationErrorsAction';
import { showProgressSequenceDecorator } from '@web-client/presenter/utilities/showProgressSequenceDecorator';
@@ -15,17 +15,17 @@ import { validateUploadPetitionStep5Action } from '@web-client/presenter/actions
export const updatedFilePetitionCompleteStep5Sequence = [
startShowValidationAction,
- getStep5DataAction,
+ getCreatePetitionStep5DataAction,
validateUploadPetitionStep5Action,
{
error: [setValidationErrorsAction],
success: showProgressSequenceDecorator([
clearAlertsAction,
stopShowValidationAction,
- getStep1DataAction,
- getStep2DataAction,
- getStep3DataAction,
- getStep4DataAction,
+ getCreatePetitionStep1DataAction,
+ getCreatePetitionStep2DataAction,
+ getCreatePetitionStep3DataAction,
+ getCreatePetitionStep4DataAction,
formatPetitionAction,
generatePetitionPreviewPdfUrlAction,
incrementCurrentStepIndicatorAction,
diff --git a/web-client/src/presenter/sequences/validateUpdatedFilePetitionStep2Sequence.ts b/web-client/src/presenter/sequences/validateUpdatedFilePetitionStep2Sequence.ts
index 073bcfaa497..5bbf5d2d861 100644
--- a/web-client/src/presenter/sequences/validateUpdatedFilePetitionStep2Sequence.ts
+++ b/web-client/src/presenter/sequences/validateUpdatedFilePetitionStep2Sequence.ts
@@ -1,5 +1,5 @@
import { clearAlertsAction } from '../actions/clearAlertsAction';
-import { getStep2DataAction } from '@web-client/presenter/actions/getStep2DataAction';
+import { getCreatePetitionStep2DataAction } from '@web-client/presenter/actions/getCreatePetitionStep2DataAction';
import { setValidationAlertErrorsAction } from '../actions/setValidationAlertErrorsAction';
import { setValidationErrorsAction } from '../actions/setValidationErrorsAction';
import { startShowValidationAction } from '../actions/startShowValidationAction';
@@ -8,7 +8,7 @@ import { validateUploadPetitionStep2Action } from '@web-client/presenter/actions
export const validateUpdatedFilePetitionStep2Sequence = [
startShowValidationAction,
- getStep2DataAction,
+ getCreatePetitionStep2DataAction,
validateUploadPetitionStep2Action,
{
error: [setValidationErrorsAction, setValidationAlertErrorsAction],
diff --git a/web-client/src/presenter/sequences/validateUpdatedFilePetitionStep5Sequence.ts b/web-client/src/presenter/sequences/validateUpdatedFilePetitionStep5Sequence.ts
index 7601acaf5ba..a8f04ffef2f 100644
--- a/web-client/src/presenter/sequences/validateUpdatedFilePetitionStep5Sequence.ts
+++ b/web-client/src/presenter/sequences/validateUpdatedFilePetitionStep5Sequence.ts
@@ -1,5 +1,5 @@
import { clearAlertsAction } from '../actions/clearAlertsAction';
-import { getStep5DataAction } from '@web-client/presenter/actions/getStep5DataAction';
+import { getCreatePetitionStep5DataAction } from '@web-client/presenter/actions/getCreatePetitionStep5DataAction';
import { setValidationAlertErrorsAction } from '../actions/setValidationAlertErrorsAction';
import { setValidationErrorsAction } from '../actions/setValidationErrorsAction';
import { startShowValidationAction } from '../actions/startShowValidationAction';
@@ -8,7 +8,7 @@ import { validateUploadPetitionStep5Action } from '@web-client/presenter/actions
export const validateUpdatedFilePetitionStep5Sequence = [
startShowValidationAction,
- getStep5DataAction,
+ getCreatePetitionStep5DataAction,
validateUploadPetitionStep5Action,
{
error: [setValidationErrorsAction, setValidationAlertErrorsAction],
diff --git a/web-client/src/presenter/state.ts b/web-client/src/presenter/state.ts
index 4f49d718215..700e2df412f 100644
--- a/web-client/src/presenter/state.ts
+++ b/web-client/src/presenter/state.ts
@@ -832,11 +832,6 @@ export const baseState = {
name: '',
},
trialSessionWorkingCopy: cloneDeep(initialTrialSessionWorkingCopyState),
- updatedFilePetitionStep2State: {
- selectedFilingOption: undefined,
- } as {
- selectedFilingOption?: string;
- },
user: null as any,
userContactEditProgress: {} as { inProgress?: boolean },
users: [] as RawUser[],
diff --git a/web-client/src/styles/custom.scss b/web-client/src/styles/custom.scss
index 47125b9dbec..1fad9c5aee8 100644
--- a/web-client/src/styles/custom.scss
+++ b/web-client/src/styles/custom.scss
@@ -2280,8 +2280,6 @@ button.change-scanner-button {
}
.alpha-list {
- padding-left: 20px;
- margin-top: 5px;
list-style-type: lower-alpha;
}
diff --git a/web-client/src/views/Dashboards/DashboardPetitioner.tsx b/web-client/src/views/Dashboards/DashboardPetitioner.tsx
index d8a4b62ff46..26968754677 100644
--- a/web-client/src/views/Dashboards/DashboardPetitioner.tsx
+++ b/web-client/src/views/Dashboards/DashboardPetitioner.tsx
@@ -78,18 +78,7 @@ export const DashboardPetitioner = connect(