Skip to content

Commit

Permalink
fix: shows secondary contacts in project contact summary form
Browse files Browse the repository at this point in the history
  • Loading branch information
Sepehr-Sobhani committed Jul 19, 2023
1 parent 2ba4145 commit 55b11c2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
5 changes: 2 additions & 3 deletions app/components/Form/ProjectContactFormSummary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,7 @@ const ProjectContactFormSummary: React.FC<Props> = ({
const secondaryContacts = useMemo(
() =>
contactFormChanges.filter(
({ node }) =>
node.newFormData?.contactIndex !== 1 &&
(node.isPristine === false || node.isPristine === null)
({ node }) => node.newFormData?.contactIndex !== 1
),
[contactFormChanges]
);
Expand Down Expand Up @@ -150,6 +148,7 @@ const ProjectContactFormSummary: React.FC<Props> = ({

const contactsJSX = useMemo(() => {
return secondaryContacts.map(({ node }) => {
if (node.isPristine && renderDiff) return null;
const latestCommittedContactNode = lastCommittedSecondaryContacts.find(
(latestCommittedNode) => {
return (
Expand Down
16 changes: 16 additions & 0 deletions app/tests/unit/components/Form/ProjectContactFormSummary.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 55b11c2

Please sign in to comment.