feat(dashboard): default to Analytics tab; fix(test): unbreak jsdom localStorage under Node 22+

Dashboard now opens on the Analytics tab for first-time visitors (localStorage
still wins once a user picks a tab). Also unbreaks the client test suite in
this environment: Node 22+'s built-in --experimental-webstorage localStorage
stub was shadowing jsdom's working one, failing every test that touches
localStorage. Disabled via a Node-major-gated poolOptions.forks.execArgv so
Node 20/21 test runs are unaffected.
This commit is contained in:
2026-08-25 13:34:42 +07:00
parent 8ce20e8163
commit 03a178a718
3 changed files with 2026 additions and 272 deletions
+1 -1
View File
@@ -2330,7 +2330,7 @@ export function Dashboard() {
// Persistent Tab State
const [activeTab, setActiveTab] = useState<"monitor" | "analytics" | "health">(() => {
return (
(localStorage.getItem("dashboard_tab") as "monitor" | "analytics" | "health") || "monitor"
(localStorage.getItem("dashboard_tab") as "monitor" | "analytics" | "health") || "analytics"
);
});
File diff suppressed because it is too large Load Diff
+16
View File
@@ -25,6 +25,14 @@ function resolveAppVersion(): string {
}
const APP_VERSION = resolveAppVersion();
// Node >=22 ships a built-in `localStorage` global (Web Storage API) that, without
// a configured `--localstorage-file`, is a non-functional stub (getItem/setItem
// undefined) — it shadows jsdom's own working localStorage before the jsdom
// environment can install it. Disabling it on those Node versions lets jsdom's
// localStorage apply instead; the flag doesn't exist on Node 20/21, so it's
// gated to avoid breaking test runs there.
const nodeMajor = Number(process.versions.node.split(".")[0]);
export default defineConfig({
plugins: [react()],
define: {
@@ -32,6 +40,14 @@ export default defineConfig({
},
test: {
environment: "jsdom",
environmentOptions: {
jsdom: {
url: "http://localhost/",
},
},
...(nodeMajor >= 22
? { poolOptions: { forks: { execArgv: ["--no-experimental-webstorage"] } } }
: {}),
setupFiles: ["./src/test-setup.ts"],
include: ["src/**/*.test.{ts,tsx}"],
css: false,