fix: address onboarding review feedback

This commit is contained in:
Thomas Camlong authored and ajnart committed 2026-08-14 11:32:12 +02:00
1 parent dc71084323
commit 2566be2838
72 files changed
+7783 -280

No files matched your search

@@ -288,6 +288,20 @@ describe("getAllBoards should return all boards accessable to the current user",
});
describe("getManageOverview", () => {
test("does not expose a public board creator email to anonymous callers", async () => {
const db = createDb();
const caller = boardRouter.createCaller({ db, deviceType: undefined, session: null });
const creatorId = createId();
await db.insert(users).values({ id: creatorId, name: "Board creator", email: "private@example.com" });
await db.insert(boards).values({ id: createId(), name: "public-overview", creatorId, isPublic: true });
const [board] = await caller.getManageOverview();
expect(board?.creator).toEqual({ id: creatorId, name: "Board creator", image: null });
expect(board?.creator).not.toHaveProperty("email");
});
test("returns the same accessible board set as getAllBoards", async () => {
const db = createDb();
const caller = boardRouter.createCaller({ db, deviceType: undefined, session: defaultSession });
@@ -433,6 +447,8 @@ describe("getManageOverview", () => {
const result = await caller.getManageOverview();
expect(result).toHaveLength(1);
expect(result[0]?.creator).toEqual({ id: defaultCreatorId, name: null, image: null });
expect(result[0]?.creator).not.toHaveProperty("email");
expect(result[0]).toMatchObject({
id: boardId,
isHome: true,
@@ -43,6 +43,8 @@ vi.mock("@homarr/common", async (importOriginal) => ({
createId: createIdMock,
}));
vi.mock("@homarr/docker", () => ({
createDockerSourceId: (host: string, externalId: string) =>
`docker:${encodeURIComponent(host)}:${encodeURIComponent(externalId)}`,
dockerLabels: { hide: "homarr.hide" },
listDiscoveredContainersAsync,
}));
@@ -267,6 +269,20 @@ describe("onboard.completeSetup", () => {
expect(await db.query.onboarding.findFirst()).toMatchObject({ step: "setup", previousStep: "group" });
});
it("rejects an explicit board id that no longer exists", async () => {
const db = createDb();
const claimToken = await seedOnboardingAsync(db);
await seedBoardAsync(db, { boardId: "target" });
await expect(createCaller(db, claimToken).completeSetup(completionInput("missing"))).rejects.toMatchObject({
code: "NOT_FOUND",
message: "The selected board no longer exists.",
});
expect(await db.query.boards.findFirst({ where: eq(boards.id, "target") })).toMatchObject({ name: "target" });
expect(await db.query.onboarding.findFirst()).toMatchObject({ step: "setup", previousStep: "group" });
});
it("rejects a board rename that only differs by case from another board", async () => {
const db = createDb();
const claimToken = await seedOnboardingAsync(db);
@@ -899,6 +915,7 @@ describe("onboard.completeSetup", () => {
for (const layoutId of ["target-base", "target-mobile"]) {
const positions = groupedLayouts.filter((layout) => layout.layoutId === layoutId);
const containerLayout = containerLayouts.find((layout) => layout.layoutId === layoutId);
expect(positions.length).toBeGreaterThan(0);
expect(containerLayout).toBeDefined();
expect(Math.max(...positions.map((position) => position.yOffset + position.height))).toBeLessThanOrEqual(
containerLayout?.height ?? 0,
@@ -77,6 +77,8 @@ describe("onboarding claim", () => {
expect(
getOnboardingClaimTokenFromCookieHeader(`theme=dark; ${onboardingClaimCookieName}=secret-token; other=x`),
).toBe("secret-token");
expect(getOnboardingClaimTokenFromCookieHeader(`${onboardingClaimCookieName}=secret%2Dtoken`)).toBe("secret-token");
expect(getOnboardingClaimTokenFromCookieHeader(`${onboardingClaimCookieName}=%E0%A4%A`)).toBeUndefined();
expect(getOnboardingClaimTokenFromCookieHeader(`${onboardingClaimCookieName}-copy=wrong`)).toBeUndefined();
});
});