diff --git a/app/components/Form/ProjectEmissionIntensityReportFormSummary.tsx b/app/components/Form/ProjectEmissionIntensityReportFormSummary.tsx index 6cd0ffeb42..47efa23cab 100644 --- a/app/components/Form/ProjectEmissionIntensityReportFormSummary.tsx +++ b/app/components/Form/ProjectEmissionIntensityReportFormSummary.tsx @@ -259,6 +259,12 @@ const ProjectEmissionsIntensityReportFormSummary: React.FC = ({ isOnAmendmentsAndOtherRevisionsPage, }} /> + ); }; diff --git a/app/components/Form/ProjectMilestoneReportFormSummary.tsx b/app/components/Form/ProjectMilestoneReportFormSummary.tsx index d0aeccc995..327e81d397 100644 --- a/app/components/Form/ProjectMilestoneReportFormSummary.tsx +++ b/app/components/Form/ProjectMilestoneReportFormSummary.tsx @@ -236,6 +236,12 @@ const ProjectMilestoneReportFormSummary: React.FC = ({ uiSchema={updatedUiSchema} formData={milestoneFormDiffObject.formData} formContext={{ + calculatedHoldbackAmount: + milestoneReport?.newFormData?.calculatedHoldbackAmount, + calculatedGrossAmount: + milestoneReport?.newFormData?.calculatedGrossAmount, + calculatedNetAmount: + milestoneReport?.newFormData?.calculatedNetAmount, operation: milestoneReport.operation, oldData: milestoneReport.formChangeByPreviousFormChangeId?.newFormData, @@ -244,11 +250,14 @@ const ProjectMilestoneReportFormSummary: React.FC = ({ isOnAmendmentsAndOtherRevisionsPage, }} /> - ); diff --git a/app/cypress/e2e/cif/project-revision/create-first-project-revision.cy.js b/app/cypress/e2e/cif/project-revision/create-first-project-revision.cy.js index 03b042ece8..f0dbb007f2 100644 --- a/app/cypress/e2e/cif/project-revision/create-first-project-revision.cy.js +++ b/app/cypress/e2e/cif/project-revision/create-first-project-revision.cy.js @@ -266,10 +266,10 @@ describe("when creating a project, the project page", () => { // GHG performance uses the ReadOnlyAdjustableCalculatedValueWidget, which has a different HTML structure than the other fields cy.findByText("GHG Emission Intensity Performance") .next() - .should( - "have.text", - "200.00%GHG Emission Intensity Performance (Adjusted)100%" - ); + .should("have.text", "200.00%"); + cy.findByText("GHG Emission Intensity Performance (Adjusted)") + .next() + .should("have.text", "100%"); cy.findByText("Payment Percentage of Performance Milestone Amount (%)") .next() .should("have.text", "100.00%"); diff --git a/app/lib/theme/ReadOnlyFieldTemplate.tsx b/app/lib/theme/ReadOnlyFieldTemplate.tsx index 0fa41e6fc4..3b48e44585 100644 --- a/app/lib/theme/ReadOnlyFieldTemplate.tsx +++ b/app/lib/theme/ReadOnlyFieldTemplate.tsx @@ -15,7 +15,13 @@ const FieldTemplate: React.FC = ({ }) => { return (
-
+
{displayLabel && ( = ( props @@ -10,34 +11,14 @@ const ReadOnlyAdjustableCalculatedValueWidget: React.FC = ( const isMoney = uiSchema?.isMoney; const isPercentage = uiSchema?.isPercentage; - // If we need to set the amount of decimal places, we can set it in the uiSchema, otherwise there will be no decimal places. - const numberOfDecimalPlaces = isMoney - ? 2 - : uiSchema?.numberOfDecimalPlaces ?? 0; - const calculatedValue = formContext[uiSchema.calculatedValueFormContextProperty]; const adjustedInputId = `${id}_adjusted`; return ( -
- {calculatedValue && ( - <> - { - - } - - )} + <> + {value !== calculatedValue && (
{label} (Adjusted)
@@ -57,21 +38,22 @@ const ReadOnlyAdjustableCalculatedValueWidget: React.FC = ( ) : ( Not added )} +
)} - - -
+ ); }; diff --git a/app/tests/unit/components/Form/ProjectEmissionIntensityReportFormSummary.test.tsx b/app/tests/unit/components/Form/ProjectEmissionIntensityReportFormSummary.test.tsx index a7d3094af2..0abf95719a 100644 --- a/app/tests/unit/components/Form/ProjectEmissionIntensityReportFormSummary.test.tsx +++ b/app/tests/unit/components/Form/ProjectEmissionIntensityReportFormSummary.test.tsx @@ -345,7 +345,7 @@ describe("the emission intensity report form component", () => { }, }; componentTestingHelper.loadQuery(customPayload); - const component = componentTestingHelper.renderComponent(); + componentTestingHelper.renderComponent(); // Note the exclusion of the GHG Emission Intensity Performance (Adjusted) field here // This is captured in AdjustableCalculatedValueWidget.test.tsx @@ -370,8 +370,5 @@ describe("the emission intensity report form component", () => { name: "actual-performance-milestone-amount-tooltip", }) ).toBeInTheDocument(); - - // check that tooltip text hasn't changed - expect(component.container).toMatchSnapshot(); }); }); diff --git a/app/tests/unit/components/Form/ProjectFundingAgreementFormSummary.test.tsx b/app/tests/unit/components/Form/ProjectFundingAgreementFormSummary.test.tsx index 4544259e1f..e183263ef0 100644 --- a/app/tests/unit/components/Form/ProjectFundingAgreementFormSummary.test.tsx +++ b/app/tests/unit/components/Form/ProjectFundingAgreementFormSummary.test.tsx @@ -739,7 +739,7 @@ describe("The Project Funding Agreement Form Summary", () => { }; }, }); - const component = componentTestingHelper.renderComponent(); + componentTestingHelper.renderComponent(); expect( screen.getAllByRole("tooltip", { name: "maximum-funding-amount-tooltip", @@ -795,9 +795,6 @@ describe("The Project Funding Agreement Form Summary", () => { name: "total-eligible-expenses-to-date-tooltip", }) ).toHaveLength(1); - - // check that tooltip text hasn't changed - expect(component.container).toMatchSnapshot(); }); it("renders the tooltips for the IA form", () => { @@ -880,7 +877,7 @@ describe("The Project Funding Agreement Form Summary", () => { }; }, }); - const component = componentTestingHelper.renderComponent(); + componentTestingHelper.renderComponent(); expect( screen.getAllByRole("tooltip", { @@ -913,7 +910,5 @@ describe("The Project Funding Agreement Form Summary", () => { name: "additional-funding-amount-tooltip", }) ).toHaveLength(1); - // check that tooltip text hasn't changed - expect(component.container).toMatchSnapshot(); }); }); diff --git a/app/tests/unit/components/Form/ProjectMilestoneReportFormSummary.test.tsx b/app/tests/unit/components/Form/ProjectMilestoneReportFormSummary.test.tsx index c9bcf5c0cb..c8f95cb561 100644 --- a/app/tests/unit/components/Form/ProjectMilestoneReportFormSummary.test.tsx +++ b/app/tests/unit/components/Form/ProjectMilestoneReportFormSummary.test.tsx @@ -120,7 +120,7 @@ describe("The Project Milestone Report Form Summary", () => { componentTestingHelper.reinit(); }); - it("Only displays the data fields that have changed", () => { + it("Displays the data fields that have changed", () => { componentTestingHelper.loadQuery(); componentTestingHelper.renderComponent(); @@ -134,6 +134,41 @@ describe("The Project Milestone Report Form Summary", () => { expect(milestoneReport.textContent).toBe("Milestone Report"); }); + it("Displays calculated and adjusted values and labels for calculated fields", () => { + componentTestingHelper.loadQuery(); + componentTestingHelper.renderComponent(); + + // Gross Payment Amount + expect( + screen.getByText("Gross Payment Amount This Milestone") + ).toBeInTheDocument(); + expect(screen.getByText("$999.00")).toBeInTheDocument(); + expect( + screen.getByText(/gross payment amount this milestone \(adjusted\)/i) + ).toBeInTheDocument(); + expect(screen.getByText("$99.00")).toBeInTheDocument(); + + // Net Payment Amount + expect( + screen.getByText("Net Payment Amount This Milestone") + ).toBeInTheDocument(); + expect(screen.getByText("$111.00")).toBeInTheDocument(); + expect( + screen.getByText(/net payment amount this milestone \(adjusted\)/i) + ).toBeInTheDocument(); + expect(screen.getByText("$11.00")).toBeInTheDocument(); + + // Holdback Amount + expect( + screen.getByText("Holdback Amount This Milestone") + ).toBeInTheDocument(); + expect(screen.getByText("$888.00")).toBeInTheDocument(); + expect( + screen.getByText(/holdback amount this milestone \(adjusted\)/i) + ).toBeInTheDocument(); + expect(screen.getByText("$88.00")).toBeInTheDocument(); + }); + it("Displays diffs of the the data fields that were updated", () => { componentTestingHelper.loadQuery(); componentTestingHelper.renderComponent(); @@ -185,56 +220,56 @@ describe("The Project Milestone Report Form Summary", () => { expect(screen.getByText(/\$88\.00/i)).toBeInTheDocument(); }); - 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, + 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, + ], + }, + }; + + const mockQueryPayloadLatestCommitted = { + ...mockQueryPayload, + ProjectRevision() { + const originalProjectRevision = mockQueryPayload.ProjectRevision(); + const modifiedProjectRevision = { + ...originalProjectRevision, + latestCommittedMilestoneFormChanges: { + edges: [ + { + node: { + newFormData: + latestCommittedData.latestCommittedMilestoneFormChanges + .edges[0].node.newFormData, + }, }, - }, - ], - }, - }; - return modifiedProjectRevision; - }, - }; + ], + }, + }; + return modifiedProjectRevision; + }, + }; - it("Displays diffs of the data fields that were updated and shows latest committed values", () => { componentTestingHelper.defaultQueryResolver = mockQueryPayloadLatestCommitted; componentTestingHelper.loadQuery(mockQueryPayloadLatestCommitted); @@ -275,66 +310,66 @@ describe("The Project Milestone Report Form Summary", () => { expect(screen.getByText(/\$88\.00/i)).toBeInTheDocument(); expect(screen.getByText(/\$91\.00/i)).toBeInTheDocument(); }); - const mockQueryPayloadWithDiffs = { - Form() { - return { - jsonSchema: milestoneProdSchema, - }; - }, - ProjectRevision() { - const result = { - isFirstRevision: false, - summaryMilestoneFormChanges: { - edges: [ - { - node: { - id: "Test Reporting Requirement ID - 1", - isPristine: false, - newFormData: { - totalEligibleExpenses: 1000, - description: "charmander", - projectId: 1, - reportingRequirementIndex: 1, - reportType: "General", - reportDueDate: "2020-01-10T23:59:59.999-07:00", - reportingRequirementId: 1, - hasExpenses: true, - calculatedNetAmount: 221, - calculatedGrossAmount: 222, - calculatedHoldbackAmount: 223, - adjustedNetAmount: 21, - adjustedGrossAmount: 22, - adjustedHoldbackAmount: 23, - }, - operation: "UPDATE", - formChangeByPreviousFormChangeId: { + + it("Displays diffs of the data fields that were updated and the old values", () => { + const mockQueryPayloadWithDiffs = { + Form() { + return { + jsonSchema: milestoneProdSchema, + }; + }, + ProjectRevision() { + const result = { + isFirstRevision: false, + summaryMilestoneFormChanges: { + edges: [ + { + node: { + id: "Test Reporting Requirement ID - 1", + isPristine: false, newFormData: { - description: "bulbasaur", + totalEligibleExpenses: 1000, + description: "charmander", projectId: 1, reportingRequirementIndex: 1, - reportDueDate: "2020-01-01T13:59:59.999-07:00", - reportType: "Advanced", + reportType: "General", + reportDueDate: "2020-01-10T23:59:59.999-07:00", reportingRequirementId: 1, hasExpenses: true, - calculatedNetAmount: 111, - calculatedGrossAmount: 112, - calculatedHoldbackAmount: 113, - adjustedNetAmount: 11, - adjustedGrossAmount: 12, - adjustedHoldbackAmount: 13, + calculatedNetAmount: 221, + calculatedGrossAmount: 222, + calculatedHoldbackAmount: 223, + adjustedNetAmount: 21, + adjustedGrossAmount: 22, + 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, }, - formDataRecordId: 1, }, - }, - ], - }, - }; - return result; - }, - }; - - it("Displays diffs of the data fields that were updated and the old values", () => { + ], + }, + }; + return result; + }, + }; componentTestingHelper.defaultQueryResolver = mockQueryPayloadWithDiffs; componentTestingHelper.loadQuery(mockQueryPayloadWithDiffs); componentTestingHelper.renderComponent(); @@ -413,7 +448,7 @@ describe("The Project Milestone Report Form Summary", () => { }, }; componentTestingHelper.loadQuery(mockTooltipPayload); - const component = componentTestingHelper.renderComponent(); + componentTestingHelper.renderComponent(); expect( screen.getAllByRole("tooltip", { @@ -444,7 +479,5 @@ describe("The Project Milestone Report Form Summary", () => { name: "holdback-amount-this-milestone-tooltip", }) ).toHaveLength(1); - // check that tooltip text hasn't changed - expect(component.container).toMatchSnapshot(); }); }); diff --git a/app/tests/unit/components/Form/__snapshots__/ProjectEmissionIntensityReportFormSummary.test.tsx.snap b/app/tests/unit/components/Form/__snapshots__/ProjectEmissionIntensityReportFormSummary.test.tsx.snap deleted file mode 100644 index 76ce77b26a..0000000000 --- a/app/tests/unit/components/Form/__snapshots__/ProjectEmissionIntensityReportFormSummary.test.tsx.snap +++ /dev/null @@ -1,510 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`the emission intensity report form component renders the help tooltips 1`] = ` -
-

- Emission Intensity Report -

-
-
-
-
-
-
-
- Report Due Date (optional) -
-
- - Not added - -
-
-
-
-
-
-
- Report Received Date (optional) -
-
- - Not added - -
-
-
-
-
-
-
- General Comments (optional) -
-
- - Not added - -
-
-
-
-
-
-
- TEIMP Start Date -
-
- - Not added - -
-
-
-
-
-
-
- TEIMP End Date -
-
- - Not added - -
-
-
-
-
-
-
- Functional Unit -
-
- - Not added - -
-
-
-
-
-
-
- Production Functional Unit (optional) -
-
- - Not added - -
-
-
-
-
-
-
- Baseline Emission Intensity (BEI) -
-
- - Not added - -
-
-
-
-
-
- Target Emission Intensity (TEI) -
-
- - Not added - -
-
-
-
-
-
- Post-Project Emission Intensity (PEI) (optional) -
-
- - Not added - -
-
-
-
-
-
- Total Project Lifetime Emissions Reductions (optional) -
-
- - Not added - -
-
-
-
-
-
- GHG Emission Intensity Performance - - - -
-
- -
-
- GHG Emission Intensity Performance - (Adjusted) -
- - Not added - -
-
-
-
-
-
-
- Date Invoice Sent to CSNR (optional) -
-
- - Not added - -
-
-
-
-
-
-
- Payment Percentage of Performance Milestone Amount (%) - - - -
-
- -
-
-
-
-
-
- Actual Performance Milestone Amount - - - -
-
- -
-
-
-
-
-
- Maximum Performance Milestone Amount - - - -
-
- -
-
-
-
-
-
-
-
-`; diff --git a/app/tests/unit/components/Form/__snapshots__/ProjectFundingAgreementFormSummary.test.tsx.snap b/app/tests/unit/components/Form/__snapshots__/ProjectFundingAgreementFormSummary.test.tsx.snap deleted file mode 100644 index 7ce151e230..0000000000 --- a/app/tests/unit/components/Form/__snapshots__/ProjectFundingAgreementFormSummary.test.tsx.snap +++ /dev/null @@ -1,2045 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`The Project Funding Agreement Form Summary renders the tooltips for the EP form 1`] = ` -
-
-

- Budgets, Expenses & Payments -

-
-
-
-
-
-
-
- Contract Start Date -
- - Jan 1, 2029 - - - - Feb 2, 2021 - -
-
-
-
-
- Project Assets Life End Date -
- - Dec 31, 2029 - - - - Dec 31, 2021 - -
-
-
-
-
- Maximum Funding Amount - - - -
- - $555.00 - - - - $200.00 - -
-
-
-
-
- Province's Share Percentage - - - -
- - 555.00 % - - - - 60.00 % - -
-
-
-
-
- Performance Milestone Holdback Percentage - - - -
- - 5.55 % - - - - 20.15 % - -
-
-
-
-
- Proponent Cost - - - -
- - $555.00 - - - - $100.00 - -
-
-
-
-
- Proponent's Share Percentage - - - -
- - 555.00 % - - - - - - 5.00 % - -
-
-
-
-
- Anticipated/Actual Funding Amount -
- - $555.00 - - - - $300.00 - -
-
-
-
-
-
-
- Anticipated Funding Amount Per Fiscal Year - - 1 -
-
-
-
-
-
-
-
-
- Fiscal Year -
- - Not Entered - - - - <mock-value-for-field-"fiscalYear"> - -
-
-
-
-
- Anticipated Amount Per Fiscal Year -
- - $555.00 - - - -
-
-
-
-
-
-
-
-
-
-
-
-
-
- Total Project Value - - - -
- - $555.00 - - - - - - $6.00 - -
-
-
-
-
-
-
- Additional Funding Source - - 1 -
-
-
-
-
-
-
-
-
- Additional Funding Source -
- - Not Entered - - - - Test Source Name - -
-
-
-
-
- Additional Funding Amount - - - -
- - Not Entered - - - - $2,500.00 - -
-
-
-
-
- Additional Funding Status -
- - Not Entered - - - - Approved - -
-
-
-
-
-
-
-
-
-
-
-
-
-
- Total Net Payment Amount to Date - - - -
- - - - $1.00 - -
-
-
-
-
- Total Gross Payment Amount to Date - - - -
- - - - $1.00 - -
-
-
-
-
- Total Holdback Amount to Date - - - -
- - - - $0.00 - -
-
-
-
-
- Total Eligible Expenses to Date - - - -
- - - - $1.00 - -
-
-
-
-
-
-
-
-`; - -exports[`The Project Funding Agreement Form Summary renders the tooltips for the IA form 1`] = ` -
-
-

- Budgets, Expenses & Payments -

-
-
-
-
-
-
-
- Contract Start Date -
- - Jan 1, 2029 - - - - Feb 2, 2021 - -
-
-
-
-
- Project Assets Life End Date -
- - Dec 31, 2029 - - - - Dec 31, 2021 - -
-
-
-
-
- Maximum Funding Amount - - - -
- - $555.00 - - - - $200.00 - -
-
-
-
-
- Province's Share Percentage - - - -
- - 555.00 % - - - - 60.00 % - -
-
-
-
-
- Performance Milestone Holdback Percentage - - - -
- - 5.55 % - - - - 20.15 % - -
-
-
-
-
- Proponent Cost - - - -
- - $555.00 - - - - $100.00 - -
-
-
-
-
- Proponent's Share Percentage - - - -
- - 555.00 % - - - - - - 5.00 % - -
-
-
-
-
- Anticipated/Actual Funding Amount -
- - $555.00 - - - - $300.00 - -
-
-
-
-
-
-
- Anticipated Funding Amount Per Fiscal Year - - 1 -
-
-
-
-
-
-
-
-
- Fiscal Year -
- - Not Entered - - - - <mock-value-for-field-"fiscalYear"> - -
-
-
-
-
- Anticipated Amount Per Fiscal Year -
- - $555.00 - - - -
-
-
-
-
-
-
-
-
-
-
-
-
-
- Total Project Value - - - -
- - $555.00 - - - - - - $6.00 - -
-
-
-
-
-
-
- Additional Funding Source - - 1 -
-
-
-
-
-
-
-
-
- Additional Funding Source -
- - Not Entered - - - - Test Source Name - -
-
-
-
-
- Additional Funding Amount - - - -
- - Not Entered - - - - $2,500.00 - -
-
-
-
-
- Additional Funding Status -
- - Not Entered - - - - Approved - -
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-`; diff --git a/app/tests/unit/components/Form/__snapshots__/ProjectMilestoneReportFormSummary.test.tsx.snap b/app/tests/unit/components/Form/__snapshots__/ProjectMilestoneReportFormSummary.test.tsx.snap deleted file mode 100644 index 0618e1eb69..0000000000 --- a/app/tests/unit/components/Form/__snapshots__/ProjectMilestoneReportFormSummary.test.tsx.snap +++ /dev/null @@ -1,488 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`The Project Milestone Report Form Summary renders the tooltips for the mock summary 1`] = ` -
-

- Project Milestone Reports -

-
-
-

- Milestone Report - 1 -

-
-
-
-
-
-
-
-
- Milestone Description -
-
- - Not added - -
-
-
-
-
-
-
- Milestone Type -
-
- General Milestone -
-
-
-
-
-
- -
-
-
-
-
- Maximum Amount This Milestone - - - -
-
- - $23.00 - - -
-
-
-
-
-
- Substantial Completion Date -
-
- - Not added - -
-
-
-
-
-
-
- Report Due Date -
-
- - Not added - -
-
-
-
-
-
-
- Certifier (optional) -
-
- - Not added - -
-
-
-
-
-
-
- Professional Designation (optional) -
-
- Professional Engineer -
-
-
-
-
-
-
- Report Received Date (optional) -
-
- - Not added - -
-
-
-
-
-
-
- Total Eligible Expenses (optional) - - - -
-
- - $1,000.00 - - -
-
-
-
-
-
- Gross Payment Amount This Milestone - - - -
-
-
-
- Gross Payment Amount This Milestone - (Adjusted) -
-
- - $1,000.00 - -
-
-
-
-
-
-
-
- Net Payment Amount This Milestone - - - -
-
-
-
-
-
-
- Holdback Amount This Milestone - - - -
-
-
-
-
-
-
- Date Invoice Sent to CSNR (optional) -
-
- - Not added - -
-
-
-
-
-
-
-
-
-
-`;