Files
Piik/tests/creation-profile.test.ts
AAA 1332473513 feat: rename product and runtime to Piik
Rename the active product, Go module, binaries, configuration, protocols and documentation to Piik while retaining the TV mascot and existing media/room behavior.

Use one current private contract without old-name aliases. Preserve SQLite authority and copy compatible local settings once; other settings start fresh. Git-message cleanup and the infrastructure name cutover are coordinated with this phase, with original history and deployment data archived externally.

Validated locally with Web and Go checks, Windows capture compilation, matched Client/Server builds, packaged Client control handshake and history-rewrite integrity checks. Skip duplicate hosted CI for this owner-authorized local release.

[skip ci]
2026-09-10 11:10:12 +08:00

71 lines
1.8 KiB
TypeScript

import { afterEach, describe, expect, it, vi } from "vitest";
import {
readCreationProfile,
saveCreationProfile,
} from "../src/client/lib/creation-profile.ts";
describe("Host creation profile", () => {
afterEach(() => {
vi.unstubAllGlobals();
});
it("defaults to open code entry without a room password", () => {
vi.stubGlobal("window", {
localStorage: { getItem: () => null },
});
expect(readCreationProfile()).toEqual({
codeEntryPolicy: "open",
roomPassword: null,
});
});
it("persists the accepted creation preferences in same-origin storage", () => {
const values = new Map<string, string>();
vi.stubGlobal("window", {
localStorage: {
getItem: (key: string) => values.get(key) ?? null,
setItem: (key: string, value: string) => values.set(key, value),
removeItem: (key: string) => values.delete(key),
},
});
saveCreationProfile({
codeEntryPolicy: "private",
roomPassword: "room-password",
});
expect(readCreationProfile()).toEqual({
codeEntryPolicy: "private",
roomPassword: "room-password",
});
expect(values.get("piik:host-creation-profile:v1")).not.toContain(
"SITE_ACCESS_PASSWORD",
);
saveCreationProfile({ codeEntryPolicy: "private", roomPassword: null });
expect(readCreationProfile()).toEqual({
codeEntryPolicy: "private",
roomPassword: null,
});
});
it("discards removed policy records", () => {
const removeItem = vi.fn();
vi.stubGlobal("window", {
localStorage: {
getItem: () =>
JSON.stringify({ codeEntryPolicy: "password", roomPassword: null }),
removeItem,
},
});
expect(readCreationProfile()).toEqual({
codeEntryPolicy: "open",
roomPassword: null,
});
expect(removeItem).toHaveBeenCalledOnce();
});
});