Pin the theme settings as account-level, not per-browser
Both `theme` and `lastDarkTheme` sync, so a theme chosen on one machine -- and the toggle's way back to it -- are the same everywhere. That is already true, by the rule that DEVICE_KEYS is a list of exceptions and anything else syncs by default, but nothing said so. The existing test cannot say it: it derives what should sync from DEVICE_KEYS, so moving one of these into that list would move the expectation with it and still pass. These name the two keys outright.
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
import { describe, expect, it } from "vitest";
|
import { describe, expect, it } from "vitest";
|
||||||
import { DEFAULT_SETTINGS, isDarkTheme, toggleTarget, useSettings, type Theme } from "@/store/settings";
|
import { DEFAULT_SETTINGS, DEVICE_KEYS, acceptRemote, isDarkTheme, syncedPart, toggleTarget, useSettings, type Theme } from "@/store/settings";
|
||||||
import { loadJson, saveJson } from "@/lib/storage";
|
import { loadJson, saveJson } from "@/lib/storage";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -144,3 +144,22 @@ describe("remembering which dark theme you were on", () => {
|
|||||||
expect(back.theme).toBe("ihasmail");
|
expect(back.theme).toBe("ihasmail");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe("where the theme settings live", () => {
|
||||||
|
it("follows the account, not the browser", () => {
|
||||||
|
// Both of these ride in the account's settings.json, so a theme chosen on
|
||||||
|
// one machine — and the toggle's way back to it — are the same everywhere.
|
||||||
|
// Named explicitly rather than derived from DEVICE_KEYS: the test that
|
||||||
|
// does derive it would still pass if one of these were moved there, since
|
||||||
|
// its expectation would move too.
|
||||||
|
const synced = syncedPart(DEFAULT_SETTINGS);
|
||||||
|
expect(synced).toHaveProperty("theme");
|
||||||
|
expect(synced).toHaveProperty("lastDarkTheme");
|
||||||
|
expect(DEVICE_KEYS.has("theme")).toBe(false);
|
||||||
|
expect(DEVICE_KEYS.has("lastDarkTheme")).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("is applied from a settings file another device wrote", () => {
|
||||||
|
expect(acceptRemote({ theme: "dark", lastDarkTheme: "dark" })).toEqual({ theme: "dark", lastDarkTheme: "dark" });
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user