diff --git a/src/app/request-accepted/request-accepted-client.test.tsx b/src/app/request-accepted/request-accepted-client.test.tsx index 14b97a2..c771b4b 100644 --- a/src/app/request-accepted/request-accepted-client.test.tsx +++ b/src/app/request-accepted/request-accepted-client.test.tsx @@ -339,4 +339,77 @@ describe("RequestAcceptedClient", () => { expect(screen.queryByText(/acquaintance concluded/i)).not.toBeInTheDocument(); expect(sessionStorage.getItem("recent_declined_outcome")).toBeNull(); }); + + it("handles female confirming 'Contact Received', invokes mutation with contacted action, and transitions cleanly to outcome reporting state", async () => { + mockContactStatusMutateAsync.mockResolvedValueOnce({ success: true }); + + mockProfileState.data = { + id: 2, + gender: "female", + is_registering_for_self: true, + status: "in_case", + active_case: { + case_id: 45, + status: "female_accepted", + has_outcome_reported: false, + }, + }; + + render(); + + // Click "Contact Received" button + const contactReceivedBtn = screen.getByRole("button", { + name: "Contact Received", + }); + expect(contactReceivedBtn).toBeInTheDocument(); + await userEvent.click(contactReceivedBtn); + + // Confirmation modal should appear + expect( + screen.getByText("Are you sure contact has been made?"), + ).toBeInTheDocument(); + + // Confirm button in the modal + const confirmBtn = screen.getByRole("button", { name: "Confirm" }); + await userEvent.click(confirmBtn); + + // Mutation should have been called with action: 'contacted' + expect(mockContactStatusMutateAsync).toHaveBeenCalledWith({ + action: "contacted", + custom_note: "Contact received confirmed by female candidate", + }); + + // Modal should be closed and outcome state should be rendered + expect( + screen.queryByText("Are you sure contact has been made?"), + ).not.toBeInTheDocument(); + expect(screen.getByText("Share Result")).toBeInTheDocument(); + }); + + it("persists 'Acquaintance Concluded' across reload when active_case has has_outcome_reported: true in post-contact stage", () => { + mockProfileState.data = { + id: 2, + gender: "female", + is_registering_for_self: true, + status: "in_case", + active_case: { + case_id: 45, + status: "contacted", + has_outcome_reported: true, + outcome_reason: "personal_withdrawal", + }, + }; + + render(); + + expect(screen.getByText(/acquaintance concluded/i)).toBeInTheDocument(); + expect( + screen.getByText( + "This acquaintance has not reached a conclusion and the process has been stopped. Please contact support for information on the next steps.", + ), + ).toBeInTheDocument(); + expect(screen.getByText("Contact Support")).toBeInTheDocument(); + expect(screen.getByText("View all detail")).toBeInTheDocument(); + expect(screen.queryByText("Share Result")).not.toBeInTheDocument(); + }); }); diff --git a/src/app/request-accepted/request-accepted-client.tsx b/src/app/request-accepted/request-accepted-client.tsx index e10a48c..521c48a 100644 --- a/src/app/request-accepted/request-accepted-client.tsx +++ b/src/app/request-accepted/request-accepted-client.tsx @@ -628,6 +628,7 @@ export default function RequestAcceptedClient() { "Contact received confirmed by female candidate", }); setHasConfirmedFemaleContact(true); + await refetchProfile(); setIsContactReceivedConfirmOpen(false); } catch (error) { console.error("Unable to persist received contact", error); @@ -756,6 +757,7 @@ export default function RequestAcceptedClient() { onSuccess={async () => { try { await handleNoContactReport(); + await refetchProfile(); setIsNoContactConfirmOpen(false); } catch (err) { console.error("Failed to report no contact", err); @@ -825,36 +827,30 @@ export default function RequestAcceptedClient() { }

- ) : caseStatus === "contacted" || - isFemaleContactConfirmed || - (isFemaleProfile && contactStatusMutation.isPending) ? ( + ) : caseStatus === "contacted" || isFemaleContactConfirmed ? (
- {isFemaleProfile && contactStatusMutation.isPending ? ( - - ) : ( -

- {isFemaleProfile ? ( - t[ - "Thank you for your feedback. To complete the process, please submit the final outcome of this introduction/contact so that the final status can be determined. If the final status is not yet determined, you can stay in this state until it is finalized." - ] - ) : ( - <> - {t[ - "Thank you for giving us feedback, we would be very happy if you also let us know the final result." - ]} - {!canReportOutcome && ( - <> - {" "} - {t[ - "The 'Share Result' option will become active after 48 hours." - ] || - "The 'Share Result' option will become active after 48 hours."} - - )} - - )} -

- )} +

+ {isFemaleProfile ? ( + t[ + "Thank you for your feedback. To complete the process, please submit the final outcome of this introduction/contact so that the final status can be determined. If the final status is not yet determined, you can stay in this state until it is finalized." + ] + ) : ( + <> + {t[ + "Thank you for giving us feedback, we would be very happy if you also let us know the final result." + ]} + {!canReportOutcome && ( + <> + {" "} + {t[ + "The 'Share Result' option will become active after 48 hours." + ] || + "The 'Share Result' option will become active after 48 hours."} + + )} + + )} +

) : noContactReportedSuccess ? (

@@ -896,56 +892,49 @@ export default function RequestAcceptedClient() { {t["Contact Support"] || "Contact Support"} - ) : caseStatus === "contacted" || - isFemaleContactConfirmed || - (isFemaleProfile && contactStatusMutation.isPending) ? ( + ) : caseStatus === "contacted" || isFemaleContactConfirmed ? (

- {isFemaleProfile && - contactStatusMutation.isPending ? null : ( - <> - + - - - )} +
) : noContactReportedSuccess ? (
@@ -1009,11 +998,7 @@ export default function RequestAcceptedClient() { : "border-[#E2E8F0] bg-white/95 backdrop-blur-sm text-[#475569] shadow-sm cursor-pointer hover:bg-[#F8FAFC] active:scale-[0.98]" }`} > - {contactStatusMutation.isPending ? ( - - ) : ( - primaryActionText - )} + {primaryActionText} ) : (