Files
kandev/apps/web/lib/state/slices/features/features-slice.test.ts
T
José Almeida 9c16d337a2 feat(web): add global app status surface (#1869)
* feat(web): add app status bar

* feat(web): add app status bar visibility toggle

* feat(web): persist status bar item order

* fix(web): refine app status bar behavior

* fix(web): polish app status bar presentation

* test(web): split plugin slot coverage groups

* fix(web): address status surface review feedback

* fix(web): stabilize status bar overlay tests
2026-07-23 12:28:54 +01:00

40 lines
1.7 KiB
TypeScript

import { describe, expect, it } from "vitest";
import { create } from "zustand";
import { immer } from "zustand/middleware/immer";
import { createFeaturesSlice, defaultFeaturesState } from "./features-slice";
import type { FeaturesSlice } from "./types";
function makeStore() {
return create<FeaturesSlice>()(
// eslint-disable-next-line @typescript-eslint/no-explicit-any
immer((...a) => ({ ...(createFeaturesSlice as any)(...a) })),
);
}
describe("features slice", () => {
// Production-safety invariant: every flag must be false out of the box.
// If this test starts failing because a new flag was added defaulting to
// true, that is the bug — fix the default, not the test.
it("defaults every flag to false", () => {
const store = makeStore();
for (const [name, value] of Object.entries(defaultFeaturesState.features)) {
expect(value, `default of features.${name}`).toBe(false);
}
expect(store.getState().features.office).toBe(false);
expect(store.getState().features.plugins).toBe(false);
expect(defaultFeaturesState.features).toHaveProperty("appStatusBar", false);
});
it("setFeatures replaces the whole flag map", () => {
const store = makeStore();
store.getState().setFeatures({ office: true, plugins: true, appStatusBar: true });
expect(store.getState().features.office).toBe(true);
expect(store.getState().features.plugins).toBe(true);
expect(store.getState().features.appStatusBar).toBe(true);
store.getState().setFeatures({ office: false, plugins: false, appStatusBar: false });
expect(store.getState().features.office).toBe(false);
expect(store.getState().features.plugins).toBe(false);
expect(store.getState().features.appStatusBar).toBe(false);
});
});