diff --git a/app/components/Form/ProjectContactFormSummary.tsx b/app/components/Form/ProjectContactFormSummary.tsx index 69b8bd73e4..c71c4fc399 100644 --- a/app/components/Form/ProjectContactFormSummary.tsx +++ b/app/components/Form/ProjectContactFormSummary.tsx @@ -113,9 +113,7 @@ const ProjectContactFormSummary: React.FC = ({ const secondaryContacts = useMemo( () => contactFormChanges.filter( - ({ node }) => - node.newFormData?.contactIndex !== 1 && - (node.isPristine === false || node.isPristine === null) + ({ node }) => node.newFormData?.contactIndex !== 1 ), [contactFormChanges] ); @@ -150,6 +148,7 @@ const ProjectContactFormSummary: React.FC = ({ const contactsJSX = useMemo(() => { return secondaryContacts.map(({ node }) => { + if (node.isPristine && renderDiff) return null; const latestCommittedContactNode = lastCommittedSecondaryContacts.find( (latestCommittedNode) => { return ( diff --git a/app/tests/unit/components/Form/ProjectContactFormSummary.test.tsx b/app/tests/unit/components/Form/ProjectContactFormSummary.test.tsx index e853a1783a..4d2760c6e7 100644 --- a/app/tests/unit/components/Form/ProjectContactFormSummary.test.tsx +++ b/app/tests/unit/components/Form/ProjectContactFormSummary.test.tsx @@ -171,6 +171,22 @@ describe("The ProjectContactFormSummary", () => { componentTestingHelper.reinit(); }); + it("Displays primary contact and secondary contacts on view mode", () => { + componentTestingHelper.loadQuery(); + componentTestingHelper.renderComponent(undefined, { + viewOnly: true, + }); + + // Primary contact + expect(screen.getByText(/primary contact/i)).toBeInTheDocument(); + expect(screen.getByText(/Test Full Name primary/i)).toBeInTheDocument(); + + // Secondary contacts + expect(screen.getByText(/secondary contacts/i)).toBeInTheDocument(); + expect(screen.getByText(/I did not change/i)).toBeInTheDocument(); + expect(screen.getByText(/I was added/i)).toBeInTheDocument(); + }); + it("Only displays the data fields that have changed", () => { componentTestingHelper.loadQuery(); componentTestingHelper.renderComponent();