test: harden package boundaries and audit budgets
Quality / quality (windows-latest) (push) Waiting to run
Quality / quality (ubuntu-latest) (push) Failing after 9m52s

This commit is contained in:
2026-08-24 12:05:20 +05:30
parent 613ff7ae5b
commit b3c93e9b18
12 changed files with 115 additions and 17 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@wrnexus/store",
"version": "0.8.11",
"version": "0.8.12",
"type": "module",
"main": "src/index.ts",
"exports": {
@@ -30,3 +30,33 @@ test("memory persistence includes only approved fields and migrates old state",
expect(second.state.theme).toBe("light-v2");
expect(second.state.secret).toBe("initial");
});
test("invalid persisted state fails closed to the store defaults", async () => {
const name = `preferences-validation-${crypto.randomUUID()}`;
const firstDefinition = defineStore({
name,
kind: "global" as const,
createSharedState: () => ({ theme: "dark" }),
persist: { storage: "memory" as const, version: 1, include: ["theme"] },
actions: {
setTheme: {
runtime: "client" as const,
handler: ({ state }: any, theme: string) => void (state.theme = theme),
},
},
});
const first = await new StoreContainer({ runtime: "client" }).use(firstDefinition);
await first.actions.setTheme("corrupt");
const validated = defineStore({
...firstDefinition,
persist: {
storage: "memory" as const,
version: 1,
include: ["theme"],
validate: (value: any) => (value?.theme === "light" ? value : null),
},
});
const second = await new StoreContainer({ runtime: "client" }).use(validated);
expect(second.state.theme).toBe("dark");
});