From c982db1684865a00bff1bae46bb3daf155aab757 Mon Sep 17 00:00:00 2001 From: Jess Eldredge Date: Thu, 19 Dec 2024 16:59:19 -0500 Subject: [PATCH] bugfix: display WP topic on the export page --- ...ExportedModalOverlayReportSection.test.tsx | 4 +-- .../ExportedModalOverlayReportSection.tsx | 5 +-- .../ui-src/src/utils/testing/mockReport.ts | 33 +++++++------------ 3 files changed, 17 insertions(+), 25 deletions(-) diff --git a/services/ui-src/src/components/export/ExportedModalOverlayReportSection.test.tsx b/services/ui-src/src/components/export/ExportedModalOverlayReportSection.test.tsx index 725da4b56..ff0f2fa3e 100644 --- a/services/ui-src/src/components/export/ExportedModalOverlayReportSection.test.tsx +++ b/services/ui-src/src/components/export/ExportedModalOverlayReportSection.test.tsx @@ -6,7 +6,6 @@ import { } from "utils/testing/setupJest"; import { mockSARReportWithOverlays, - mockWPReportWithOtherTypeOverlays, mockWPReportWithOverlays, } from "utils/testing/mockReport"; import { @@ -336,9 +335,10 @@ describe("", () => { test("should render correct initiative topic", () => { mockedUseStore.mockReturnValue({ ...mockReportStore, - report: mockWPReportWithOtherTypeOverlays, + report: mockWPReportWithOverlays, }); render(testComponent(wpMockProps)); + expect(screen.getByText("mock WP topic")).toBeInTheDocument(); expect(screen.getByText("Unique initiative type")).toBeInTheDocument(); }); diff --git a/services/ui-src/src/components/export/ExportedModalOverlayReportSection.tsx b/services/ui-src/src/components/export/ExportedModalOverlayReportSection.tsx index 09e071fb7..1e30e3d3c 100644 --- a/services/ui-src/src/components/export/ExportedModalOverlayReportSection.tsx +++ b/services/ui-src/src/components/export/ExportedModalOverlayReportSection.tsx @@ -164,8 +164,9 @@ export function renderModalOverlayTableBody( {`${idx + 1}. ${entity.initiative_name}` ?? "Not entered"} - {entity.initiative_wp_otherTopic ?? - entity.initiative_wpTopic[0].value} + {entity.initiative_wp_otherTopic + ? entity.initiative_wp_otherTopic + : entity.initiative_wpTopic[0].value} diff --git a/services/ui-src/src/utils/testing/mockReport.ts b/services/ui-src/src/utils/testing/mockReport.ts index a75664bd0..d3130eff8 100644 --- a/services/ui-src/src/utils/testing/mockReport.ts +++ b/services/ui-src/src/utils/testing/mockReport.ts @@ -496,6 +496,18 @@ export const mockWPReportWithOverlays = { }, ], }, + { + ...mockWPFullReport.fieldData.entityType[0], + type: OverlayModalTypes.INITIATIVE, + id: "mock wip id", + initiative_wpTopic: [ + { + key: "other-type-key", + value: "Other, specify", + }, + ], + initiative_wp_otherTopic: "Unique initiative type", + }, ], }, formTemplate: { @@ -520,27 +532,6 @@ export const mockWPReportWithOverlays = { }, }; -export const mockWPReportWithOtherTypeOverlays = { - ...mockWPFullReport, - fieldData: { - ...mockWPFullReport.fieldData, - [OverlayModalTypes.INITIATIVE]: [ - { - ...mockWPFullReport.fieldData.entityType[0], - type: OverlayModalTypes.INITIATIVE, - id: "mock wip id", - initiative_wpTopic: [ - { - key: "other-type-key", - value: "Other, specify", - }, - ], - initiative_wp_otherTopic: "Unique initiative type", - }, - ], - }, -}; - export const mockSARReportWithOverlays = { ...mockSARFullReport, fieldData: {