Keep the photo a community already uploaded when they pick a template from the wizard.

This commit is contained in:
adilallo committed 2026-11-24 21:11:40 -07:00
1 parent 6bf890fa78
commit 5dc936834c
6 files changed
+58 -17

No files matched your search

+22
View File
@@ -248,6 +248,28 @@ describe("buildAppliedTemplateCreateFlowState", () => {
mode: "useWithoutChanges",
});
});
it("keeps an in-flow photo when identity includes it", () => {
const seeded = buildAppliedTemplateCreateFlowState({
slug: "mutual-aid-mondays",
body: {
sections: [
{
categoryName: "Communication",
entries: [{ title: "Signal" }],
},
],
},
mode: "useWithoutChanges",
identity: {
title: "Neighborhood",
communityAvatarUrl: " /api/uploads/logo ",
},
});
expect(seeded.title).toBe("Neighborhood");
expect(seeded.communityAvatarUrl).toBe("/api/uploads/logo");
expect(seeded.templateReviewEntryFromCreateFlow).toBe(true);
});
});
describe("templatePresetDetailsFromPrefill", () => {
@@ -145,12 +145,13 @@ describe("useTemplateReviewActions", () => {
});
});
it("in-flow Use without changes keeps the community name and pins the template path", async () => {
it("in-flow Use without changes keeps the community name, photo, and pins the template path", async () => {
const { result } = renderActions(
{
title: "Neighborhood",
communityContext: "We meet weekly",
templateReviewEntryFromCreateFlow: true,
communityLocation: "Oakland",
communityAvatarUrl: "/api/uploads/logo",
},
true,
);
@@ -162,6 +163,8 @@ describe("useTemplateReviewActions", () => {
expect(router.push).toHaveBeenCalledWith("/create/community-name");
expect(applied?.title).toBe("Neighborhood");
expect(applied?.communityContext).toBe("We meet weekly");
expect(applied?.communityLocation).toBe("Oakland");
expect(applied?.communityAvatarUrl).toBe("/api/uploads/logo");
expect(applied?.setupTraits).toBeUndefined();
expect(applied?.pendingTemplateAction).toEqual({
slug: "mutual-aid-mondays",
@@ -170,6 +173,24 @@ describe("useTemplateReviewActions", () => {
expect(applied?.templateReviewBackSlug).toBe("mutual-aid-mondays");
});
it("a persisted in-flow flag without ?fromFlow=1 clears leftover identity", async () => {
const { result } = renderActions(
{
title: "Neighborhood",
communityAvatarUrl: "/api/uploads/logo",
templateReviewEntryFromCreateFlow: true,
},
false,
);
await act(async () => {
await result.current.handleUseWithoutChanges();
});
expect(applied?.title).toBeUndefined();
expect(applied?.communityAvatarUrl).toBeUndefined();
});
it("asks before replacing a draft in progress", async () => {
requestConfirm.mockResolvedValueOnce(false);
const { result } = renderActions({ title: "Juniper Street Tenants" });