mirror of
https://github.com/snapotter-hq/SnapOtter.git
synced 2026-08-03 07:46:42 +02:00
Server stops phoning Sentry home after opt-out (release-health sessions + client reports off); settings saves diff-send only changed keys so a stale tab cannot revert an instance-wide opt-out; disabling analytics hides the feedback UI immediately; optIn resumes PostHog after re-enable; onboarding survey writes time out at 15s; inline tool-feedback prompt arms a shown-cooldown.
41 lines
1.7 KiB
TypeScript
41 lines
1.7 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { changedSettings, writableSettings } from "@/lib/settings-payload";
|
|
|
|
describe("writableSettings", () => {
|
|
it("strips server-managed read-only keys that the PUT rejects", () => {
|
|
expect(
|
|
writableSettings({ instance_id: "abc", cookie_secret: "shh", defaultTheme: "dark" }),
|
|
).toEqual({ defaultTheme: "dark" });
|
|
});
|
|
|
|
it("strips masked secret placeholders so a real secret is never overwritten by the mask", () => {
|
|
expect(writableSettings({ oidc_client_secret: "********", fileUploadLimitMb: "100" })).toEqual({
|
|
fileUploadLimitMb: "100",
|
|
});
|
|
});
|
|
});
|
|
|
|
describe("changedSettings", () => {
|
|
it("returns only keys whose value differs from the original snapshot", () => {
|
|
const original = { analyticsEnabled: "true", defaultTheme: "system" };
|
|
const current = { analyticsEnabled: "true", defaultTheme: "dark" };
|
|
expect(changedSettings(original, current)).toEqual({ defaultTheme: "dark" });
|
|
});
|
|
|
|
it("omits an unchanged analyticsEnabled so a stale save cannot revert an instance-wide opt-out", () => {
|
|
const original = { analyticsEnabled: "true", fileUploadLimitMb: "100" };
|
|
const current = { analyticsEnabled: "true", fileUploadLimitMb: "250" };
|
|
expect("analyticsEnabled" in changedSettings(original, current)).toBe(false);
|
|
});
|
|
|
|
it("includes a key the user actually toggled", () => {
|
|
expect(changedSettings({ analyticsEnabled: "true" }, { analyticsEnabled: "false" })).toEqual({
|
|
analyticsEnabled: "false",
|
|
});
|
|
});
|
|
|
|
it("includes keys added since the snapshot was taken", () => {
|
|
expect(changedSettings({}, { defaultLocale: "fr" })).toEqual({ defaultLocale: "fr" });
|
|
});
|
|
});
|