From daed4aee09dd70066e74cfc0b1691a0c6cbeecae Mon Sep 17 00:00:00 2001 From: Mike Vesprini Date: Thu, 9 May 2024 22:12:11 -0700 Subject: [PATCH 01/33] feat: switch diff fields to only show the latest committed, and what will change (no states in between) --- app/lib/theme/CustomDiffFields.tsx | 66 ++++-------------------------- 1 file changed, 7 insertions(+), 59 deletions(-) diff --git a/app/lib/theme/CustomDiffFields.tsx b/app/lib/theme/CustomDiffFields.tsx index 41234491f5..152ac14b6b 100644 --- a/app/lib/theme/CustomDiffFields.tsx +++ b/app/lib/theme/CustomDiffFields.tsx @@ -60,7 +60,6 @@ const renderArrow = () => { }; const renderDiffData = ({ - oldData, newData, latestCommittedData, id, @@ -72,31 +71,10 @@ const renderDiffData = ({ contentSuffix, }) => { let components = []; - if (oldData !== null && oldData !== undefined) { - components.push( - - ); - if (contentSuffix) { - components.push( - contentSuffixElement(`${id}-${diffOldClsName}`, contentSuffix) - ); - } - if (newData !== null && newData !== undefined) { - components.push(renderArrow()); - } - } if ( latestCommittedData !== null && latestCommittedData !== undefined && - latestCommittedData !== oldData && latestCommittedData !== newData ) { components.push( @@ -120,8 +98,8 @@ const renderDiffData = ({ if ( newData !== null && newData !== undefined && - oldData !== null && - oldData !== undefined + latestCommittedData !== null && + latestCommittedData !== undefined ) { components.push( { let components = []; - if (oldData !== null && oldData !== undefined) { - components.push( - - ); - if (contentSuffix) { - components.push( - contentSuffixElement(`${id}-${diffOldClsName}`, contentSuffix) - ); - } - if ( - (newData !== null && newData !== undefined) || - (latestCommittedData !== null && latestCommittedData !== undefined) - ) { - components.push(renderArrow()); - } - } if ( latestCommittedData !== null && latestCommittedData !== undefined && - latestCommittedData !== oldData && latestCommittedData !== newData ) { components.push( @@ -223,8 +179,8 @@ const renderDiffString = ({ if ( newData !== null && newData !== undefined && - oldData !== null && - oldData !== undefined + latestCommittedData !== null && + latestCommittedData !== undefined ) { components.push( Not Entered); components.push(renderArrow()); components.push( @@ -261,13 +218,10 @@ const CUSTOM_DIFF_FIELDS = { StringField: (props) => { const { idSchema, formData, formContext, uiSchema } = props; const id = idSchema?.$id; - const oldData = formContext?.oldData?.[props.name]; const latestCommittedData = formContext?.latestCommittedData?.[props.name]; const isDate = uiSchema["ui:widget"] === "DateWidget"; const contentSuffix = uiSchema?.["ui:options"]?.contentSuffix; - return renderDiffString({ - oldData, newData: formData, latestCommittedData, id, @@ -280,7 +234,6 @@ const CUSTOM_DIFF_FIELDS = { NumberField: (props) => { const { idSchema, formData, formContext, uiSchema } = props; const id = idSchema?.$id; - const oldData = formContext?.oldData?.[props.name]; const latestCommittedData = formContext?.latestCommittedData?.[props.name]; const isMoney = uiSchema?.isMoney; const isPercentage = uiSchema?.isPercentage; @@ -289,8 +242,6 @@ const CUSTOM_DIFF_FIELDS = { // Handle text data mapping for certain number values let textData = uiSchema?.["ui:options"]?.text as string; - let oldTextData = - formContext?.oldUiSchema?.[props.name]?.["ui:options"]?.text; let latestCommittedTextData = formContext?.latestCommittedUiSchema?.[props.name]?.["ui:options"]?.text; @@ -298,7 +249,6 @@ const CUSTOM_DIFF_FIELDS = { // Switch to string rendering for archive textData = undefined; return renderDiffString({ - oldData: oldTextData, newData: textData, latestCommittedData: latestCommittedTextData, id, @@ -309,9 +259,8 @@ const CUSTOM_DIFF_FIELDS = { }); } - if (oldTextData || textData || latestCommittedTextData) { + if (textData || latestCommittedTextData) { return renderDiffString({ - oldData: oldTextData, newData: textData, latestCommittedData: latestCommittedTextData, id, @@ -322,7 +271,6 @@ const CUSTOM_DIFF_FIELDS = { }); } else { return renderDiffData({ - oldData, newData: formData, latestCommittedData, id, From 8c1761120640295447b534097df8ff2c9e1744f0 Mon Sep 17 00:00:00 2001 From: Mike Vesprini Date: Thu, 9 May 2024 22:13:50 -0700 Subject: [PATCH 02/33] chore: remove the oldData from the summary form pages --- .../Form/ProjectAnnualReportFormSummary.tsx | 5 --- .../Form/ProjectContactFormSummary.tsx | 12 ------ ...jectEmissionIntensityReportFormSummary.tsx | 27 ------------ app/components/Form/ProjectFormSummary.tsx | 38 ----------------- .../ProjectFundingAgreementFormSummary.tsx | 41 +------------------ .../Form/ProjectManagerFormSummary.tsx | 14 ------- .../ProjectMilestoneReportFormSummary.tsx | 5 --- .../ProjectQuarterlyReportFormSummary.tsx | 5 --- .../Form/ProjectSummaryReportFormSummary.tsx | 5 --- 9 files changed, 1 insertion(+), 151 deletions(-) diff --git a/app/components/Form/ProjectAnnualReportFormSummary.tsx b/app/components/Form/ProjectAnnualReportFormSummary.tsx index 1ec3967e30..438c9e96fb 100644 --- a/app/components/Form/ProjectAnnualReportFormSummary.tsx +++ b/app/components/Form/ProjectAnnualReportFormSummary.tsx @@ -46,9 +46,6 @@ const ProjectAnnualReportFormSummary: React.FC = ({ isPristine newFormData operation - formChangeByPreviousFormChangeId { - newFormData - } formByJsonSchemaName { jsonSchema } @@ -162,8 +159,6 @@ const ProjectAnnualReportFormSummary: React.FC = ({ uiSchema={reportingRequirementUiSchema} formContext={{ operation: annualReport.operation, - oldData: - annualReport.formChangeByPreviousFormChangeId?.newFormData, latestCommittedData, isAmendmentsAndOtherRevisionsSpecific: isOnAmendmentsAndOtherRevisionsPage, diff --git a/app/components/Form/ProjectContactFormSummary.tsx b/app/components/Form/ProjectContactFormSummary.tsx index c71c4fc399..eb57d53d05 100644 --- a/app/components/Form/ProjectContactFormSummary.tsx +++ b/app/components/Form/ProjectContactFormSummary.tsx @@ -181,11 +181,6 @@ const ProjectContactFormSummary: React.FC = ({ formData={node.newFormData} formContext={{ operation: node.operation, - oldData: node.formChangeByPreviousFormChangeId?.newFormData, - oldUiSchema: createProjectContactUiSchema( - node?.formChangeByPreviousFormChangeId?.asProjectContact - ?.contactByContactId?.fullName - ), latestCommittedData: latestCommittedContactNode?.node?.newFormData, latestCommittedUiSchema, @@ -260,13 +255,6 @@ const ProjectContactFormSummary: React.FC = ({ formData={primaryContact ? primaryContact.node.newFormData : null} formContext={{ operation: primaryContact?.node.operation, - oldData: - primaryContact?.node.formChangeByPreviousFormChangeId - ?.newFormData, - oldUiSchema: createProjectContactUiSchema( - primaryContact?.node?.formChangeByPreviousFormChangeId - ?.asProjectContact?.contactByContactId?.fullName - ), latestCommittedData: lastCommittedPrimaryContact?.node?.newFormData, latestCommittedUiSchema: createProjectContactUiSchema( diff --git a/app/components/Form/ProjectEmissionIntensityReportFormSummary.tsx b/app/components/Form/ProjectEmissionIntensityReportFormSummary.tsx index 86ea14749e..b5819e2799 100644 --- a/app/components/Form/ProjectEmissionIntensityReportFormSummary.tsx +++ b/app/components/Form/ProjectEmissionIntensityReportFormSummary.tsx @@ -51,13 +51,6 @@ const ProjectEmissionsIntensityReportFormSummary: React.FC = ({ formByJsonSchemaName { jsonSchema } - formChangeByPreviousFormChangeId { - newFormData - calculatedEiPerformance - paymentPercentage - maximumPerformanceMilestoneAmount - actualPerformanceMilestoneAmount - } } } } @@ -97,24 +90,6 @@ const ProjectEmissionsIntensityReportFormSummary: React.FC = ({ summaryReportingRequirement?.actualPerformanceMilestoneAmount, }; - const oldData = { - ...summaryReportingRequirement?.formChangeByPreviousFormChangeId - ?.newFormData, - //calculated values - calculatedEiPerformance: - summaryReportingRequirement?.formChangeByPreviousFormChangeId - ?.calculatedEiPerformance, - paymentPercentage: - summaryReportingRequirement?.formChangeByPreviousFormChangeId - ?.paymentPercentage, - maximumPerformanceMilestoneAmount: - summaryReportingRequirement?.formChangeByPreviousFormChangeId - ?.maximumPerformanceMilestoneAmount, - actualPerformanceMilestoneAmount: - summaryReportingRequirement?.formChangeByPreviousFormChangeId - ?.actualPerformanceMilestoneAmount, - }; - const latestCommittedData = { ...latestCommittedEmissionIntensityReportFormChange?.edges[0]?.node ?.newFormData, @@ -147,7 +122,6 @@ const ProjectEmissionsIntensityReportFormSummary: React.FC = ({ const filteredSchema = getSchemaAndDataIncludingCalculatedValues( emissionIntensityFormBySlug.jsonSchema.schema as JSONSchema7, newData, - oldData, { // This is only to add the (Adjusted) to the title of the field to differentiate it from the calculated field adjustedEmissionsIntensityPerformance: { @@ -265,7 +239,6 @@ const ProjectEmissionsIntensityReportFormSummary: React.FC = ({ actualPerformanceMilestoneAmount: summaryReportingRequirement?.actualPerformanceMilestoneAmount, operation: summaryReportingRequirement?.operation, - oldData, latestCommittedData, isAmendmentsAndOtherRevisionsSpecific: isOnAmendmentsAndOtherRevisionsPage, diff --git a/app/components/Form/ProjectFormSummary.tsx b/app/components/Form/ProjectFormSummary.tsx index 5a0868bf57..1706076b60 100644 --- a/app/components/Form/ProjectFormSummary.tsx +++ b/app/components/Form/ProjectFormSummary.tsx @@ -52,25 +52,6 @@ const ProjectFormSummary: React.FC = ({ name } } - formChangeByPreviousFormChangeId { - rank - newFormData - asProject { - operatorByOperatorId { - legalName - bcRegistryId - } - fundingStreamRfpByFundingStreamRfpId { - year - fundingStreamByFundingStreamId { - description - } - } - projectStatusByProjectStatusId { - name - } - } - } } latestCommittedProjectFormChanges: latestCommittedFormChangesFor( formDataTableName: "project" @@ -110,23 +91,7 @@ const ProjectFormSummary: React.FC = ({ // Show diff if it is not the first revision and not view only (rendered from the overview page) const renderDiff = !isFirstRevision && !viewOnly; - const oldData = { - ...projectFormChange.formChangeByPreviousFormChangeId?.newFormData, - rank: projectFormChange.formChangeByPreviousFormChangeId?.rank, - }; - const newDataAsProject = projectFormChange.asProject; - const previousDataAsProject = - projectFormChange.formChangeByPreviousFormChangeId?.asProject; - - const oldUiSchema = previousDataAsProject - ? createProjectUiSchema( - previousDataAsProject.operatorByOperatorId.legalName, - `${previousDataAsProject?.fundingStreamRfpByFundingStreamRfpId?.fundingStreamByFundingStreamId.description} - ${previousDataAsProject?.fundingStreamRfpByFundingStreamRfpId?.year}`, - previousDataAsProject.operatorByOperatorId.bcRegistryId, - previousDataAsProject.projectStatusByProjectStatusId.name - ) - : null; const latestCommittedUiSchema = latestCommittedData?.asProject ? createProjectUiSchema( @@ -148,7 +113,6 @@ const ProjectFormSummary: React.FC = ({ projectSchema as JSONSchema7, { ...projectFormChange?.newFormData, rank: projectFormChange.rank }, - oldData, { rank: { type: "number", @@ -199,8 +163,6 @@ const ProjectFormSummary: React.FC = ({ formData={formData} formContext={{ calculatedRank: projectFormChange.rank, - oldData, - oldUiSchema, latestCommittedData, latestCommittedUiSchema, operation: projectFormChange.operation, diff --git a/app/components/Form/ProjectFundingAgreementFormSummary.tsx b/app/components/Form/ProjectFundingAgreementFormSummary.tsx index a0adaec4f6..12e3ea405b 100644 --- a/app/components/Form/ProjectFundingAgreementFormSummary.tsx +++ b/app/components/Form/ProjectFundingAgreementFormSummary.tsx @@ -71,25 +71,6 @@ const ProjectFundingAgreementFormSummary: React.FC = ({ } } operation - formChangeByPreviousFormChangeId { - newFormData - eligibleExpensesToDate - holdbackAmountToDate - netPaymentsToDate - grossPaymentsToDate - calculatedTotalPaymentAmountToDate - proponentsSharePercentage - totalProjectValue - anticipatedFundingAmountPerFiscalYear { - edges { - # eslint-disable-next-line relay/unused-fields - node { - anticipatedFundingAmount - fiscalYear - } - } - } - } } } } @@ -169,25 +150,6 @@ const ProjectFundingAgreementFormSummary: React.FC = ({ ), }; - const oldFundingFormChanges = - revision.summaryProjectFundingAgreementFormChanges.edges[0]?.node - .formChangeByPreviousFormChangeId; - - const oldData = { - ...oldFundingFormChanges?.newFormData, - eligibleExpensesToDate: oldFundingFormChanges?.eligibleExpensesToDate, - holdbackAmountToDate: oldFundingFormChanges?.holdbackAmountToDate, - netPaymentsToDate: oldFundingFormChanges?.netPaymentsToDate, - grossPaymentsToDate: oldFundingFormChanges?.grossPaymentsToDate, - totalPaymentAmountToDate: - oldFundingFormChanges?.calculatedTotalPaymentAmountToDate, - proponentsSharePercentage: oldFundingFormChanges?.proponentsSharePercentage, - totalProjectValue: oldFundingFormChanges?.totalProjectValue, - anticipatedFundingAmountPerFiscalYear: cleanupNestedNodes( - oldFundingFormChanges?.anticipatedFundingAmountPerFiscalYear.edges - ), - }; - const fundingStream = revision.projectFormChange.asProject.fundingStreamRfpByFundingStreamRfpId .fundingStreamByFundingStreamId.name; @@ -223,7 +185,7 @@ const ProjectFundingAgreementFormSummary: React.FC = ({ const filteredSchema = getSchemaAndDataIncludingCalculatedValues( schema as JSONSchema7, newData, - oldData + latestCommittedData ); // Set the formSchema and formData based on showing the diff or not @@ -342,7 +304,6 @@ const ProjectFundingAgreementFormSummary: React.FC = ({ fundingAgreementSummary?.totalProjectValue, calculatedProponentsSharePercentage: fundingAgreementSummary?.proponentsSharePercentage, - oldData, latestCommittedData, isAmendmentsAndOtherRevisionsSpecific: isOnAmendmentsAndOtherRevisionsPage, diff --git a/app/components/Form/ProjectManagerFormSummary.tsx b/app/components/Form/ProjectManagerFormSummary.tsx index 9ba457a8a1..0ce9c978de 100644 --- a/app/components/Form/ProjectManagerFormSummary.tsx +++ b/app/components/Form/ProjectManagerFormSummary.tsx @@ -42,14 +42,6 @@ const ProjectManagerFormSummary: React.FC = ({ fullName } } - formChangeByPreviousFormChangeId { - newFormData - asProjectManager { - cifUserByCifUserId { - fullName - } - } - } formByJsonSchemaName { jsonSchema } @@ -146,12 +138,6 @@ const ProjectManagerFormSummary: React.FC = ({ formData={node.formChange.newFormData} formContext={{ operation: node.formChange?.operation, - oldData: - node.formChange?.formChangeByPreviousFormChangeId?.newFormData, - oldUiSchema: createProjectManagerUiSchema( - node.formChange?.formChangeByPreviousFormChangeId - ?.asProjectManager?.cifUserByCifUserId?.fullName - ), latestCommittedData: latestCommittedManagerNode?.node?.newFormData, latestCommittedUiSchema, isAmendmentsAndOtherRevisionsSpecific: diff --git a/app/components/Form/ProjectMilestoneReportFormSummary.tsx b/app/components/Form/ProjectMilestoneReportFormSummary.tsx index 327e81d397..8f8e37c3e2 100644 --- a/app/components/Form/ProjectMilestoneReportFormSummary.tsx +++ b/app/components/Form/ProjectMilestoneReportFormSummary.tsx @@ -50,9 +50,6 @@ const ProjectMilestoneReportFormSummary: React.FC = ({ isPristine newFormData operation - formChangeByPreviousFormChangeId { - newFormData - } formByJsonSchemaName { jsonSchema } @@ -243,8 +240,6 @@ const ProjectMilestoneReportFormSummary: React.FC = ({ calculatedNetAmount: milestoneReport?.newFormData?.calculatedNetAmount, operation: milestoneReport.operation, - oldData: - milestoneReport.formChangeByPreviousFormChangeId?.newFormData, latestCommittedData, isAmendmentsAndOtherRevisionsSpecific: isOnAmendmentsAndOtherRevisionsPage, diff --git a/app/components/Form/ProjectQuarterlyReportFormSummary.tsx b/app/components/Form/ProjectQuarterlyReportFormSummary.tsx index fe2e9d27ae..c446beb80e 100644 --- a/app/components/Form/ProjectQuarterlyReportFormSummary.tsx +++ b/app/components/Form/ProjectQuarterlyReportFormSummary.tsx @@ -47,9 +47,6 @@ const ProjectQuarterlyReportFormSummary: React.FC = ({ isPristine newFormData operation - formChangeByPreviousFormChangeId { - newFormData - } formByJsonSchemaName { jsonSchema } @@ -169,8 +166,6 @@ const ProjectQuarterlyReportFormSummary: React.FC = ({ formData={formData} formContext={{ operation: quarterlyReport.operation, - oldData: - quarterlyReport.formChangeByPreviousFormChangeId?.newFormData, latestCommittedData, isAmendmentsAndOtherRevisionsSpecific: isOnAmendmentsAndOtherRevisionsPage, diff --git a/app/components/Form/ProjectSummaryReportFormSummary.tsx b/app/components/Form/ProjectSummaryReportFormSummary.tsx index 31cbc5139a..56f7c2778d 100644 --- a/app/components/Form/ProjectSummaryReportFormSummary.tsx +++ b/app/components/Form/ProjectSummaryReportFormSummary.tsx @@ -56,9 +56,6 @@ const ProjectSummaryReportFormSummary: React.FC = ({ node { newFormData operation - formChangeByPreviousFormChangeId { - newFormData - } } } } @@ -153,8 +150,6 @@ const ProjectSummaryReportFormSummary: React.FC = ({ uiSchema={projectSummaryReportUiSchema} formContext={{ operation: projectSummaryReport.operation, - oldData: - projectSummaryReport.formChangeByPreviousFormChangeId?.newFormData, latestCommittedData: latestCommittedProjectSummaryFormChanges?.edges[0]?.node ?.newFormData, From 57a84393a0431042c9ef78f60309bc810bf3d6e0 Mon Sep 17 00:00:00 2001 From: Mike Vesprini Date: Thu, 9 May 2024 22:32:12 -0700 Subject: [PATCH 03/33] test: update test cases, except for 0 handling --- .../unit/lib/theme/CustomDiffFields.test.tsx | 135 ++++-------------- 1 file changed, 29 insertions(+), 106 deletions(-) diff --git a/app/tests/unit/lib/theme/CustomDiffFields.test.tsx b/app/tests/unit/lib/theme/CustomDiffFields.test.tsx index 36027a32bd..1e9b01de21 100644 --- a/app/tests/unit/lib/theme/CustomDiffFields.test.tsx +++ b/app/tests/unit/lib/theme/CustomDiffFields.test.tsx @@ -77,8 +77,8 @@ const latestCommittedData = { }; describe("The Object Field Template", () => { - // 111 - it("shows diffs when there is an old, new, and latest committed value, and old !== latest committed", () => { + + it("shows diffs when there is a latest committed value that has been changed in the new data", () => { const componentUnderTest = render( { uiSchema={uiTestSchema} formData={formData} formContext={{ - oldData: oldFormData, - latestCommittedData, - oldUiSchema: oldUiTestSchema, + latestCommittedData: latestCommittedData, latestCommittedUiSchema: latestCommittedUiTestSchema, operation: "UPDATE", }} @@ -97,62 +95,22 @@ describe("The Object Field Template", () => { ); expect(componentUnderTest.getByText("stringTest NEW")).toBeInTheDocument(); - expect(componentUnderTest.getByText("stringTest OLD")).toBeInTheDocument(); - expect( - componentUnderTest.getByText(/^(.*?)stringTest LAST COMMITTED/) - ).toBeInTheDocument(); + expect(componentUnderTest.getByText("stringTest LAST COMMITTED")).toBeInTheDocument(); + expect(getComputedStyle(componentUnderTest.getByText("stringTest LAST COMMITTED")).textDecoration).toBe("line-through") + expect(componentUnderTest.getByText("$100.00")).toBeInTheDocument(); - expect(componentUnderTest.getByText("$200.00")).toBeInTheDocument(); expect(componentUnderTest.getByText("$300.00")).toBeInTheDocument(); - expect( - componentUnderTest.getByText("I replaced the ID") - ).toBeInTheDocument(); - expect( - componentUnderTest.getByText("I replaced the OLD ID") - ).toBeInTheDocument(); + expect(getComputedStyle(componentUnderTest.getByText("$300.00")).textDecoration).toBe("line-through") expect( componentUnderTest.getByText(/I am the last committed value/i) ).toBeInTheDocument(); - }); - - it("shows diffs when there is an old, new, and latest committed value and old === latest committed", () => { - const componentUnderTest = render( - - ); - - expect(componentUnderTest.getByText("stringTest NEW")).toBeInTheDocument(); - expect(componentUnderTest.getByText("stringTest OLD")).toBeInTheDocument(); - expect( - componentUnderTest.queryByText(/^(.*?)LAST COMMITTED/) - ).not.toBeInTheDocument(); - expect(componentUnderTest.getByText("$100.00")).toBeInTheDocument(); - expect(componentUnderTest.getByText("$200.00")).toBeInTheDocument(); - expect(componentUnderTest.queryByText("$300.00")).not.toBeInTheDocument(); expect( componentUnderTest.getByText("I replaced the ID") ).toBeInTheDocument(); - expect( - componentUnderTest.getByText("I replaced the OLD ID") - ).toBeInTheDocument(); - expect( - componentUnderTest.queryByText(/I am the last committed value/i) - ).not.toBeInTheDocument(); }); + // 101 - it("shows data has been removed when there is old data and latest committed data but no new data", () => { + it("shows data has been removed when there is latest committed data but no new data", () => { const componentUnderTest = render( { uiSchema={uiTestSchema} formData={null} formContext={{ - oldData: oldFormData, - oldUiSchema: oldUiTestSchema, operation: "CREATE", latestCommittedData, + latestCommittedUiSchema: latestCommittedUiTestSchema }} /> ); - expect(componentUnderTest.getByText("stringTest OLD")).toHaveClass( + expect(componentUnderTest.getByText("stringTest LAST COMMITTED")).toHaveClass( "diffOld" ); - expect(componentUnderTest.getByText("$200.00")).toHaveClass("diffOld"); - expect(componentUnderTest.getByText("I replaced the OLD ID")).toHaveClass( + expect(componentUnderTest.getByText("$300.00")).toHaveClass("diffOld"); + expect(componentUnderTest.getByText("I am the last committed value")).toHaveClass( "diffOld" ); }); // 010 - it("shows data has been added when there is newData, and there is no old data or no latest committed", () => { + it("shows data has been added when there is newData, and there is no latest committed", () => { const componentUnderTest = render( { uiSchema={uiTestSchema} formData={formData} formContext={{ - oldData: null, oldUiSchema: oldUiTestSchema, operation: "CREATE", }} @@ -203,7 +159,7 @@ describe("The Object Field Template", () => { ); }); // 011 - it("shows data has been added when there is newData, latest and there is no old data", () => { + it("shows data has been added when there is newData, and latest committed data", () => { const componentUnderTest = render( { uiSchema={uiTestSchema} formData={formData} formContext={{ - oldData: null, - oldUiSchema: oldUiTestSchema, operation: "CREATE", - latestCommittedData: latestCommittedData, + latestCommittedData, }} /> ); @@ -240,8 +194,8 @@ describe("The Object Field Template", () => { uiSchema={uiTestSchema} formData={formData} formContext={{ - oldData: oldFormData, - oldUiSchema: oldUiTestSchema, + latestCommittedData, + latestCommittedUiSchema: latestCommittedUiTestSchema, operation: "UPDATE", }} /> @@ -262,8 +216,7 @@ describe("The Object Field Template", () => { uiSchema={uiTestSchema} formData={formData} formContext={{ - oldData: oldFormData, - oldUiSchema: oldUiTestSchema, + latestCommittedData: latestCommittedData, operation: "UPDATE", }} /> @@ -282,8 +235,8 @@ describe("The Object Field Template", () => { uiSchema={uiTestSchema} formData={formData} formContext={{ - oldData: oldFormData, - oldUiSchema: oldUiTestSchema, + latestCommittedData, + latestCommittedUiSchema: latestCommittedUiTestSchema, operation: "UPDATE", }} /> @@ -303,8 +256,6 @@ describe("The Object Field Template", () => { uiSchema={uiTestSchema} formData={null} formContext={{ - oldData: null, - oldUiSchema: null, operation: "CREATE", }} /> @@ -323,8 +274,8 @@ describe("The Object Field Template", () => { uiSchema={uiTestSchema} formData={formData} formContext={{ - oldData: oldFormData, - oldUiSchema: oldUiTestSchema, + latestCommittedData, + latestCommittedUiSchema: latestCommittedUiTestSchema, operation: "UPDATE", isAmendmentsAndOtherRevisionsSpecific: true, }} @@ -334,10 +285,11 @@ describe("The Object Field Template", () => { expect(componentUnderTest.getByText("stringTest NEW")).toHaveClass( "diffNew" ); - expect(componentUnderTest.getByText("stringTest OLD")).toHaveClass( + expect(componentUnderTest.getByText("stringTest LAST COMMITTED")).toHaveClass( "diffOld" ); }); + it("handles 0 when latest committed data is 0", () => { const latestCommittedDataWithZero = { stringTest: "stringTest LAST COMMITTED", @@ -377,16 +329,15 @@ describe("The Object Field Template", () => { uiSchema={uiTestSchema} formData={formDataWithZero} formContext={{ - oldData: oldFormData, - oldUiSchema: oldUiTestSchema, operation: "UPDATE", isAmendmentsAndOtherRevisionsSpecific: true, latestCommittedData, }} /> ); - expect(componentUnderTest.getByText("0")).toHaveClass("diffNew"); + expect(componentUnderTest.getByText("$0.00")).toHaveClass("diffNew"); }); + it("handles 0 when latestCommittedData and oldData are 0, (the same), and newFormData exists", () => { const latestCommittedDataWithZero = { stringTest: "stringTest LAST COMMITTED", @@ -418,34 +369,8 @@ describe("The Object Field Template", () => { expect(componentUnderTest.getAllByText("0")).toHaveLength(1); expect(componentUnderTest.getByText("100")).toHaveClass("diffNew"); }); - it("handles 0 when oldData is 0", () => { - const oldDataWithZero = { - stringTest: "", - numberTest: 0, - numericIdTest: 0, - }; - const componentUnderTest = render( - - ); - expect(componentUnderTest.getAllByText("0")[0]).toHaveClass("diffOld"); - expect(componentUnderTest.getAllByText("0")).toHaveLength(1); - }); - - it("handles 0 when oldData and latest data is 0", () => { + it("handles 0 when latest data is 0", () => { const oldDataWithZero = { stringTest: "", numberTest: 0, @@ -476,7 +401,7 @@ describe("The Object Field Template", () => { expect(componentUnderTest.getAllByText("0")[0]).toHaveClass("diffOld"); expect(componentUnderTest.getAllByText("0")).toHaveLength(1); }); - it("handles 0 when newData and latest data is 0", () => { + it.only("handles 0 when newData and latest data is 0", () => { const formDataWithZero = { stringTest: "", numberTest: 0, @@ -495,8 +420,6 @@ describe("The Object Field Template", () => { uiSchema={uiTestSchema} formData={formDataWithZero} formContext={{ - oldData: oldFormData, - oldUiSchema: oldUiTestSchema, operation: "UPDATE", isAmendmentsAndOtherRevisionsSpecific: true, latestCommittedData: latestCommittedDataWithZero, From 39b5183cd31ae69e7f7c90f8df5ffba412db022e Mon Sep 17 00:00:00 2001 From: Mike Vesprini Date: Fri, 10 May 2024 21:26:51 -0700 Subject: [PATCH 04/33] chore: fix the project status showing showing Not Entered for enterd statuses in project form summary --- app/components/Form/ProjectFormSummary.tsx | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/app/components/Form/ProjectFormSummary.tsx b/app/components/Form/ProjectFormSummary.tsx index 1706076b60..2ce5263205 100644 --- a/app/components/Form/ProjectFormSummary.tsx +++ b/app/components/Form/ProjectFormSummary.tsx @@ -93,12 +93,13 @@ const ProjectFormSummary: React.FC = ({ const newDataAsProject = projectFormChange.asProject; - const latestCommittedUiSchema = latestCommittedData?.asProject + const latestCommittedAsProject = latestCommittedProjectFormChanges?.edges[0]?.node?.asProject + const latestCommittedUiSchema = latestCommittedAsProject ? createProjectUiSchema( - latestCommittedData.asProject.operatorByOperatorId.legalName, - `${latestCommittedData.asProject?.fundingStreamRfpByFundingStreamRfpId?.fundingStreamByFundingStreamId.description} - ${latestCommittedData.asProject?.fundingStreamRfpByFundingStreamRfpId?.year}`, - latestCommittedData.asProject.operatorByOperatorId.bcRegistryId, - latestCommittedData.asProject.projectStatusByProjectStatusId.name + latestCommittedAsProject.operatorByOperatorId.legalName, + `${latestCommittedAsProject?.fundingStreamRfpByFundingStreamRfpId?.fundingStreamByFundingStreamId.description} - ${latestCommittedAsProject?.fundingStreamRfpByFundingStreamRfpId?.year}`, + latestCommittedAsProject.operatorByOperatorId.bcRegistryId, + latestCommittedAsProject.projectStatusByProjectStatusId.name ) : null; @@ -113,6 +114,7 @@ const ProjectFormSummary: React.FC = ({ projectSchema as JSONSchema7, { ...projectFormChange?.newFormData, rank: projectFormChange.rank }, + latestCommittedData, { rank: { type: "number", From 028d1a7f53a5ead9a9265a49d0bd67934574d83e Mon Sep 17 00:00:00 2001 From: Mike Vesprini Date: Fri, 10 May 2024 21:28:03 -0700 Subject: [PATCH 05/33] test: update form diff tests --- .../unit/lib/theme/CustomDiffFields.test.tsx | 156 ++++-------------- 1 file changed, 31 insertions(+), 125 deletions(-) diff --git a/app/tests/unit/lib/theme/CustomDiffFields.test.tsx b/app/tests/unit/lib/theme/CustomDiffFields.test.tsx index 1e9b01de21..845d6bda66 100644 --- a/app/tests/unit/lib/theme/CustomDiffFields.test.tsx +++ b/app/tests/unit/lib/theme/CustomDiffFields.test.tsx @@ -13,6 +13,11 @@ const testSchema = { title: "Proposal Reference", }, numberTest: { + type: "number", + title: "Score", + default: undefined, + }, + moneyTest: { type: "number", title: "Total Funding Request", default: undefined, @@ -27,12 +32,18 @@ const testSchema = { }; const uiTestSchema = { - "ui:order": ["stringTest", "numberTest", "numericIdTest"], + "ui:order": ["stringTest", "numberTest", "moneyTest", "numericIdTest"], stringTest: { "bcgov:size": "small", "ui:help": (e.g. 2020-RFP-1-ABCD-123), }, numberTest: { + "ui:widget": "NumberWidget", + isMoney: false, + "ui:col-md": 12, + "bcgov:size": "small", + }, + moneyTest: { "ui:widget": "NumberWidget", isMoney: true, "ui:col-md": 12, @@ -52,33 +63,25 @@ const uiTestSchema = { const formData = { stringTest: "stringTest NEW", numberTest: 100, + moneyTest: 10, numericIdTest: 1, }; -const oldFormData = { - stringTest: "stringTest OLD", - numberTest: 200, - numericIdTest: 2, +const latestCommittedData = { + stringTest: "stringTest LAST COMMITTED", + numberTest: 300, + moneyTest: 30, + numericIdTest: 3, }; -const oldUiTestSchema = JSON.parse(JSON.stringify(uiTestSchema)); - -oldUiTestSchema.numericIdTest["ui:options"].text = "I replaced the OLD ID"; - const latestCommittedUiTestSchema = JSON.parse(JSON.stringify(uiTestSchema)); latestCommittedUiTestSchema.numericIdTest["ui:options"].text = "I am the last committed value"; -const latestCommittedData = { - stringTest: "stringTest LAST COMMITTED", - numberTest: 300, - numericIdTest: 3, -}; - describe("The Object Field Template", () => { - it("shows diffs when there is a latest committed value that has been changed in the new data", () => { + it("shows diffs when the latest committed value exists and has been changed in the new data", () => { const componentUnderTest = render( { expect(componentUnderTest.getByText("stringTest NEW")).toBeInTheDocument(); expect(componentUnderTest.getByText("stringTest LAST COMMITTED")).toBeInTheDocument(); - expect(getComputedStyle(componentUnderTest.getByText("stringTest LAST COMMITTED")).textDecoration).toBe("line-through") - expect(componentUnderTest.getByText("$100.00")).toBeInTheDocument(); - expect(componentUnderTest.getByText("$300.00")).toBeInTheDocument(); - expect(getComputedStyle(componentUnderTest.getByText("$300.00")).textDecoration).toBe("line-through") + expect(componentUnderTest.getByText("100")).toBeInTheDocument(); + expect(componentUnderTest.getByText("300")).toBeInTheDocument(); + + expect(componentUnderTest.getByText("$10.00")).toBeInTheDocument(); + expect(componentUnderTest.getByText("$30.00")).toBeInTheDocument(); + expect( componentUnderTest.getByText(/I am the last committed value/i) ).toBeInTheDocument(); @@ -109,7 +114,6 @@ describe("The Object Field Template", () => { ).toBeInTheDocument(); }); - // 101 it("shows data has been removed when there is latest committed data but no new data", () => { const componentUnderTest = render( { expect(componentUnderTest.getByText("stringTest LAST COMMITTED")).toHaveClass( "diffOld" ); - expect(componentUnderTest.getByText("$300.00")).toHaveClass("diffOld"); + expect(componentUnderTest.getByText("$30.00")).toHaveClass("diffOld"); expect(componentUnderTest.getByText("I am the last committed value")).toHaveClass( "diffOld" ); }); - // 010 it("shows data has been added when there is newData, and there is no latest committed", () => { const componentUnderTest = render( { uiSchema={uiTestSchema} formData={formData} formContext={{ - oldUiSchema: oldUiTestSchema, + latestCommittedUiSchema: latestCommittedUiTestSchema, operation: "CREATE", }} /> @@ -153,7 +156,7 @@ describe("The Object Field Template", () => { expect(componentUnderTest.getByText("stringTest NEW")).toHaveClass( "diffNew" ); - expect(componentUnderTest.getByText("$100.00")).toHaveClass("diffNew"); + expect(componentUnderTest.getByText("$10.00")).toHaveClass("diffNew"); expect(componentUnderTest.getByText("I replaced the ID")).toHaveClass( "diffNew" ); @@ -180,8 +183,8 @@ describe("The Object Field Template", () => { expect( componentUnderTest.getByText("stringTest LAST COMMITTED") ).toHaveClass("diffOld"); - expect(componentUnderTest.getByText("$100.00")).toHaveClass("diffNew"); - expect(componentUnderTest.getByText("$300.00")).toHaveClass("diffOld"); + expect(componentUnderTest.getByText("100")).toHaveClass("diffNew"); + expect(componentUnderTest.getByText("300")).toHaveClass("diffOld"); }); // numericId test @@ -221,12 +224,10 @@ describe("The Object Field Template", () => { }} /> ); - expect(componentUnderTest.getByText("$100.00")).toBeInTheDocument(); + expect(componentUnderTest.getByText("$10.00")).toBeInTheDocument(); }); it("shows the number without a preceding $ when uiSchema.isMoney is false in a NumberField's uiSchema", () => { - delete uiTestSchema.numberTest.isMoney; - const componentUnderTest = render( { uiSchema={uiTestSchema} formData={formData} formContext={{ - oldData: oldFormData, - oldUiSchema: oldUiTestSchema, operation: "UPDATE", isAmendmentsAndOtherRevisionsSpecific: true, latestCommittedData: latestCommittedDataWithZero, @@ -335,99 +334,6 @@ describe("The Object Field Template", () => { }} /> ); - expect(componentUnderTest.getByText("$0.00")).toHaveClass("diffNew"); - }); - - it("handles 0 when latestCommittedData and oldData are 0, (the same), and newFormData exists", () => { - const latestCommittedDataWithZero = { - stringTest: "stringTest LAST COMMITTED", - numberTest: 0, - }; - - const oldDataWithZero = { - stringTest: "stringTest FORM DATA", - numberTest: 0, - }; - - const componentUnderTest = render( - - ); - expect(componentUnderTest.getAllByText("0")[0]).toHaveClass("diffOld"); - expect(componentUnderTest.getAllByText("0")).toHaveLength(1); - expect(componentUnderTest.getByText("100")).toHaveClass("diffNew"); - }); - - it("handles 0 when latest data is 0", () => { - const oldDataWithZero = { - stringTest: "", - numberTest: 0, - numericIdTest: 0, - }; - const latestCommittedDataWithZero = { - stringTest: "", - numberTest: 0, - numericIdTest: 0, - }; - const componentUnderTest = render( - - ); - - expect(componentUnderTest.getAllByText("0")[0]).toHaveClass("diffOld"); - expect(componentUnderTest.getAllByText("0")).toHaveLength(1); - }); - it.only("handles 0 when newData and latest data is 0", () => { - const formDataWithZero = { - stringTest: "", - numberTest: 0, - numericIdTest: 0, - }; - const latestCommittedDataWithZero = { - stringTest: "", - numberTest: 0, - numericIdTest: 0, - }; - const componentUnderTest = render( - - ); - - expect(componentUnderTest.getByText("200")).toHaveClass("diffOld"); expect(componentUnderTest.getByText("0")).toHaveClass("diffNew"); }); }); From 3d8e8682d1d9eaef13b302767f2b82c99c2f31c6 Mon Sep 17 00:00:00 2001 From: Mike Vesprini Date: Mon, 13 May 2024 15:47:55 -0700 Subject: [PATCH 06/33] chore: linting --- app/components/Form/ProjectFormSummary.tsx | 3 ++- app/lib/theme/CustomDiffFields.tsx | 3 +-- .../unit/lib/theme/CustomDiffFields.test.tsx | 25 ++++++++++--------- 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/app/components/Form/ProjectFormSummary.tsx b/app/components/Form/ProjectFormSummary.tsx index 2ce5263205..2a8f40f925 100644 --- a/app/components/Form/ProjectFormSummary.tsx +++ b/app/components/Form/ProjectFormSummary.tsx @@ -93,7 +93,8 @@ const ProjectFormSummary: React.FC = ({ const newDataAsProject = projectFormChange.asProject; - const latestCommittedAsProject = latestCommittedProjectFormChanges?.edges[0]?.node?.asProject + const latestCommittedAsProject = + latestCommittedProjectFormChanges?.edges[0]?.node?.asProject; const latestCommittedUiSchema = latestCommittedAsProject ? createProjectUiSchema( latestCommittedAsProject.operatorByOperatorId.legalName, diff --git a/app/lib/theme/CustomDiffFields.tsx b/app/lib/theme/CustomDiffFields.tsx index 152ac14b6b..06fb3e2ed1 100644 --- a/app/lib/theme/CustomDiffFields.tsx +++ b/app/lib/theme/CustomDiffFields.tsx @@ -194,8 +194,7 @@ const renderDiffString = ({ contentSuffixElement(`${id}-${diffOldClsName}`, contentSuffix) ); } - } - else if (newData !== null && newData !== undefined) { + } else if (newData !== null && newData !== undefined) { components.push(Not Entered); components.push(renderArrow()); components.push( diff --git a/app/tests/unit/lib/theme/CustomDiffFields.test.tsx b/app/tests/unit/lib/theme/CustomDiffFields.test.tsx index 845d6bda66..eb2c0997d8 100644 --- a/app/tests/unit/lib/theme/CustomDiffFields.test.tsx +++ b/app/tests/unit/lib/theme/CustomDiffFields.test.tsx @@ -80,7 +80,6 @@ latestCommittedUiTestSchema.numericIdTest["ui:options"].text = "I am the last committed value"; describe("The Object Field Template", () => { - it("shows diffs when the latest committed value exists and has been changed in the new data", () => { const componentUnderTest = render( { ); expect(componentUnderTest.getByText("stringTest NEW")).toBeInTheDocument(); - expect(componentUnderTest.getByText("stringTest LAST COMMITTED")).toBeInTheDocument(); + expect( + componentUnderTest.getByText("stringTest LAST COMMITTED") + ).toBeInTheDocument(); expect(componentUnderTest.getByText("100")).toBeInTheDocument(); expect(componentUnderTest.getByText("300")).toBeInTheDocument(); @@ -125,17 +126,17 @@ describe("The Object Field Template", () => { formContext={{ operation: "CREATE", latestCommittedData, - latestCommittedUiSchema: latestCommittedUiTestSchema + latestCommittedUiSchema: latestCommittedUiTestSchema, }} /> ); - expect(componentUnderTest.getByText("stringTest LAST COMMITTED")).toHaveClass( - "diffOld" - ); + expect( + componentUnderTest.getByText("stringTest LAST COMMITTED") + ).toHaveClass("diffOld"); expect(componentUnderTest.getByText("$30.00")).toHaveClass("diffOld"); - expect(componentUnderTest.getByText("I am the last committed value")).toHaveClass( - "diffOld" - ); + expect( + componentUnderTest.getByText("I am the last committed value") + ).toHaveClass("diffOld"); }); it("shows data has been added when there is newData, and there is no latest committed", () => { @@ -286,9 +287,9 @@ describe("The Object Field Template", () => { expect(componentUnderTest.getByText("stringTest NEW")).toHaveClass( "diffNew" ); - expect(componentUnderTest.getByText("stringTest LAST COMMITTED")).toHaveClass( - "diffOld" - ); + expect( + componentUnderTest.getByText("stringTest LAST COMMITTED") + ).toHaveClass("diffOld"); }); it("handles 0 when latest committed data is 0", () => { From b2b8e5c3d8ee82d992c6e9668e8b042d260bc659 Mon Sep 17 00:00:00 2001 From: Mike Vesprini Date: Mon, 13 May 2024 15:55:40 -0700 Subject: [PATCH 07/33] test: update test data in project form summary test to be latest committed data --- .../Form/ProjectFormSummary.test.tsx | 58 ++++++++++--------- 1 file changed, 32 insertions(+), 26 deletions(-) diff --git a/app/tests/unit/components/Form/ProjectFormSummary.test.tsx b/app/tests/unit/components/Form/ProjectFormSummary.test.tsx index d52ebd3325..ea5d2353f7 100644 --- a/app/tests/unit/components/Form/ProjectFormSummary.test.tsx +++ b/app/tests/unit/components/Form/ProjectFormSummary.test.tsx @@ -51,34 +51,40 @@ const mockQueryPayload = { name: "Test Project Status Name", }, }, - formChangeByPreviousFormChangeId: { - rank: 987654321, - newFormData: { - proposalReference: "Test Proposal Reference PREVIOUS", - operatorId: 1, - fundingStreamRfpId: 1, - projectStatusId: 1, - summary: "Test Summary", - projectName: "Test Project Name", - totalFundingRequest: 100.0, - score: 1, - projectType: "test project type PREVIOUS", - }, - asProject: { - operatorByOperatorId: { - legalName: "Test Legal Name PREVIOUS", - bcRegistryId: "Test BC Registry ID", - }, - fundingStreamRfpByFundingStreamRfpId: { - year: 2020, - fundingStreamByFundingStreamId: { - description: "Test Funding Stream Description", + latestCommittedProjectFormChanges: { + edges: [ + { + node: { + rank: 987654321, + newFormData: { + proposalReference: "Test Proposal Reference PREVIOUS", + operatorId: 1, + fundingStreamRfpId: 1, + projectStatusId: 1, + summary: "Test Summary", + projectName: "Test Project Name", + totalFundingRequest: 100.0, + score: 1, + projectType: "test project type PREVIOUS", + }, + asProject: { + operatorByOperatorId: { + legalName: "Test Legal Name PREVIOUS", + bcRegistryId: "Test BC Registry ID", + }, + fundingStreamRfpByFundingStreamRfpId: { + year: 2020, + fundingStreamByFundingStreamId: { + description: "Test Funding Stream Description", + }, + }, + projectStatusByProjectStatusId: { + name: "Test Project Status Name", + }, + }, }, }, - projectStatusByProjectStatusId: { - name: "Test Project Status Name", - }, - }, + ], }, }, }; From 6af5a6329314ec6617b6854915125ee1847ab6cc Mon Sep 17 00:00:00 2001 From: Mike Vesprini Date: Tue, 14 May 2024 09:30:33 -0700 Subject: [PATCH 08/33] test: fix project form summary tests to use latest committed data --- .../Form/ProjectFormSummary.test.tsx | 60 +++++++++---------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/app/tests/unit/components/Form/ProjectFormSummary.test.tsx b/app/tests/unit/components/Form/ProjectFormSummary.test.tsx index ea5d2353f7..a263ecf181 100644 --- a/app/tests/unit/components/Form/ProjectFormSummary.test.tsx +++ b/app/tests/unit/components/Form/ProjectFormSummary.test.tsx @@ -51,41 +51,41 @@ const mockQueryPayload = { name: "Test Project Status Name", }, }, - latestCommittedProjectFormChanges: { - edges: [ - { - node: { - rank: 987654321, - newFormData: { - proposalReference: "Test Proposal Reference PREVIOUS", - operatorId: 1, - fundingStreamRfpId: 1, - projectStatusId: 1, - summary: "Test Summary", - projectName: "Test Project Name", - totalFundingRequest: 100.0, - score: 1, - projectType: "test project type PREVIOUS", + }, + latestCommittedProjectFormChanges: { + edges: [ + { + node: { + rank: 987654321, + newFormData: { + proposalReference: "Test Proposal Reference PREVIOUS", + operatorId: 1, + fundingStreamRfpId: 1, + projectStatusId: 1, + summary: "Test Summary", + projectName: "Test Project Name", + totalFundingRequest: 100.0, + score: 1, + projectType: "test project type PREVIOUS", + }, + asProject: { + operatorByOperatorId: { + legalName: "Test Legal Name PREVIOUS", + bcRegistryId: "Test BC Registry ID", }, - asProject: { - operatorByOperatorId: { - legalName: "Test Legal Name PREVIOUS", - bcRegistryId: "Test BC Registry ID", - }, - fundingStreamRfpByFundingStreamRfpId: { - year: 2020, - fundingStreamByFundingStreamId: { - description: "Test Funding Stream Description", - }, - }, - projectStatusByProjectStatusId: { - name: "Test Project Status Name", + fundingStreamRfpByFundingStreamRfpId: { + year: 2020, + fundingStreamByFundingStreamId: { + description: "Test Funding Stream Description", }, }, + projectStatusByProjectStatusId: { + name: "Test Project Status Name", + }, }, }, - ], - }, + }, + ], }, }; return result; From e4e9552a0e93c99facf5bf635ab56d5f72e8284e Mon Sep 17 00:00:00 2001 From: Mike Vesprini Date: Tue, 14 May 2024 19:54:54 -0700 Subject: [PATCH 09/33] chore: switch contact summary form to use latest committed data only for diffs --- .../Form/ProjectContactFormSummary.tsx | 8 -- .../Form/ProjectContactFormSummary.test.tsx | 74 +++++++++++-------- 2 files changed, 42 insertions(+), 40 deletions(-) diff --git a/app/components/Form/ProjectContactFormSummary.tsx b/app/components/Form/ProjectContactFormSummary.tsx index eb57d53d05..1c728e3493 100644 --- a/app/components/Form/ProjectContactFormSummary.tsx +++ b/app/components/Form/ProjectContactFormSummary.tsx @@ -48,14 +48,6 @@ const ProjectContactFormSummary: React.FC = ({ ...ContactDetails_contact } } - formChangeByPreviousFormChangeId { - newFormData - asProjectContact { - contactByContactId { - fullName - } - } - } formByJsonSchemaName { jsonSchema } diff --git a/app/tests/unit/components/Form/ProjectContactFormSummary.test.tsx b/app/tests/unit/components/Form/ProjectContactFormSummary.test.tsx index 4d2760c6e7..0b27182eb0 100644 --- a/app/tests/unit/components/Form/ProjectContactFormSummary.test.tsx +++ b/app/tests/unit/components/Form/ProjectContactFormSummary.test.tsx @@ -39,18 +39,6 @@ const mockQueryPayload = { fullName: "Test Full Name primary", }, }, - formChangeByPreviousFormChangeId: { - newFormData: { - contactIndex: 1, - contactId: 1, - projectId: 1, - }, - asProjectContact: { - contactByContactId: { - fullName: "Test Full Name primary PREVIOUS", - }, - }, - }, formByJsonSchemaName: { jsonSchema: projectContactProdSchema, }, @@ -70,18 +58,6 @@ const mockQueryPayload = { fullName: "I did not change", }, }, - formChangeByPreviousFormChangeId: { - newFormData: { - contactIndex: 1, - contactId: 2, - projectId: 1, - }, - asProjectContact: { - contactByContactId: { - fullName: "I did not change", - }, - }, - }, formByJsonSchemaName: { jsonSchema: projectContactProdSchema, }, @@ -122,7 +98,44 @@ const mockQueryPayload = { }, }, operation: "ARCHIVE", - formChangeByPreviousFormChangeId: { + formByJsonSchemaName: { + jsonSchema: projectContactProdSchema, + }, + }, + }, + ], + latestCommittedProjectContactFormChanges: { + edges: [ + { + node: { + newFormData: { + contactIndex: 1, + contactId: 1, + projectId: 1, + }, + asProjectContact: { + contactByContactId: { + fullName: "Test Full Name primary PREVIOUS", + }, + }, + } + }, + { + node: { + newFormData: { + contactIndex: 1, + contactId: 2, + projectId: 1, + }, + asProjectContact: { + contactByContactId: { + fullName: "I did not change", + }, + }, + } + }, + { + node: { newFormData: { contactIndex: 4, contactId: 4, @@ -133,13 +146,10 @@ const mockQueryPayload = { fullName: "I was removed", }, }, - }, - formByJsonSchemaName: { - jsonSchema: projectContactProdSchema, - }, - }, - }, - ], + } + } + ] + } }, }; return result; From ff88327fe8f6be0ddbc775f10b83d57ba3748333 Mon Sep 17 00:00:00 2001 From: Mike Vesprini Date: Tue, 14 May 2024 22:00:19 -0700 Subject: [PATCH 10/33] test: update manager and contact form summary tests to use latest committed data --- .../Form/ProjectContactFormSummary.test.tsx | 86 +++++++++---------- .../Form/ProjectManagerFormSummary.test.tsx | 83 ++++++++++-------- 2 files changed, 90 insertions(+), 79 deletions(-) diff --git a/app/tests/unit/components/Form/ProjectContactFormSummary.test.tsx b/app/tests/unit/components/Form/ProjectContactFormSummary.test.tsx index 0b27182eb0..0f518fcd88 100644 --- a/app/tests/unit/components/Form/ProjectContactFormSummary.test.tsx +++ b/app/tests/unit/components/Form/ProjectContactFormSummary.test.tsx @@ -104,53 +104,53 @@ const mockQueryPayload = { }, }, ], - latestCommittedProjectContactFormChanges: { - edges: [ - { - node: { - newFormData: { - contactIndex: 1, - contactId: 1, - projectId: 1, - }, - asProjectContact: { - contactByContactId: { - fullName: "Test Full Name primary PREVIOUS", - }, - }, - } - }, - { - node: { - newFormData: { - contactIndex: 1, - contactId: 2, - projectId: 1, - }, - asProjectContact: { - contactByContactId: { - fullName: "I did not change", - }, + }, + latestCommittedProjectContactFormChanges: { + edges: [ + { + node: { + newFormData: { + contactIndex: 1, + contactId: 1, + projectId: 1, + }, + asProjectContact: { + contactByContactId: { + fullName: "Test Full Name primary PREVIOUS", }, - } - }, - { - node: { - newFormData: { - contactIndex: 4, - contactId: 4, - projectId: 1, + }, + } + }, + { + node: { + newFormData: { + contactIndex: 1, + contactId: 2, + projectId: 1, + }, + asProjectContact: { + contactByContactId: { + fullName: "I did not change", }, - asProjectContact: { - contactByContactId: { - fullName: "I was removed", - }, + }, + } + }, + { + node: { + newFormData: { + contactIndex: 4, + contactId: 4, + projectId: 1, + }, + asProjectContact: { + contactByContactId: { + fullName: "I was removed", }, - } + }, } - ] - } - }, + } + ] + } }; return result; }, diff --git a/app/tests/unit/components/Form/ProjectManagerFormSummary.test.tsx b/app/tests/unit/components/Form/ProjectManagerFormSummary.test.tsx index 18f8d09dab..195277cd20 100644 --- a/app/tests/unit/components/Form/ProjectManagerFormSummary.test.tsx +++ b/app/tests/unit/components/Form/ProjectManagerFormSummary.test.tsx @@ -42,18 +42,6 @@ const mockQueryPayload = { fullName: "Test Full Name Update", }, }, - formChangeByPreviousFormChangeId: { - newFormData: { - projectId: 1, - cifUserId: 1, - projectManagerLabelId: 1, - }, - asProjectManager: { - cifUserByCifUserId: { - fullName: "Test Full Name Update PREVIOUS", - }, - }, - }, }, projectManagerLabel: { label: "Test First Label", @@ -75,18 +63,6 @@ const mockQueryPayload = { fullName: "Test Full Name Archive", }, }, - formChangeByPreviousFormChangeId: { - newFormData: { - projectId: 1, - cifUserId: 1, - projectManagerLabelId: 1, - }, - asProjectManager: { - cifUserByCifUserId: { - fullName: "Test Full Name Archive PREVIOUS", - }, - }, - }, }, projectManagerLabel: { label: "Test Second Label", @@ -130,18 +106,6 @@ const mockQueryPayload = { fullName: "Test Full Name No Change", }, }, - formChangeByPreviousFormChangeId: { - newFormData: { - projectId: 1, - cifUserId: 4, - projectManagerLabelId: 4, - }, - asProjectManager: { - cifUserByCifUserId: { - fullName: "Test Full Name No Change", - }, - }, - }, }, projectManagerLabel: { label: "Test Fourth Label", @@ -150,6 +114,52 @@ const mockQueryPayload = { }, ], }, + latestCommittedProjectManagerFormChanges: { + edges: [ + { + node: { + newFormData: { + projectId: 1, + cifUserId: 1, + projectManagerLabelId: 1, + }, + asProjectManager: { + cifUserByCifUserId: { + fullName: "Test Full Name Update PREVIOUS", + }, + }, + } + }, + { + node: { + newFormData: { + projectId: 1, + cifUserId: 1, + projectManagerLabelId: 1, + }, + asProjectManager: { + cifUserByCifUserId: { + fullName: "Test Full Name Archive PREVIOUS", + }, + }, + } + }, + { + node: { + newFormData: { + projectId: 1, + cifUserId: 4, + projectManagerLabelId: 4, + }, + asProjectManager: { + cifUserByCifUserId: { + fullName: "Test Full Name No Change", + }, + }, + } + } + ] + }, }, }; }, @@ -197,6 +207,7 @@ describe("The ProjectManagerForm", () => { it("Only displays diffs of the the data fields that have changed", () => { componentTestingHelper.loadQuery(); componentTestingHelper.renderComponent(); + screen.logTestingPlaygroundURL(); expect(screen.getByText("Test Full Name Update")).toBeInTheDocument(); expect( From 333cc25a47575ef4b074568ebab16136a0a67c94 Mon Sep 17 00:00:00 2001 From: Mike Vesprini Date: Wed, 15 May 2024 10:14:29 -0700 Subject: [PATCH 11/33] test: update manager form summary tests --- .../unit/components/Form/ProjectManagerFormSummary.test.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/app/tests/unit/components/Form/ProjectManagerFormSummary.test.tsx b/app/tests/unit/components/Form/ProjectManagerFormSummary.test.tsx index 195277cd20..07bf5cecd4 100644 --- a/app/tests/unit/components/Form/ProjectManagerFormSummary.test.tsx +++ b/app/tests/unit/components/Form/ProjectManagerFormSummary.test.tsx @@ -207,7 +207,6 @@ describe("The ProjectManagerForm", () => { it("Only displays diffs of the the data fields that have changed", () => { componentTestingHelper.loadQuery(); componentTestingHelper.renderComponent(); - screen.logTestingPlaygroundURL(); expect(screen.getByText("Test Full Name Update")).toBeInTheDocument(); expect( From c148a659ddc0685f2301a6e5d6fccf46f87ded0a Mon Sep 17 00:00:00 2001 From: Mike Vesprini Date: Wed, 15 May 2024 21:55:28 -0700 Subject: [PATCH 12/33] chore: cleanup unused fields --- .../unit/components/Form/ProjectContactFormSummary.test.tsx | 1 - .../unit/components/Form/ProjectManagerFormSummary.test.tsx | 1 - 2 files changed, 2 deletions(-) diff --git a/app/tests/unit/components/Form/ProjectContactFormSummary.test.tsx b/app/tests/unit/components/Form/ProjectContactFormSummary.test.tsx index 0f518fcd88..c7764eac5f 100644 --- a/app/tests/unit/components/Form/ProjectContactFormSummary.test.tsx +++ b/app/tests/unit/components/Form/ProjectContactFormSummary.test.tsx @@ -77,7 +77,6 @@ const mockQueryPayload = { fullName: "I was added", }, }, - formChangeByPreviousFormChangeId: null, formByJsonSchemaName: { jsonSchema: projectContactProdSchema, }, diff --git a/app/tests/unit/components/Form/ProjectManagerFormSummary.test.tsx b/app/tests/unit/components/Form/ProjectManagerFormSummary.test.tsx index 07bf5cecd4..098fd26552 100644 --- a/app/tests/unit/components/Form/ProjectManagerFormSummary.test.tsx +++ b/app/tests/unit/components/Form/ProjectManagerFormSummary.test.tsx @@ -84,7 +84,6 @@ const mockQueryPayload = { fullName: "Test Full Name Create", }, }, - formChangeByPreviousFormChangeId: null, }, projectManagerLabel: { label: "Test Third Label", From 0e9b4015c2fb3b0011272de83528142a996b10a1 Mon Sep 17 00:00:00 2001 From: Mike Vesprini Date: Wed, 15 May 2024 22:42:24 -0700 Subject: [PATCH 13/33] chore: update getFilteredSchema to require latest committed form change --- app/lib/theme/schemaFilteringHelpers.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/lib/theme/schemaFilteringHelpers.ts b/app/lib/theme/schemaFilteringHelpers.ts index 5c3c8b4002..e28a4a9259 100644 --- a/app/lib/theme/schemaFilteringHelpers.ts +++ b/app/lib/theme/schemaFilteringHelpers.ts @@ -46,18 +46,17 @@ export const getSchemaAndDataIncludingCalculatedValues = ( }; // `getFilteredSchema` can only be used when all form values are found in `newFormData` (most of the time, calculated values are queried outside of `newFormData`, so in forms with calculated values, use `getSchemaAndDataIncludingCalculatedValues` instead) -export const getFilteredSchema = (formSchema: JSONSchema7, formChange) => { +export const getFilteredSchema = (formSchema: JSONSchema7, formChange, latestCommittedFormChange) => { const filteredSchema = JSON.parse(JSON.stringify(formSchema)); const newDataObject = {}; for (const key of Object.keys(filteredSchema.properties)) { if ( formChange?.newFormData?.[key] === - formChange?.formChangeByPreviousFormChangeId?.newFormData?.[key] + latestCommittedFormChange?.newFormData?.[key] ) delete filteredSchema.properties[key]; else newDataObject[key] = formChange.newFormData?.[key]; } - return { formSchema: filteredSchema, formData: newDataObject }; }; From d55c60759b08694fc720979010f4f9f4d6767496 Mon Sep 17 00:00:00 2001 From: Mike Vesprini Date: Wed, 15 May 2024 22:43:06 -0700 Subject: [PATCH 14/33] chore: use latest committed form data with getFilteredSchema in annual report summary --- .../Form/ProjectAnnualReportFormSummary.tsx | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/app/components/Form/ProjectAnnualReportFormSummary.tsx b/app/components/Form/ProjectAnnualReportFormSummary.tsx index 438c9e96fb..45711c5a8c 100644 --- a/app/components/Form/ProjectAnnualReportFormSummary.tsx +++ b/app/components/Form/ProjectAnnualReportFormSummary.tsx @@ -90,6 +90,15 @@ const ProjectAnnualReportFormSummary: React.FC = ({ return [filteredReports]; }, [annualReportFormChanges]); + let latestCommittedReports = latestCommittedAnnualReportFormChanges.edges; + const latestCommittedReportMap = useMemo(() => { + const filteredReports = latestCommittedReports.map(({ node }) => node); + + const reportMap = filteredReports.reduce((reports, current) => (reports[current.newFormData.reportingRequirementIndex] = current, reports),{}) + + return reportMap; + }, [latestCommittedReports]); + const allFormChangesPristine = useMemo( () => !annualReportFormChanges.some( @@ -109,7 +118,8 @@ const ProjectAnnualReportFormSummary: React.FC = ({ } : getFilteredSchema( annualReport.formByJsonSchemaName.jsonSchema.schema as JSONSchema7, - annualReport + annualReport, + latestCommittedReportMap[annualReport.newFormData.reportingRequirementIndex] ); if ( From 5d58192a52ccb69158b3460827a6322e82e367d2 Mon Sep 17 00:00:00 2001 From: Mike Vesprini Date: Wed, 15 May 2024 22:52:57 -0700 Subject: [PATCH 15/33] test: use latest committed data for annual report summary tests --- .../ProjectAnnualReportFormSummary.test.tsx | 60 ++++++++++--------- 1 file changed, 32 insertions(+), 28 deletions(-) diff --git a/app/tests/unit/components/Form/ProjectAnnualReportFormSummary.test.tsx b/app/tests/unit/components/Form/ProjectAnnualReportFormSummary.test.tsx index 4ff6adadad..6b141983d6 100644 --- a/app/tests/unit/components/Form/ProjectAnnualReportFormSummary.test.tsx +++ b/app/tests/unit/components/Form/ProjectAnnualReportFormSummary.test.tsx @@ -41,18 +41,6 @@ const mockQueryPayload = { }, operation: "UPDATE", changeStatus: "committed", - formChangeByPreviousFormChangeId: { - changeStatus: "committed", - newFormData: { - status: "on_track", - comments: "I am the old comment on Annual Report #1", - projectId: 1, - reportType: "Annual", - reportDueDate: "2025-06-18T23:59:59.999-07:00", - submittedDate: "2025-07-01T23:59:59.999-07:00", - reportingRequirementIndex: 1, - }, - }, formByJsonSchemaName: { jsonSchema: reportingRequirementProdSchema, }, @@ -76,20 +64,6 @@ const mockQueryPayload = { }, operation: "UPDATE", changeStatus: "committed", - formChangeByPreviousFormChangeId: { - changeStatus: "committed", - newFormData: { - status: "on_track", - comments: "I am an unchanged comment on Annual Report #2", - projectId: 1, - reportType: "Annual", - reportDueDate: - "I am an unchanged due date on Annual Report #2", - submittedDate: - "I am an unchanged received date on Annual Report #2", - reportingRequirementIndex: 2, - }, - }, formByJsonSchemaName: { jsonSchema: reportingRequirementProdSchema, }, @@ -111,7 +85,6 @@ const mockQueryPayload = { }, operation: "UPDATE", changeStatus: "committed", - formChangeByPreviousFormChangeId: null, formByJsonSchemaName: { jsonSchema: reportingRequirementProdSchema, }, @@ -133,7 +106,6 @@ const mockQueryPayload = { }, operation: "ARCHIVE", changeStatus: "committed", - formChangeByPreviousFormChangeId: null, formByJsonSchemaName: { jsonSchema: reportingRequirementProdSchema, }, @@ -141,6 +113,38 @@ const mockQueryPayload = { }, ], }, + latestCommittedAnnualReportFormChanges: { + edges: [ + { + node: { + newFormData: { + status: "on_track", + comments: "I am the old comment on Annual Report #1", + projectId: 1, + reportType: "Annual", + reportDueDate: "2025-06-18T23:59:59.999-07:00", + submittedDate: "2025-07-01T23:59:59.999-07:00", + reportingRequirementIndex: 1, + }, + } + }, + { + node: { + newFormData: { + status: "on_track", + comments: "I am an unchanged comment on Annual Report #2", + projectId: 1, + reportType: "Annual", + reportDueDate: + "I am an unchanged due date on Annual Report #2", + submittedDate: + "I am an unchanged received date on Annual Report #2", + reportingRequirementIndex: 2, + }, + } + }, + ] + } }; return result; }, From c8b8790df0d45fb1ac8d8763ec2683c96d9e181e Mon Sep 17 00:00:00 2001 From: Mike Vesprini Date: Wed, 15 May 2024 22:56:43 -0700 Subject: [PATCH 16/33] chore: pre-commit run --- .../Form/ProjectAnnualReportFormSummary.tsx | 12 ++++++++++-- app/lib/theme/schemaFilteringHelpers.ts | 6 +++++- .../Form/ProjectAnnualReportFormSummary.test.tsx | 8 ++++---- .../Form/ProjectContactFormSummary.test.tsx | 12 ++++++------ .../Form/ProjectManagerFormSummary.test.tsx | 10 +++++----- 5 files changed, 30 insertions(+), 18 deletions(-) diff --git a/app/components/Form/ProjectAnnualReportFormSummary.tsx b/app/components/Form/ProjectAnnualReportFormSummary.tsx index 45711c5a8c..ab60b6df4a 100644 --- a/app/components/Form/ProjectAnnualReportFormSummary.tsx +++ b/app/components/Form/ProjectAnnualReportFormSummary.tsx @@ -94,7 +94,13 @@ const ProjectAnnualReportFormSummary: React.FC = ({ const latestCommittedReportMap = useMemo(() => { const filteredReports = latestCommittedReports.map(({ node }) => node); - const reportMap = filteredReports.reduce((reports, current) => (reports[current.newFormData.reportingRequirementIndex] = current, reports),{}) + const reportMap = filteredReports.reduce( + (reports, current) => ( + (reports[current.newFormData.reportingRequirementIndex] = current), + reports + ), + {} + ); return reportMap; }, [latestCommittedReports]); @@ -119,7 +125,9 @@ const ProjectAnnualReportFormSummary: React.FC = ({ : getFilteredSchema( annualReport.formByJsonSchemaName.jsonSchema.schema as JSONSchema7, annualReport, - latestCommittedReportMap[annualReport.newFormData.reportingRequirementIndex] + latestCommittedReportMap[ + annualReport.newFormData.reportingRequirementIndex + ] ); if ( diff --git a/app/lib/theme/schemaFilteringHelpers.ts b/app/lib/theme/schemaFilteringHelpers.ts index e28a4a9259..d11ce87b6e 100644 --- a/app/lib/theme/schemaFilteringHelpers.ts +++ b/app/lib/theme/schemaFilteringHelpers.ts @@ -46,7 +46,11 @@ export const getSchemaAndDataIncludingCalculatedValues = ( }; // `getFilteredSchema` can only be used when all form values are found in `newFormData` (most of the time, calculated values are queried outside of `newFormData`, so in forms with calculated values, use `getSchemaAndDataIncludingCalculatedValues` instead) -export const getFilteredSchema = (formSchema: JSONSchema7, formChange, latestCommittedFormChange) => { +export const getFilteredSchema = ( + formSchema: JSONSchema7, + formChange, + latestCommittedFormChange +) => { const filteredSchema = JSON.parse(JSON.stringify(formSchema)); const newDataObject = {}; diff --git a/app/tests/unit/components/Form/ProjectAnnualReportFormSummary.test.tsx b/app/tests/unit/components/Form/ProjectAnnualReportFormSummary.test.tsx index 6b141983d6..069299f001 100644 --- a/app/tests/unit/components/Form/ProjectAnnualReportFormSummary.test.tsx +++ b/app/tests/unit/components/Form/ProjectAnnualReportFormSummary.test.tsx @@ -126,7 +126,7 @@ const mockQueryPayload = { submittedDate: "2025-07-01T23:59:59.999-07:00", reportingRequirementIndex: 1, }, - } + }, }, { node: { @@ -141,10 +141,10 @@ const mockQueryPayload = { "I am an unchanged received date on Annual Report #2", reportingRequirementIndex: 2, }, - } + }, }, - ] - } + ], + }, }; return result; }, diff --git a/app/tests/unit/components/Form/ProjectContactFormSummary.test.tsx b/app/tests/unit/components/Form/ProjectContactFormSummary.test.tsx index c7764eac5f..a66bee449e 100644 --- a/app/tests/unit/components/Form/ProjectContactFormSummary.test.tsx +++ b/app/tests/unit/components/Form/ProjectContactFormSummary.test.tsx @@ -118,7 +118,7 @@ const mockQueryPayload = { fullName: "Test Full Name primary PREVIOUS", }, }, - } + }, }, { node: { @@ -132,7 +132,7 @@ const mockQueryPayload = { fullName: "I did not change", }, }, - } + }, }, { node: { @@ -146,10 +146,10 @@ const mockQueryPayload = { fullName: "I was removed", }, }, - } - } - ] - } + }, + }, + ], + }, }; return result; }, diff --git a/app/tests/unit/components/Form/ProjectManagerFormSummary.test.tsx b/app/tests/unit/components/Form/ProjectManagerFormSummary.test.tsx index 098fd26552..d28fb44a34 100644 --- a/app/tests/unit/components/Form/ProjectManagerFormSummary.test.tsx +++ b/app/tests/unit/components/Form/ProjectManagerFormSummary.test.tsx @@ -127,7 +127,7 @@ const mockQueryPayload = { fullName: "Test Full Name Update PREVIOUS", }, }, - } + }, }, { node: { @@ -141,7 +141,7 @@ const mockQueryPayload = { fullName: "Test Full Name Archive PREVIOUS", }, }, - } + }, }, { node: { @@ -155,9 +155,9 @@ const mockQueryPayload = { fullName: "Test Full Name No Change", }, }, - } - } - ] + }, + }, + ], }, }, }; From f50cb73070ca93c8c828919d1970928b5a9e3ce1 Mon Sep 17 00:00:00 2001 From: Mike Vesprini Date: Thu, 16 May 2024 15:12:19 -0700 Subject: [PATCH 17/33] chore: fix incomplete reference in annual report form summary --- .../Form/ProjectAnnualReportFormSummary.tsx | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/app/components/Form/ProjectAnnualReportFormSummary.tsx b/app/components/Form/ProjectAnnualReportFormSummary.tsx index ab60b6df4a..4e7b54c428 100644 --- a/app/components/Form/ProjectAnnualReportFormSummary.tsx +++ b/app/components/Form/ProjectAnnualReportFormSummary.tsx @@ -115,6 +115,7 @@ const ProjectAnnualReportFormSummary: React.FC = ({ const annualReportsJSX = useMemo(() => { return sortedAnnualReports.map((annualReport, index) => { + const latestCommittedData = latestCommittedReportMap[annualReport.newFormData.reportingRequirementIndex] if (!annualReport) return; // Set the formSchema and formData based on showing the diff or not const { formSchema, formData } = !renderDiff @@ -125,9 +126,7 @@ const ProjectAnnualReportFormSummary: React.FC = ({ : getFilteredSchema( annualReport.formByJsonSchemaName.jsonSchema.schema as JSONSchema7, annualReport, - latestCommittedReportMap[ - annualReport.newFormData.reportingRequirementIndex - ] + latestCommittedData ); if ( @@ -137,13 +136,6 @@ const ProjectAnnualReportFormSummary: React.FC = ({ ) return null; - const latestCommittedData = - latestCommittedAnnualReportFormChanges?.edges?.find( - ({ node }) => - node.newFormData.reportingRequirementIndex === - annualReport.newFormData.reportingRequirementIndex - )?.node?.newFormData; - return (
@@ -177,7 +169,7 @@ const ProjectAnnualReportFormSummary: React.FC = ({ uiSchema={reportingRequirementUiSchema} formContext={{ operation: annualReport.operation, - latestCommittedData, + latestCommittedData: latestCommittedData?.newFormData, isAmendmentsAndOtherRevisionsSpecific: isOnAmendmentsAndOtherRevisionsPage, }} @@ -196,6 +188,7 @@ const ProjectAnnualReportFormSummary: React.FC = ({ isOnAmendmentsAndOtherRevisionsPage, renderDiff, sortedAnnualReports, + latestCommittedReportMap ]); // Update the hasDiff state in the CollapsibleFormWidget to define if the form has diffs to show From 3aadc2a81850fb58924274922945198319ce8427 Mon Sep 17 00:00:00 2001 From: Mike Vesprini Date: Thu, 16 May 2024 21:49:51 -0700 Subject: [PATCH 18/33] chore: pass latest committed data to getFilteredSchema in quarterly report summary --- .../Form/ProjectQuarterlyReportFormSummary.tsx | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/app/components/Form/ProjectQuarterlyReportFormSummary.tsx b/app/components/Form/ProjectQuarterlyReportFormSummary.tsx index c446beb80e..233f89fa06 100644 --- a/app/components/Form/ProjectQuarterlyReportFormSummary.tsx +++ b/app/components/Form/ProjectQuarterlyReportFormSummary.tsx @@ -94,6 +94,21 @@ const ProjectQuarterlyReportFormSummary: React.FC = ({ return [filteredReports]; }, [quarterlyReportFormChanges]); + let latestCommittedReports = latestCommittedProjectQuarterlyReportFormChanges.edges; + const latestCommittedReportMap = useMemo(() => { + const filteredReports = latestCommittedReports.map(({ node }) => node); + + const reportMap = filteredReports.reduce( + (reports, current) => ( + (reports[current.newFormData.reportingRequirementIndex] = current), + reports + ), + {} + ); + + return reportMap; + }, [latestCommittedReports]); + // Defines if all quarterly reports are pristine const allFormChangesPristine = useMemo( () => @@ -116,7 +131,8 @@ const ProjectQuarterlyReportFormSummary: React.FC = ({ : getFilteredSchema( quarterlyReport.formByJsonSchemaName.jsonSchema .schema as JSONSchema7, - quarterlyReport + quarterlyReport, + latestCommittedReportMap[quarterlyReport.newFormData.reportingRequirementIndex] ); if ( From 5f9c67fab531ea0a17dbf6feafc5f40d331aabd5 Mon Sep 17 00:00:00 2001 From: Mike Vesprini Date: Thu, 16 May 2024 21:54:40 -0700 Subject: [PATCH 19/33] test: use latest committed form data in quarterly summary test --- ...ProjectQuarterlyReportFormSummary.test.tsx | 80 +++++++++++-------- 1 file changed, 46 insertions(+), 34 deletions(-) diff --git a/app/tests/unit/components/Form/ProjectQuarterlyReportFormSummary.test.tsx b/app/tests/unit/components/Form/ProjectQuarterlyReportFormSummary.test.tsx index 307faaa95b..24e7e6c53a 100644 --- a/app/tests/unit/components/Form/ProjectQuarterlyReportFormSummary.test.tsx +++ b/app/tests/unit/components/Form/ProjectQuarterlyReportFormSummary.test.tsx @@ -36,14 +36,6 @@ const mockQueryPayload = { reportingRequirementIndex: 1, }, operation: "UPDATE", - formChangeByPreviousFormChangeId: { - newFormData: { - comments: "Test comment", - projectId: 1, - reportDueDate: "2020-01-01T23:59:59.999-07:00", - reportingRequirementIndex: 1, - }, - }, formByJsonSchemaName: { jsonSchema: reportingRequirementProdSchema, }, @@ -57,17 +49,25 @@ const mockQueryPayload = { comments: "Not updated comment", projectId: 1, reportDueDate: "2020-01-03T23:59:59.999-07:00", - reportingRequirementIndex: 1, + reportingRequirementIndex: 2, }, operation: "UPDATE", - formChangeByPreviousFormChangeId: { - newFormData: { - comments: "Not updated comment", - projectId: 1, - reportDueDate: "2020-01-03T23:59:59.999-07:00", - reportingRequirementIndex: 1, - }, + formByJsonSchemaName: { + jsonSchema: reportingRequirementProdSchema, }, + }, + }, + { + node: { + id: "Test ID - 4", + isPristine: false, + newFormData: { + comments: "Removed comment", + projectId: 1, + reportDueDate: "2020-01-05T23:59:59.999-07:00", + reportingRequirementIndex: 3, + }, + operation: "ARCHIVE", formByJsonSchemaName: { jsonSchema: reportingRequirementProdSchema, }, @@ -81,41 +81,53 @@ const mockQueryPayload = { comments: "Added comment", projectId: 1, reportDueDate: "2020-01-04T23:59:59.999-07:00", - reportingRequirementIndex: 1, + reportingRequirementIndex: 4, }, operation: "CREATE", - formChangeByPreviousFormChangeId: null, formByJsonSchemaName: { jsonSchema: reportingRequirementProdSchema, }, }, }, + ], + }, + latestCommittedProjectQuarterlyReportFormChanges: { + edges: [ { node: { - id: "Test ID - 4", - isPristine: false, + id: "Test ID 5", newFormData: { - comments: "Removed comment", + comments: "Test comment", projectId: 1, - reportDueDate: "2020-01-05T23:59:59.999-07:00", + reportDueDate: "2020-01-01T23:59:59.999-07:00", reportingRequirementIndex: 1, }, - operation: "ARCHIVE", - formChangeByPreviousFormChangeId: { - newFormData: { - comments: "Removed comment", - projectId: 1, - reportDueDate: "2020-01-05T23:59:59.999-07:00", - reportingRequirementIndex: 1, - }, + }, + }, + { + node: { + id: "Test ID 6", + newFormData: { + comments: "Not updated comment", + projectId: 1, + reportDueDate: "2020-01-03T23:59:59.999-07:00", + reportingRequirementIndex: 2, }, - formByJsonSchemaName: { - jsonSchema: reportingRequirementProdSchema, + }, + }, + { + node: { + id: "Test ID 7", + newFormData: { + comments: "Removed comment", + projectId: 1, + reportDueDate: "2020-01-05T23:59:59.999-07:00", + reportingRequirementIndex: 3, }, }, }, - ], - }, + ] + } }; return result; }, From daff5a2cf3c84a63ed436bd2a0a3891f5648d2b9 Mon Sep 17 00:00:00 2001 From: Mike Vesprini Date: Thu, 16 May 2024 21:56:53 -0700 Subject: [PATCH 20/33] chore: precommit run --- .../Form/ProjectAnnualReportFormSummary.tsx | 7 +++++-- .../Form/ProjectQuarterlyReportFormSummary.tsx | 7 +++++-- .../Form/ProjectAnnualReportFormSummary.test.tsx | 13 +++++++++++++ .../Form/ProjectQuarterlyReportFormSummary.test.tsx | 4 ++-- 4 files changed, 25 insertions(+), 6 deletions(-) diff --git a/app/components/Form/ProjectAnnualReportFormSummary.tsx b/app/components/Form/ProjectAnnualReportFormSummary.tsx index 4e7b54c428..7b84285571 100644 --- a/app/components/Form/ProjectAnnualReportFormSummary.tsx +++ b/app/components/Form/ProjectAnnualReportFormSummary.tsx @@ -115,7 +115,10 @@ const ProjectAnnualReportFormSummary: React.FC = ({ const annualReportsJSX = useMemo(() => { return sortedAnnualReports.map((annualReport, index) => { - const latestCommittedData = latestCommittedReportMap[annualReport.newFormData.reportingRequirementIndex] + const latestCommittedData = + latestCommittedReportMap[ + annualReport.newFormData.reportingRequirementIndex + ]; if (!annualReport) return; // Set the formSchema and formData based on showing the diff or not const { formSchema, formData } = !renderDiff @@ -188,7 +191,7 @@ const ProjectAnnualReportFormSummary: React.FC = ({ isOnAmendmentsAndOtherRevisionsPage, renderDiff, sortedAnnualReports, - latestCommittedReportMap + latestCommittedReportMap, ]); // Update the hasDiff state in the CollapsibleFormWidget to define if the form has diffs to show diff --git a/app/components/Form/ProjectQuarterlyReportFormSummary.tsx b/app/components/Form/ProjectQuarterlyReportFormSummary.tsx index 233f89fa06..05108a6fbc 100644 --- a/app/components/Form/ProjectQuarterlyReportFormSummary.tsx +++ b/app/components/Form/ProjectQuarterlyReportFormSummary.tsx @@ -94,7 +94,8 @@ const ProjectQuarterlyReportFormSummary: React.FC = ({ return [filteredReports]; }, [quarterlyReportFormChanges]); - let latestCommittedReports = latestCommittedProjectQuarterlyReportFormChanges.edges; + let latestCommittedReports = + latestCommittedProjectQuarterlyReportFormChanges.edges; const latestCommittedReportMap = useMemo(() => { const filteredReports = latestCommittedReports.map(({ node }) => node); @@ -132,7 +133,9 @@ const ProjectQuarterlyReportFormSummary: React.FC = ({ quarterlyReport.formByJsonSchemaName.jsonSchema .schema as JSONSchema7, quarterlyReport, - latestCommittedReportMap[quarterlyReport.newFormData.reportingRequirementIndex] + latestCommittedReportMap[ + quarterlyReport.newFormData.reportingRequirementIndex + ] ); if ( diff --git a/app/tests/unit/components/Form/ProjectAnnualReportFormSummary.test.tsx b/app/tests/unit/components/Form/ProjectAnnualReportFormSummary.test.tsx index 069299f001..981c6e0c59 100644 --- a/app/tests/unit/components/Form/ProjectAnnualReportFormSummary.test.tsx +++ b/app/tests/unit/components/Form/ProjectAnnualReportFormSummary.test.tsx @@ -143,6 +143,19 @@ const mockQueryPayload = { }, }, }, + { + node: { + newFormData: { + status: "on_track", + comments: "I have been deleted", + projectId: 1, + reportType: "Annual", + reportDueDate: "2022-06-03T23:59:59.999-07:00", + submittedDate: "2022-06-24T23:59:59.999-07:00", + reportingRequirementIndex: 4, + }, + }, + }, ], }, }; diff --git a/app/tests/unit/components/Form/ProjectQuarterlyReportFormSummary.test.tsx b/app/tests/unit/components/Form/ProjectQuarterlyReportFormSummary.test.tsx index 24e7e6c53a..c0d9eadf5d 100644 --- a/app/tests/unit/components/Form/ProjectQuarterlyReportFormSummary.test.tsx +++ b/app/tests/unit/components/Form/ProjectQuarterlyReportFormSummary.test.tsx @@ -126,8 +126,8 @@ const mockQueryPayload = { }, }, }, - ] - } + ], + }, }; return result; }, From 5c44705f3797539249345064255f2e6e5cc4ac70 Mon Sep 17 00:00:00 2001 From: Mike Vesprini Date: Thu, 16 May 2024 22:12:29 -0700 Subject: [PATCH 21/33] chore: add latest committed data to getFilteredSchema call in ProjectSummaryReportFormSummary --- app/components/Form/ProjectSummaryReportFormSummary.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/components/Form/ProjectSummaryReportFormSummary.tsx b/app/components/Form/ProjectSummaryReportFormSummary.tsx index 56f7c2778d..63868e5496 100644 --- a/app/components/Form/ProjectSummaryReportFormSummary.tsx +++ b/app/components/Form/ProjectSummaryReportFormSummary.tsx @@ -88,7 +88,8 @@ const ProjectSummaryReportFormSummary: React.FC = ({ const filteredSchema = getFilteredSchema( projectSummaryReportFormBySlug.jsonSchema.schema as JSONSchema7, - projectSummaryReport || {} + projectSummaryReport || {}, + latestCommittedProjectSummaryFormChanges?.edges[0]?.node ); const allFormChangesPristine = useMemo( From 75e45b03d9d6a2ccfbefc2c44e58d2739b500566 Mon Sep 17 00:00:00 2001 From: Mike Vesprini Date: Sun, 19 May 2024 13:33:12 -0700 Subject: [PATCH 22/33] test: use latest committed data in quarterly summary test --- ...rojectFundingAgreementFormSummary.test.tsx | 90 ++++++------------- .../Form/ProjectQuarterlyReportForm.test.tsx | 2 - 2 files changed, 28 insertions(+), 64 deletions(-) diff --git a/app/tests/unit/components/Form/ProjectFundingAgreementFormSummary.test.tsx b/app/tests/unit/components/Form/ProjectFundingAgreementFormSummary.test.tsx index 17f09244eb..d022cce4b8 100644 --- a/app/tests/unit/components/Form/ProjectFundingAgreementFormSummary.test.tsx +++ b/app/tests/unit/components/Form/ProjectFundingAgreementFormSummary.test.tsx @@ -63,27 +63,6 @@ const mockQueryPayloadEP = { grossPaymentsToDate: "1.00", isPristine: false, operation: "UPDATE", - formChangeByPreviousFormChangeId: { - proponentsSharePercentage: 10, // will trigger three diffs - totalProjectValue: 12, // will trigger three diffs - newFormData: { - projectId: "Test Project ID", - maxFundingAmount: 200, - provinceSharePercentage: 50, - holdbackPercentage: 10.23, - anticipatedFundingAmount: 300, - proponentCost: 100, - contractStartDate: "2021-01-01T23:59:59.999-07:00", - projectAssetsLifeEndDate: "2021-12-31T23:59:59.999-07:00", - additionalFundingSources: [ - { - source: "Test Source Name", - amount: 1000, - status: "Awaiting Approval", - }, - ], - }, - }, }, }, ], @@ -92,17 +71,25 @@ const mockQueryPayloadEP = { edges: [ { node: { - proponentsSharePercentage: 15, // will trigger three diffs - totalProjectValue: 18, // will trigger three diffs + proponentsSharePercentage: 10, // will trigger three diffs + totalProjectValue: 12, // will trigger three diffs newFormData: { - // add data as required + projectId: "Test Project ID", + maxFundingAmount: 200, + provinceSharePercentage: 50, + holdbackPercentage: 10.23, + anticipatedFundingAmount: 300, + proponentCost: 100, + contractStartDate: "2021-01-01T23:59:59.999-07:00", + projectAssetsLifeEndDate: "2021-12-31T23:59:59.999-07:00", + additionalFundingSources: [ + { + source: "Test Source Name", + amount: 1000, + status: "Awaiting Approval", + }, + ], }, - eligibleExpensesToDate: "1.00", - holdbackAmountToDate: "0.00", - netPaymentsToDate: "1.00", - grossPaymentsToDate: "1.00", - isPristine: false, - operation: "UPDATE", }, }, ], @@ -154,20 +141,6 @@ const mockQueryPayloadIA = { calculatedTotalPaymentAmountToDate: "511.0", isPristine: false, operation: "UPDATE", - formChangeByPreviousFormChangeId: { - proponentsSharePercentage: 14, // will trigger three diffs - totalProjectValue: 16, // will trigger three diffs - newFormData: { - projectId: "Test Project ID", - maxFundingAmount: 500, - provinceSharePercentage: 50, - anticipatedFundingAmount: 200, - proponentCost: 100, - contractStartDate: "2021-01-01T23:59:59.999-07:00", - projectAssetsLifeEndDate: - "2023-03-28T14:41:23.626132-07:00", - }, - }, }, }, ], @@ -176,12 +149,17 @@ const mockQueryPayloadIA = { edges: [ { node: { - proponentsSharePercentage: 21, // will trigger three diffs - totalProjectValue: 24, // will trigger three diffs - newFormData: {}, - calculatedTotalPaymentAmountToDate: "511.0", - isPristine: false, - operation: "UPDATE", + proponentsSharePercentage: 14, // will trigger three diffs + totalProjectValue: 16, // will trigger three diffs + newFormData: { + projectId: "Test Project ID", + maxFundingAmount: 500, + provinceSharePercentage: 50, + anticipatedFundingAmount: 200, + proponentCost: 100, + contractStartDate: "2021-01-01T23:59:59.999-07:00", + projectAssetsLifeEndDate: "2023-03-28T14:41:23.626132-07:00", + }, }, }, ], @@ -306,18 +284,12 @@ describe("The Project Funding Agreement Form Summary", () => { expect( screen.getByText("10.00 %", { selector: ".diffOld" }) ).toBeInTheDocument(); // old proponentsSharePercentage - expect( - screen.getByText("15.00 %", { selector: ".diffOld" }) - ).toBeInTheDocument(); // latest committed proponentsSharePercentage expect( screen.getByText("$6.00", { selector: ".diffNew" }) ).toBeInTheDocument(); // new totalProjectValue expect( screen.getByText("$12.00", { selector: ".diffOld" }) ).toBeInTheDocument(); // old totalProjectValue - expect( - screen.getByText("$18.00", { selector: ".diffOld" }) - ).toBeInTheDocument(); // latest committed totalProjectValue }); it("Displays diffs of the the data fields that have changed for an IA form", () => { @@ -340,9 +312,6 @@ describe("The Project Funding Agreement Form Summary", () => { expect( screen.getByText("14.00 %", { selector: ".diffOld" }) ).toBeInTheDocument(); - expect( - screen.getByText("21.00 %", { selector: ".diffOld" }) - ).toBeInTheDocument(); expect( screen.getByText("$8.00", { selector: ".diffNew" }) @@ -350,9 +319,6 @@ describe("The Project Funding Agreement Form Summary", () => { expect( screen.getByText("$16.00", { selector: ".diffOld" }) ).toBeInTheDocument(); - expect( - screen.getByText("$24.00", { selector: ".diffOld" }) - ).toBeInTheDocument(); }); it("Displays all data for an EP project when isFirstRevision is true (Project Creation)", () => { diff --git a/app/tests/unit/components/Form/ProjectQuarterlyReportForm.test.tsx b/app/tests/unit/components/Form/ProjectQuarterlyReportForm.test.tsx index 6a33c6160f..3d9aed9ddb 100644 --- a/app/tests/unit/components/Form/ProjectQuarterlyReportForm.test.tsx +++ b/app/tests/unit/components/Form/ProjectQuarterlyReportForm.test.tsx @@ -48,7 +48,6 @@ const defaultMockResolver = { }, operation: "CREATE", changeStatus: "pending", - formChangeByPreviousFormChangeId: null, formByJsonSchemaName: { jsonSchema: reportingRequirementProdSchema, }, @@ -68,7 +67,6 @@ const defaultMockResolver = { }, operation: "CREATE", changeStatus: "pending", - formChangeByPreviousFormChangeId: null, formByJsonSchemaName: { jsonSchema: reportingRequirementProdSchema, }, From 625f2c3f3391300c219f0c0381b06f751b569673 Mon Sep 17 00:00:00 2001 From: Mike Vesprini Date: Sun, 19 May 2024 13:47:04 -0700 Subject: [PATCH 23/33] test: use latest committed data in emission intensity summary --- ...jectEmissionIntensityReportFormSummary.tsx | 1 + ...missionIntensityReportFormSummary.test.tsx | 73 ++++++++++--------- 2 files changed, 39 insertions(+), 35 deletions(-) diff --git a/app/components/Form/ProjectEmissionIntensityReportFormSummary.tsx b/app/components/Form/ProjectEmissionIntensityReportFormSummary.tsx index b5819e2799..d2540a7e70 100644 --- a/app/components/Form/ProjectEmissionIntensityReportFormSummary.tsx +++ b/app/components/Form/ProjectEmissionIntensityReportFormSummary.tsx @@ -122,6 +122,7 @@ const ProjectEmissionsIntensityReportFormSummary: React.FC = ({ const filteredSchema = getSchemaAndDataIncludingCalculatedValues( emissionIntensityFormBySlug.jsonSchema.schema as JSONSchema7, newData, + latestCommittedData, { // This is only to add the (Adjusted) to the title of the field to differentiate it from the calculated field adjustedEmissionsIntensityPerformance: { diff --git a/app/tests/unit/components/Form/ProjectEmissionIntensityReportFormSummary.test.tsx b/app/tests/unit/components/Form/ProjectEmissionIntensityReportFormSummary.test.tsx index 62fae357e4..c55d9fb7b6 100644 --- a/app/tests/unit/components/Form/ProjectEmissionIntensityReportFormSummary.test.tsx +++ b/app/tests/unit/components/Form/ProjectEmissionIntensityReportFormSummary.test.tsx @@ -42,21 +42,27 @@ const defaultMockResolver = { baselineEmissionIntensity: 0.87654321, }, operation: "UPDATE", - formChangeByPreviousFormChangeId: { - newFormData: { - comments: "squirtle", - reportType: "TEIMP", - projectId: 1, - reportingRequirementIndex: 1, - reportingRequirementId: 1, - baselineEmissionIntensity: 0.985145, - }, - }, formDataRecordId: 1, }, }, ], }, + latestCommittedEmissionIntensityReportFormChange: { + edges: [ + { + node: { + newFormData: { + comments: "squirtle", + reportType: "TEIMP", + projectId: 1, + reportingRequirementIndex: 1, + reportingRequirementId: 1, + baselineEmissionIntensity: 0.985145, + }, + }, + }, + ], + }, }; }, }; @@ -195,13 +201,19 @@ describe("the emission intensity report form component", () => { targetEmissionIntensity: 0, }, operation: "UPDATE", - formChangeByPreviousFormChangeId: { - newFormData: { - baselineEmissionIntensity: 0, - targetEmissionIntensity: 0.12345678, - postProjectEmissionIntensity: 654, - totalLifetimeEmissionReduction: 456, - }, + }, + }, + ], + }, + latestCommittedEmissionIntensityReportFormChange: { + edges: [ + { + node: { + newFormData: { + baselineEmissionIntensity: 0, + targetEmissionIntensity: 0.12345678, + postProjectEmissionIntensity: 654, + totalLifetimeEmissionReduction: 456, }, }, }, @@ -235,6 +247,7 @@ describe("the emission intensity report form component", () => { expect(screen.getByText("654.00000000")).toHaveClass("diffOld"); expect(screen.getByText("456.00000000")).toHaveClass("diffOld"); }); + it("displays calculated values diff", () => { const customPayload = { Form() { @@ -257,12 +270,6 @@ describe("the emission intensity report form component", () => { maximumPerformanceMilestoneAmount: 123, actualPerformanceMilestoneAmount: null, operation: "UPDATE", - formChangeByPreviousFormChangeId: { - calculatedEiPerformance: 20, - paymentPercentage: 44, - maximumPerformanceMilestoneAmount: 321, - actualPerformanceMilestoneAmount: 789, - }, }, }, ], @@ -273,10 +280,10 @@ describe("the emission intensity report form component", () => { node: { isPristine: false, operation: "UPDATE", - calculatedEiPerformance: 22, - paymentPercentage: 13, - maximumPerformanceMilestoneAmount: 741, - actualPerformanceMilestoneAmount: 357, + calculatedEiPerformance: 20, + paymentPercentage: 44, + maximumPerformanceMilestoneAmount: 321, + actualPerformanceMilestoneAmount: 789, }, }, ], @@ -289,31 +296,27 @@ describe("the emission intensity report form component", () => { expect( screen.getByText(/ghg emission intensity performance/i) ).toBeInTheDocument(); - expect(screen.getByText(/20\.00 %/i)).toBeInTheDocument(); //old calculatedEiPerformance + expect(screen.getByText(/20\.00 %/i)).toBeInTheDocument(); //latest committed calculatedEiPerformance expect(screen.getByText(/10\.00 %/i)).toBeInTheDocument(); //new calculatedEiPerformance - expect(screen.getByText(/22\.00 %/i)).toBeInTheDocument(); //latest committed calculatedEiPerformance expect( screen.getByText( /payment percentage of performance milestone amount \(%\)/i ) ).toBeInTheDocument(); - expect(screen.getByText(/44\.00 %/i)).toBeInTheDocument(); //old paymentPercentage + expect(screen.getByText(/44\.00 %/i)).toBeInTheDocument(); //latest committed paymentPercentage expect(screen.getByText(/40\.00 %/i)).toBeInTheDocument(); //new paymentPercentage - expect(screen.getByText(/13\.00 %/i)).toBeInTheDocument(); //latest committed paymentPercentage expect( screen.getByText(/maximum performance milestone amount/i) ).toBeInTheDocument(); - expect(screen.getByText(/\$321\.00/i)).toBeInTheDocument(); //old maximumPerformanceMilestoneAmount + expect(screen.getByText(/\$321\.00/i)).toBeInTheDocument(); //latest committed maximumPerformanceMilestoneAmount expect(screen.getByText(/\$123\.00/i)).toBeInTheDocument(); //new maximumPerformanceMilestoneAmount - expect(screen.getByText(/\$741\.00/i)).toBeInTheDocument(); //latest committed maximumPerformanceMilestoneAmount expect( screen.getByText(/actual performance milestone amount/i) ).toBeInTheDocument(); - expect(screen.getByText(/\$789\.00/i)).toBeInTheDocument(); //old actualPerformanceMilestoneAmount - expect(screen.getByText(/\$357\.00/i)).toBeInTheDocument(); //latest committed actualPerformanceMilestoneAmount + expect(screen.getByText(/\$789\.00/i)).toBeInTheDocument(); //latest committed actualPerformanceMilestoneAmount }); it("renders the help tooltips", () => { From a09a6d93646b9d614281cac29395c5a51dac24cb Mon Sep 17 00:00:00 2001 From: Mike Vesprini Date: Sun, 19 May 2024 14:37:56 -0700 Subject: [PATCH 24/33] chore: use latest committed data to filter milestone schemas --- .../Functions/getMilestoneFilteredSchema.ts | 5 +++-- .../ProjectMilestoneReportFormSummary.tsx | 20 ++++++++++++++++++- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/app/components/Form/Functions/getMilestoneFilteredSchema.ts b/app/components/Form/Functions/getMilestoneFilteredSchema.ts index ab9c85991b..f4de801d43 100644 --- a/app/components/Form/Functions/getMilestoneFilteredSchema.ts +++ b/app/components/Form/Functions/getMilestoneFilteredSchema.ts @@ -12,7 +12,8 @@ import { JSONSchema7 } from "json-schema"; */ export const getMilestoneFilteredSchema = ( formSchema: JSONSchema7, - formChange + formChange, + latestCommittedFormChange ) => { const properties = formSchema.properties; // schema dependencies @@ -37,7 +38,7 @@ export const getMilestoneFilteredSchema = ( for (const key of Object.keys(filteredSchema.properties)) { const [updatedFormData, prevFormData] = [ formChange?.newFormData?.[key], - formChange?.formChangeByPreviousFormChangeId?.newFormData?.[key], + latestCommittedFormChange?.newFormData?.[key], ]; if ( updatedFormData === prevFormData || diff --git a/app/components/Form/ProjectMilestoneReportFormSummary.tsx b/app/components/Form/ProjectMilestoneReportFormSummary.tsx index 8f8e37c3e2..c0c5598990 100644 --- a/app/components/Form/ProjectMilestoneReportFormSummary.tsx +++ b/app/components/Form/ProjectMilestoneReportFormSummary.tsx @@ -83,6 +83,21 @@ const ProjectMilestoneReportFormSummary: React.FC = ({ ({ node }) => node.operation !== "ARCHIVE" ); + let latestCommittedReports = latestCommittedMilestoneFormChanges.edges; + const latestCommittedReportMap = useMemo(() => { + const filteredReports = latestCommittedReports.map(({ node }) => node); + + const reportMap = filteredReports.reduce( + (reports, current) => ( + (reports[current.newFormData.reportingRequirementIndex] = current), + reports + ), + {} + ); + + return reportMap; + }, [latestCommittedReports]); + // Sort consolidated milestone form change records const [sortedMilestoneReports] = useMemo(() => { return getSortedReports(milestoneReportFormChanges, true); @@ -139,7 +154,10 @@ const ProjectMilestoneReportFormSummary: React.FC = ({ }, { ...milestoneReport, - } + }, + latestCommittedReportMap[ + milestoneReport.newFormData.reportingRequirementIndex + ] ) : { formSchema: milestoneReport.formByJsonSchemaName.jsonSchema.schema, From 770f85e0977e6c100c5db155a886fa663c9122c4 Mon Sep 17 00:00:00 2001 From: Mike Vesprini Date: Mon, 20 May 2024 14:53:40 -0700 Subject: [PATCH 25/33] test: use latest committed data inmilestone summary tests --- .../ProjectMilestoneReportFormSummary.tsx | 1 + ...ProjectMilestoneReportFormSummary.test.tsx | 184 +++++------------- 2 files changed, 54 insertions(+), 131 deletions(-) diff --git a/app/components/Form/ProjectMilestoneReportFormSummary.tsx b/app/components/Form/ProjectMilestoneReportFormSummary.tsx index c0c5598990..563ce85a67 100644 --- a/app/components/Form/ProjectMilestoneReportFormSummary.tsx +++ b/app/components/Form/ProjectMilestoneReportFormSummary.tsx @@ -281,6 +281,7 @@ const ProjectMilestoneReportFormSummary: React.FC = ({ latestCommittedMilestoneFormChanges?.edges, renderDiff, sortedMilestoneReports, + latestCommittedReportMap ]); const milestoneReportsNotUpdated = useMemo( diff --git a/app/tests/unit/components/Form/ProjectMilestoneReportFormSummary.test.tsx b/app/tests/unit/components/Form/ProjectMilestoneReportFormSummary.test.tsx index c8f95cb561..7d5ca60ed6 100644 --- a/app/tests/unit/components/Form/ProjectMilestoneReportFormSummary.test.tsx +++ b/app/tests/unit/components/Form/ProjectMilestoneReportFormSummary.test.tsx @@ -50,17 +50,6 @@ const mockQueryPayload = { adjustedHoldbackAmount: 88, }, operation: "UPDATE", - formChangeByPreviousFormChangeId: { - newFormData: { - description: "bulbasaur", - projectId: 1, - reportingRequirementIndex: 1, - reportDueDate: "2020-01-01T13:59:59.999-07:00", - reportType: "Advanced", - reportingRequirementId: 1, - hasExpenses: true, - }, - }, formDataRecordId: 1, }, }, @@ -72,24 +61,43 @@ const mockQueryPayload = { description: "Removed comment", projectId: 1, reportDueDate: "2020-01-07T23:59:59.999-07:00", - reportingRequirementIndex: 1, + reportingRequirementIndex: 2, reportingRequirementId: 2, }, operation: "ARCHIVE", - formChangeByPreviousFormChangeId: { - newFormData: { - description: "Removed comment", - projectId: 1, - reportDueDate: "2020-01-05T23:59:59.999-07:00", - reportingRequirementIndex: 1, - reportingRequirementId: 2, - }, - }, formDataRecordId: 2, }, }, ], }, + latestCommittedMilestoneFormChanges: { + edges: [ + { + node: { + newFormData: { + description: "bulbasaur", + projectId: 1, + reportingRequirementIndex: 1, + reportDueDate: "2020-01-01T13:59:59.999-07:00", + reportType: "Advanced", + reportingRequirementId: 1, + hasExpenses: true, + }, + } + }, + { + node: { + newFormData: { + description: "Removed comment", + projectId: 1, + reportDueDate: "2020-01-05T23:59:59.999-07:00", + reportingRequirementIndex: 2, + reportingRequirementId: 2, + }, + } + }, + ] + } }; return result; }, @@ -125,7 +133,7 @@ describe("The Project Milestone Report Form Summary", () => { componentTestingHelper.renderComponent(); // changed fields - expect(screen.getByText("Milestone Description")).toBeInTheDocument(); + expect(screen.getByText(/Milestone Description/i)).toBeInTheDocument(); expect(screen.getByText("Milestone Type")).toBeInTheDocument(); // Archive milestone report @@ -220,97 +228,6 @@ describe("The Project Milestone Report Form Summary", () => { expect(screen.getByText(/\$88\.00/i)).toBeInTheDocument(); }); - it("Displays diffs of the data fields that were updated and shows latest committed values", () => { - const latestCommittedData = { - latestCommittedMilestoneFormChanges: { - edges: [ - { - node: { - newFormData: { - totalEligibleExpenses: 1000, - description: "charmander", - projectId: 1, - reportingRequirementIndex: 1, - reportType: "General", - reportDueDate: "2020-01-10T23:59:59.999-07:00", - reportingRequirementId: 1, - hasExpenses: true, - calculatedGrossAmount: 567, - calculatedNetAmount: 789, - calculatedHoldbackAmount: 891, - adjustedNetAmount: 89, - adjustedGrossAmount: 67, - adjustedHoldbackAmount: 91, - }, - }, - }, - ], - }, - }; - - const mockQueryPayloadLatestCommitted = { - ...mockQueryPayload, - ProjectRevision() { - const originalProjectRevision = mockQueryPayload.ProjectRevision(); - const modifiedProjectRevision = { - ...originalProjectRevision, - latestCommittedMilestoneFormChanges: { - edges: [ - { - node: { - newFormData: - latestCommittedData.latestCommittedMilestoneFormChanges - .edges[0].node.newFormData, - }, - }, - ], - }, - }; - return modifiedProjectRevision; - }, - }; - - componentTestingHelper.defaultQueryResolver = - mockQueryPayloadLatestCommitted; - componentTestingHelper.loadQuery(mockQueryPayloadLatestCommitted); - componentTestingHelper.renderComponent(); - - // calculated values - expect( - screen.getByText("Gross Payment Amount This Milestone") - ).toBeInTheDocument(); - expect(screen.getByText(/\$567\.00/i)).toBeInTheDocument(); - expect(screen.getByText(/\$999\.00/i)).toBeInTheDocument(); - expect( - screen.getByText("Net Payment Amount This Milestone") - ).toBeInTheDocument(); - expect(screen.getByText(/\$789\.00/i)).toBeInTheDocument(); - expect(screen.getByText(/\$888\.00/i)).toBeInTheDocument(); - expect( - screen.getByText("Holdback Amount This Milestone") - ).toBeInTheDocument(); - expect(screen.getByText(/\$891\.00/i)).toBeInTheDocument(); - expect(screen.getByText(/\$111\.00/i)).toBeInTheDocument(); - - // adjusted values - expect( - screen.getByText("Gross Payment Amount This Milestone (Adjusted)") - ).toBeInTheDocument(); - expect(screen.getByText(/\$99\.00/i)).toBeInTheDocument(); - - expect(screen.getByText(/\$89\.00/i)).toBeInTheDocument(); - expect( - screen.getByText("Net Payment Amount This Milestone (Adjusted)") - ).toBeInTheDocument(); - expect(screen.getByText(/\$11\.00/i)).toBeInTheDocument(); - expect(screen.getByText(/\$67\.00/i)).toBeInTheDocument(); - expect( - screen.getByText("Holdback Amount This Milestone (Adjusted)") - ).toBeInTheDocument(); - expect(screen.getByText(/\$88\.00/i)).toBeInTheDocument(); - expect(screen.getByText(/\$91\.00/i)).toBeInTheDocument(); - }); - it("Displays diffs of the data fields that were updated and the old values", () => { const mockQueryPayloadWithDiffs = { Form() { @@ -344,28 +261,34 @@ describe("The Project Milestone Report Form Summary", () => { adjustedHoldbackAmount: 23, }, operation: "UPDATE", - formChangeByPreviousFormChangeId: { - newFormData: { - description: "bulbasaur", - projectId: 1, - reportingRequirementIndex: 1, - reportDueDate: "2020-01-01T13:59:59.999-07:00", - reportType: "Advanced", - reportingRequirementId: 1, - hasExpenses: true, - calculatedNetAmount: 111, - calculatedGrossAmount: 112, - calculatedHoldbackAmount: 113, - adjustedNetAmount: 11, - adjustedGrossAmount: 12, - adjustedHoldbackAmount: 13, - }, - }, formDataRecordId: 1, }, }, ], }, + latestCommittedMilestoneFormChanges: { + edges: [ + { + node: { + newFormData: { + description: "bulbasaur", + projectId: 1, + reportingRequirementIndex: 1, + reportDueDate: "2020-01-01T13:59:59.999-07:00", + reportType: "Advanced", + reportingRequirementId: 1, + hasExpenses: true, + calculatedNetAmount: 111, + calculatedGrossAmount: 112, + calculatedHoldbackAmount: 113, + adjustedNetAmount: 11, + adjustedGrossAmount: 12, + adjustedHoldbackAmount: 13, + }, + } + } + ] + } }; return result; }, @@ -425,7 +348,6 @@ describe("The Project Milestone Report Form Summary", () => { node: { id: "Tooltip Test 1", isPristine: null, - formChangeByPreviousFormChangeId: null, newFormData: { calculatedGrossAmount: 123, calculatedHoldbackAmount: 456, From 0a500602574b64251a24d7183345ff53d1ce2647 Mon Sep 17 00:00:00 2001 From: Mike Vesprini Date: Mon, 20 May 2024 15:22:18 -0700 Subject: [PATCH 26/33] test: use latest committed data in collapsible form widget test --- .../CollapsibleFormWidget.test.tsx | 90 +++++++++++++------ 1 file changed, 62 insertions(+), 28 deletions(-) diff --git a/app/tests/unit/components/ProjectRevision/CollapsibleFormWidget.test.tsx b/app/tests/unit/components/ProjectRevision/CollapsibleFormWidget.test.tsx index 67c1735067..84f0bb6a2f 100644 --- a/app/tests/unit/components/ProjectRevision/CollapsibleFormWidget.test.tsx +++ b/app/tests/unit/components/ProjectRevision/CollapsibleFormWidget.test.tsx @@ -50,35 +50,69 @@ const mockQueryPayload = { name: "Test Project Status Name", }, }, - formChangeByPreviousFormChangeId: { - newFormData: { - proposalReference: "Test Proposal Reference PREVIOUS", - operatorId: 1, - fundingStreamRfpId: 1, - projectStatusId: 1, - summary: "Test Summary", - projectName: "Test Project Name", - totalFundingRequest: 100.0, - score: 1, - projectType: "test project type PREVIOUS", - }, - asProject: { - operatorByOperatorId: { - legalName: "Test Legal Name PREVIOUS", - bcRegistryId: "Test BC Registry ID", - }, - fundingStreamRfpByFundingStreamRfpId: { - year: 2020, - fundingStreamByFundingStreamId: { - description: "Test Funding Stream Description", - }, - }, - projectStatusByProjectStatusId: { - name: "Test Project Status Name", - }, - }, - }, + // formChangeByPreviousFormChangeId: { + // newFormData: { + // proposalReference: "Test Proposal Reference PREVIOUS", + // operatorId: 1, + // fundingStreamRfpId: 1, + // projectStatusId: 1, + // summary: "Test Summary", + // projectName: "Test Project Name", + // totalFundingRequest: 100.0, + // score: 1, + // projectType: "test project type PREVIOUS", + // }, + // asProject: { + // operatorByOperatorId: { + // legalName: "Test Legal Name PREVIOUS", + // bcRegistryId: "Test BC Registry ID", + // }, + // fundingStreamRfpByFundingStreamRfpId: { + // year: 2020, + // fundingStreamByFundingStreamId: { + // description: "Test Funding Stream Description", + // }, + // }, + // projectStatusByProjectStatusId: { + // name: "Test Project Status Name", + // }, + // }, + // }, }, + latestCommittedProjectFormChanges: { + edges: [ + { + node: { + newFormData: { + proposalReference: "Test Proposal Reference PREVIOUS", + operatorId: 1, + fundingStreamRfpId: 1, + projectStatusId: 1, + summary: "Test Summary", + projectName: "Test Project Name", + totalFundingRequest: 100.0, + score: 1, + projectType: "test project type PREVIOUS", + }, + asProject: { + operatorByOperatorId: { + legalName: "Test Legal Name PREVIOUS", + bcRegistryId: "Test BC Registry ID", + }, + fundingStreamRfpByFundingStreamRfpId: { + year: 2020, + fundingStreamByFundingStreamId: { + description: "Test Funding Stream Description", + }, + }, + projectStatusByProjectStatusId: { + name: "Test Project Status Name", + }, + }, + } + } + ] + } }; }, }; From 8882143e8615503420d7108b1528b3e0144ed420 Mon Sep 17 00:00:00 2001 From: Mike Vesprini Date: Mon, 20 May 2024 15:23:54 -0700 Subject: [PATCH 27/33] chore: pre-commit run --- .../ProjectMilestoneReportFormSummary.tsx | 2 +- ...ProjectMilestoneReportFormSummary.test.tsx | 16 ++++----- .../CollapsibleFormWidget.test.tsx | 36 +++---------------- 3 files changed, 13 insertions(+), 41 deletions(-) diff --git a/app/components/Form/ProjectMilestoneReportFormSummary.tsx b/app/components/Form/ProjectMilestoneReportFormSummary.tsx index 563ce85a67..decfaa1ca5 100644 --- a/app/components/Form/ProjectMilestoneReportFormSummary.tsx +++ b/app/components/Form/ProjectMilestoneReportFormSummary.tsx @@ -281,7 +281,7 @@ const ProjectMilestoneReportFormSummary: React.FC = ({ latestCommittedMilestoneFormChanges?.edges, renderDiff, sortedMilestoneReports, - latestCommittedReportMap + latestCommittedReportMap, ]); const milestoneReportsNotUpdated = useMemo( diff --git a/app/tests/unit/components/Form/ProjectMilestoneReportFormSummary.test.tsx b/app/tests/unit/components/Form/ProjectMilestoneReportFormSummary.test.tsx index 7d5ca60ed6..60a96d8e7f 100644 --- a/app/tests/unit/components/Form/ProjectMilestoneReportFormSummary.test.tsx +++ b/app/tests/unit/components/Form/ProjectMilestoneReportFormSummary.test.tsx @@ -83,7 +83,7 @@ const mockQueryPayload = { reportingRequirementId: 1, hasExpenses: true, }, - } + }, }, { node: { @@ -94,10 +94,10 @@ const mockQueryPayload = { reportingRequirementIndex: 2, reportingRequirementId: 2, }, - } + }, }, - ] - } + ], + }, }; return result; }, @@ -285,10 +285,10 @@ describe("The Project Milestone Report Form Summary", () => { adjustedGrossAmount: 12, adjustedHoldbackAmount: 13, }, - } - } - ] - } + }, + }, + ], + }, }; return result; }, diff --git a/app/tests/unit/components/ProjectRevision/CollapsibleFormWidget.test.tsx b/app/tests/unit/components/ProjectRevision/CollapsibleFormWidget.test.tsx index 84f0bb6a2f..111aa8a6f0 100644 --- a/app/tests/unit/components/ProjectRevision/CollapsibleFormWidget.test.tsx +++ b/app/tests/unit/components/ProjectRevision/CollapsibleFormWidget.test.tsx @@ -50,34 +50,6 @@ const mockQueryPayload = { name: "Test Project Status Name", }, }, - // formChangeByPreviousFormChangeId: { - // newFormData: { - // proposalReference: "Test Proposal Reference PREVIOUS", - // operatorId: 1, - // fundingStreamRfpId: 1, - // projectStatusId: 1, - // summary: "Test Summary", - // projectName: "Test Project Name", - // totalFundingRequest: 100.0, - // score: 1, - // projectType: "test project type PREVIOUS", - // }, - // asProject: { - // operatorByOperatorId: { - // legalName: "Test Legal Name PREVIOUS", - // bcRegistryId: "Test BC Registry ID", - // }, - // fundingStreamRfpByFundingStreamRfpId: { - // year: 2020, - // fundingStreamByFundingStreamId: { - // description: "Test Funding Stream Description", - // }, - // }, - // projectStatusByProjectStatusId: { - // name: "Test Project Status Name", - // }, - // }, - // }, }, latestCommittedProjectFormChanges: { edges: [ @@ -109,10 +81,10 @@ const mockQueryPayload = { name: "Test Project Status Name", }, }, - } - } - ] - } + }, + }, + ], + }, }; }, }; From cfe1807cdf5a29f63d72ed92063cb7f32cdbf130 Mon Sep 17 00:00:00 2001 From: Mike Vesprini Date: Mon, 20 May 2024 17:50:45 -0700 Subject: [PATCH 28/33] chore: fix filter on TEIMP summary query --- .../Form/ProjectEmissionIntensityReportFormSummary.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/components/Form/ProjectEmissionIntensityReportFormSummary.tsx b/app/components/Form/ProjectEmissionIntensityReportFormSummary.tsx index d2540a7e70..b5b88e6594 100644 --- a/app/components/Form/ProjectEmissionIntensityReportFormSummary.tsx +++ b/app/components/Form/ProjectEmissionIntensityReportFormSummary.tsx @@ -55,7 +55,8 @@ const ProjectEmissionsIntensityReportFormSummary: React.FC = ({ } } latestCommittedEmissionIntensityReportFormChange: latestCommittedFormChangesFor( - formDataTableName: "emission_intensity_report" + formDataTableName: "reporting_requirement" + reportType: "TEIMP" ) { edges { node { From bca9aa12a93b158382e6eb1bd4053a07687bdcc7 Mon Sep 17 00:00:00 2001 From: Mike Vesprini Date: Tue, 21 May 2024 21:08:13 -0700 Subject: [PATCH 29/33] chore: add attachments being archived to the summary page --- app/components/Attachment/AttachmentTableRow.tsx | 5 +++++ app/components/Form/ProjectAttachmentsFormSummary.tsx | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app/components/Attachment/AttachmentTableRow.tsx b/app/components/Attachment/AttachmentTableRow.tsx index afd8182118..c10effffd1 100644 --- a/app/components/Attachment/AttachmentTableRow.tsx +++ b/app/components/Attachment/AttachmentTableRow.tsx @@ -13,6 +13,7 @@ interface Props { formChangeRowId: number; hideDelete?: boolean; isFirstRevision: boolean; + operation?: string; } const AttachmentTableRow: React.FC = ({ @@ -21,6 +22,7 @@ const AttachmentTableRow: React.FC = ({ formChangeRowId, hideDelete, isFirstRevision, + operation, }) => { const [ discardProjectAttachmentFormChange, @@ -65,6 +67,9 @@ const AttachmentTableRow: React.FC = ({ return ( <> + {operation && ( + {operation.charAt(0).toUpperCase() + operation.slice(1).toLowerCase()} + )} {fileName} {fileType} {fileSize} diff --git a/app/components/Form/ProjectAttachmentsFormSummary.tsx b/app/components/Form/ProjectAttachmentsFormSummary.tsx index 42fbbf8daf..35c0b9cec7 100644 --- a/app/components/Form/ProjectAttachmentsFormSummary.tsx +++ b/app/components/Form/ProjectAttachmentsFormSummary.tsx @@ -7,6 +7,7 @@ import { FormNotAddedOrUpdated } from "./SummaryFormCommonComponents"; import { useEffect, useMemo } from "react"; const tableFilters = [ + new TextFilter("Operation", "operation"), new TextFilter("File Name", "fileName"), new TextFilter("Type", "type"), new TextFilter("Size", "size"), @@ -36,7 +37,6 @@ const ProjectAttachmentsFormSummary: React.FC = ({ summaryProjectAttachmentFormChanges: formChangesFor( first: 500 formDataTableName: "project_attachment" - filter: { operation: { notEqualTo: ARCHIVE } } ) @connection(key: "connection_summaryProjectAttachmentFormChanges") { __id totalCount @@ -115,6 +115,7 @@ const ProjectAttachmentsFormSummary: React.FC = ({ ({ node }) => ( Date: Tue, 21 May 2024 21:49:28 -0700 Subject: [PATCH 30/33] chore: linting --- app/components/Attachment/AttachmentTableRow.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/components/Attachment/AttachmentTableRow.tsx b/app/components/Attachment/AttachmentTableRow.tsx index c10effffd1..661e045d0a 100644 --- a/app/components/Attachment/AttachmentTableRow.tsx +++ b/app/components/Attachment/AttachmentTableRow.tsx @@ -68,7 +68,10 @@ const AttachmentTableRow: React.FC = ({ <> {operation && ( - {operation.charAt(0).toUpperCase() + operation.slice(1).toLowerCase()} + + {operation.charAt(0).toUpperCase() + + operation.slice(1).toLowerCase()} + )} {fileName} {fileType} From 62785ebd77150edb115851d60173e5579457a0fe Mon Sep 17 00:00:00 2001 From: Mike Vesprini Date: Tue, 21 May 2024 22:16:55 -0700 Subject: [PATCH 31/33] test: add test for archived attachments in attachment summary form tests --- .../ProjectAttachmentsFormSummary.test.tsx | 32 ++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/app/tests/unit/components/Form/ProjectAttachmentsFormSummary.test.tsx b/app/tests/unit/components/Form/ProjectAttachmentsFormSummary.test.tsx index 9c8f3f6b81..61e515451e 100644 --- a/app/tests/unit/components/Form/ProjectAttachmentsFormSummary.test.tsx +++ b/app/tests/unit/components/Form/ProjectAttachmentsFormSummary.test.tsx @@ -34,6 +34,7 @@ const defaultQueryResolver = { node: { id: "test-attachment-form-change-id-1", rowId: 1, + operation: "CREATE", asProjectAttachment: { attachmentByAttachmentId: { id: "test-attachment-id-1", @@ -52,6 +53,7 @@ const defaultQueryResolver = { node: { id: "test-attachment-form-change-id-2", rowId: 2, + operation: "CREATE", asProjectAttachment: { attachmentByAttachmentId: { id: "test-attachment-id-2", @@ -66,6 +68,25 @@ const defaultQueryResolver = { }, }, }, + { + node: { + id: "test-attachment-form-change-id-3", + rowId: 3, + operation: "ARCHIVE", + asProjectAttachment: { + attachmentByAttachmentId: { + id: "test-attachment-id-3", + fileName: "test-attachment-3.jpg", + fileType: "image/jpeg", + fileSize: 123456, + createdAt: "2021-01-03T00:00:00.000Z", + cifUserByCreatedBy: { + fullName: "Test User 2", + }, + }, + }, + }, + }, ], }, }, @@ -111,11 +132,20 @@ describe("The project's attachment page", () => { ).not.toBeInTheDocument(); }); - it("Displays all attachments", () => { + it("Displays all attachments that were created in this revision", () => { componentTestingHelper.loadQuery(); componentTestingHelper.renderComponent(); + expect(screen.getAllByText(/Create/i)).toHaveLength(2); expect(screen.getByText(/test-attachment-1.jpg/i)).toBeInTheDocument(); expect(screen.getByText(/test-attachment-2.jpg/i)).toBeInTheDocument(); }); + + it("Displays all attachments that were archived in this revision", () => { + componentTestingHelper.loadQuery(); + componentTestingHelper.renderComponent(); + + expect(screen.getAllByText(/Archive/i)).toHaveLength(1); + expect(screen.getByText(/test-attachment-3.jpg/i)).toBeInTheDocument(); + }); }); From 29a47b7404edfcfa10cf8c9172f693b62fb51c2e Mon Sep 17 00:00:00 2001 From: Mike Vesprini Date: Fri, 24 May 2024 11:31:52 -0700 Subject: [PATCH 32/33] chore: missing dependency in useMemo call --- app/components/Form/ProjectContactFormSummary.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/components/Form/ProjectContactFormSummary.tsx b/app/components/Form/ProjectContactFormSummary.tsx index 1c728e3493..6065af8a67 100644 --- a/app/components/Form/ProjectContactFormSummary.tsx +++ b/app/components/Form/ProjectContactFormSummary.tsx @@ -192,7 +192,7 @@ const ProjectContactFormSummary: React.FC = ({ secondaryContacts, renderDiff, isOnAmendmentsAndOtherRevisionsPage, - summaryContactFormChanges, + lastCommittedSecondaryContacts, ]); // Update the hasDiff state in the CollapsibleFormWidget to define if the form has diffs to show From 9c065d085f0c5a4b29b5757d5f18de5003b13710 Mon Sep 17 00:00:00 2001 From: Mike Vesprini Date: Fri, 24 May 2024 12:46:46 -0700 Subject: [PATCH 33/33] chore: update comments to no longer reflect 3 diffs scenario --- .../ProjectFundingAgreementFormSummary.test.tsx | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/app/tests/unit/components/Form/ProjectFundingAgreementFormSummary.test.tsx b/app/tests/unit/components/Form/ProjectFundingAgreementFormSummary.test.tsx index d022cce4b8..040de13d18 100644 --- a/app/tests/unit/components/Form/ProjectFundingAgreementFormSummary.test.tsx +++ b/app/tests/unit/components/Form/ProjectFundingAgreementFormSummary.test.tsx @@ -38,8 +38,8 @@ const mockQueryPayloadEP = { edges: [ { node: { - proponentsSharePercentage: 5, // will trigger three diffs - totalProjectValue: 6, // will trigger three diffs + proponentsSharePercentage: 5, // will trigger diffs + totalProjectValue: 6, // will trigger diffs newFormData: { projectId: "Test Project ID", maxFundingAmount: 200, @@ -71,8 +71,8 @@ const mockQueryPayloadEP = { edges: [ { node: { - proponentsSharePercentage: 10, // will trigger three diffs - totalProjectValue: 12, // will trigger three diffs + proponentsSharePercentage: 10, // will trigger diffs + totalProjectValue: 12, // will trigger diffs newFormData: { projectId: "Test Project ID", maxFundingAmount: 200, @@ -127,8 +127,8 @@ const mockQueryPayloadIA = { edges: [ { node: { - proponentsSharePercentage: 7, // will trigger three diffs - totalProjectValue: 8, // will trigger three diffs + proponentsSharePercentage: 7, // will trigger diffs + totalProjectValue: 8, // will trigger diffs newFormData: { projectId: "Test Project ID", maxFundingAmount: 501, @@ -149,8 +149,8 @@ const mockQueryPayloadIA = { edges: [ { node: { - proponentsSharePercentage: 14, // will trigger three diffs - totalProjectValue: 16, // will trigger three diffs + proponentsSharePercentage: 14, // will trigger diffs + totalProjectValue: 16, // will trigger diffs newFormData: { projectId: "Test Project ID", maxFundingAmount: 500,