feat: migrate setup visibility from boolean to three-tier system
Replace isPublic boolean with visibility enum (private/link/public) across the full stack. Add shares table to schema for future share link support. Update all services, routes, schemas, hooks, components, and tests. Plan: 32-01 (Setup Sharing System - Schema Migration) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -74,7 +74,7 @@ describe("Profile Service", () => {
|
||||
// Create one public and one private setup
|
||||
const _pub = await createSetup(db, userId, {
|
||||
name: "Public Setup",
|
||||
isPublic: true,
|
||||
visibility: "public",
|
||||
});
|
||||
const _priv = await createSetup(db, userId, { name: "Private Setup" });
|
||||
|
||||
@@ -91,10 +91,10 @@ describe("Profile Service", () => {
|
||||
});
|
||||
|
||||
describe("getPublicSetupWithItems", () => {
|
||||
it("returns setup with items when isPublic is true", async () => {
|
||||
it("returns setup with items when visibility is public", async () => {
|
||||
const setup = await createSetup(db, userId, {
|
||||
name: "Public Setup",
|
||||
isPublic: true,
|
||||
visibility: "public",
|
||||
});
|
||||
|
||||
// Create an item and add to setup
|
||||
@@ -125,7 +125,7 @@ describe("Profile Service", () => {
|
||||
expect(result!.items[0].name).toBe("Tent");
|
||||
});
|
||||
|
||||
it("returns null when isPublic is false", async () => {
|
||||
it("returns null when visibility is private", async () => {
|
||||
const setup = await createSetup(db, userId, {
|
||||
name: "Private Setup",
|
||||
});
|
||||
@@ -140,7 +140,7 @@ describe("Profile Service", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("Setup Service - isPublic", () => {
|
||||
describe("Setup Service - visibility", () => {
|
||||
let db: Db;
|
||||
let userId: number;
|
||||
|
||||
@@ -150,33 +150,33 @@ describe("Setup Service - isPublic", () => {
|
||||
userId = testData.userId;
|
||||
});
|
||||
|
||||
it("createSetup persists isPublic when true", async () => {
|
||||
it("createSetup persists visibility when public", async () => {
|
||||
const setup = await createSetup(db, userId, {
|
||||
name: "Public",
|
||||
isPublic: true,
|
||||
visibility: "public",
|
||||
});
|
||||
expect(setup.isPublic).toBe(true);
|
||||
expect(setup.visibility).toBe("public");
|
||||
});
|
||||
|
||||
it("createSetup defaults isPublic to false", async () => {
|
||||
it("createSetup defaults visibility to private", async () => {
|
||||
const setup = await createSetup(db, userId, { name: "Private" });
|
||||
expect(setup.isPublic).toBe(false);
|
||||
expect(setup.visibility).toBe("private");
|
||||
});
|
||||
|
||||
it("updateSetup can toggle isPublic", async () => {
|
||||
it("updateSetup can change visibility", async () => {
|
||||
const setup = await createSetup(db, userId, { name: "Test" });
|
||||
expect(setup.isPublic).toBe(false);
|
||||
expect(setup.visibility).toBe("private");
|
||||
|
||||
const updated = await updateSetup(db, userId, setup.id, {
|
||||
name: "Test",
|
||||
isPublic: true,
|
||||
visibility: "public",
|
||||
});
|
||||
expect(updated).not.toBeNull();
|
||||
expect(updated!.isPublic).toBe(true);
|
||||
expect(updated!.visibility).toBe("public");
|
||||
});
|
||||
|
||||
it("getAllSetups includes isPublic in response", async () => {
|
||||
await createSetup(db, userId, { name: "Public", isPublic: true });
|
||||
it("getAllSetups includes visibility in response", async () => {
|
||||
await createSetup(db, userId, { name: "Public", visibility: "public" });
|
||||
await createSetup(db, userId, { name: "Private" });
|
||||
|
||||
const setups = await getAllSetups(db, userId);
|
||||
@@ -184,17 +184,17 @@ describe("Setup Service - isPublic", () => {
|
||||
|
||||
const pub = setups.find((s) => s.name === "Public");
|
||||
const priv = setups.find((s) => s.name === "Private");
|
||||
expect(pub!.isPublic).toBe(true);
|
||||
expect(priv!.isPublic).toBe(false);
|
||||
expect(pub!.visibility).toBe("public");
|
||||
expect(priv!.visibility).toBe("private");
|
||||
});
|
||||
|
||||
it("getSetupWithItems includes isPublic", async () => {
|
||||
it("getSetupWithItems includes visibility", async () => {
|
||||
const setup = await createSetup(db, userId, {
|
||||
name: "Test",
|
||||
isPublic: true,
|
||||
visibility: "public",
|
||||
});
|
||||
const result = await getSetupWithItems(db, userId, setup.id);
|
||||
expect(result).not.toBeNull();
|
||||
expect(result!.isPublic).toBe(true);
|
||||
expect(result!.visibility).toBe("public");
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user