Clear leftover setup answers on template paths that skip those questions, and treat Continue as an edit so restored ticks are not overwritten.

This commit is contained in:
adilallo committed 2026-11-05 21:02:04 -07:00
1 parent bdaf1818d9
commit cec83eb27f
3 files changed
+43 -4

No files matched your search

@@ -91,6 +91,7 @@ describe("useTemplateReviewActions", () => {
title: "Neighborhood",
communityContext: "Stale description",
currentStep: "confirm-stakeholders",
setupTraits: { employer: true, network: false },
});
},
);
@@ -104,6 +105,7 @@ describe("useTemplateReviewActions", () => {
expect(applied?.title).toBeUndefined();
expect(applied?.communityContext).toBeUndefined();
expect(applied?.currentStep).toBeUndefined();
expect(applied?.setupTraits).toBeUndefined();
expect(applied?.pendingTemplateAction?.mode).toBe("useWithoutChanges");
});
@@ -114,6 +116,7 @@ describe("useTemplateReviewActions", () => {
title: "Neighborhood",
communityContext: "We meet weekly",
templateReviewEntryFromCreateFlow: true,
setupTraits: { employer: true },
});
},
);
@@ -129,7 +132,38 @@ describe("useTemplateReviewActions", () => {
expect(router.push).toHaveBeenCalledWith("/create/confirm-stakeholders");
expect(applied?.title).toBe("Neighborhood");
expect(applied?.communityContext).toBe("We meet weekly");
expect(applied?.setupTraits).toEqual({ employer: true });
expect(applied?.pendingTemplateAction).toBeUndefined();
expect(applied?.templateReviewBackSlug).toBe("mutual-aid-mondays");
});
it("customize with a community name drops leftover setup answers", async () => {
const { result } = renderActions({
title: "Neighborhood",
setupTraits: { employer: true },
});
await act(async () => {
await result.current.handleCustomize();
});
expect(router.push).toHaveBeenCalledWith("/create/core-values");
expect(updateState).toHaveBeenCalledWith(
expect.objectContaining({ setupTraits: undefined }),
);
});
it("customize without a community name leaves setup answers for the questionnaire", async () => {
const { result } = renderActions({
setupTraits: { employer: true },
});
await act(async () => {
await result.current.handleCustomize();
});
expect(router.push).toHaveBeenCalledWith("/create/informational");
const patch = updateState.mock.calls[0]?.[0] as CreateFlowState;
expect(patch).not.toHaveProperty("setupTraits");
});
});