During onboarding (and for a chosen person without usable birth data) the desktop panel opened by default and showed only the no-birth-data line. The panel and its top-bar button now render only when homeChartShown(): onboarding finished, the person's birth data complete, the first-chart reveal over. Owner 2026-11-24 reversed BUG-2201's folded newcomer default: the newcomer fold (useStarterChartFold, starter_chart_details_open) is removed and the regular panel state (open unless closed) applies. Phone shows the button only. Beside the panel the starter cards stack when the column is narrower than 640px. The empty-state line now names 星盘档案. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DbBXp2Vp62Ur3C7yRWQdSq
87 lines
3.3 KiB
TypeScript
87 lines
3.3 KiB
TypeScript
import "./install-test-document";
|
|
import assert from "node:assert/strict";
|
|
import test from "node:test";
|
|
import { useEffect } from "react";
|
|
|
|
import { ChatChartFrame } from "../src/components/chat-chart-frame.tsx";
|
|
import { ShellFrame } from "../src/components/shell-frame.tsx";
|
|
import { SidebarProvider } from "../src/components/ui/sidebar.tsx";
|
|
import { useUiStore } from "../src/stores/ui-store.ts";
|
|
import { createClientLifecycleHarness } from "./react-client-lifecycle-test-support.ts";
|
|
|
|
function watchMount(record: { mount: number; unmount: number }) {
|
|
record.mount += 1;
|
|
return () => {
|
|
record.unmount += 1;
|
|
};
|
|
}
|
|
|
|
function Probe({ record }: { record: { mount: number; unmount: number } }) {
|
|
useEffect(() => watchMount(record), [record]);
|
|
return <span>probe</span>;
|
|
}
|
|
|
|
function listenForResize(win: Window) {
|
|
const buckets = new Map<string, Set<EventListener>>();
|
|
win.addEventListener = ((type: string, listener: EventListener) => {
|
|
const set = buckets.get(type) ?? new Set<EventListener>();
|
|
set.add(listener);
|
|
buckets.set(type, set);
|
|
}) as Window["addEventListener"];
|
|
win.removeEventListener = ((type: string, listener: EventListener) => {
|
|
buckets.get(type)?.delete(listener);
|
|
}) as Window["removeEventListener"];
|
|
win.dispatchEvent = ((event: Event) => {
|
|
for (const listener of buckets.get(event.type) ?? []) listener(event);
|
|
return true;
|
|
}) as Window["dispatchEvent"];
|
|
}
|
|
|
|
test("the shell and the chat column stay mounted when the desktop split arrives", async () => {
|
|
const sidebar = { mount: 0, unmount: 0 };
|
|
const column = { mount: 0, unmount: 0 };
|
|
const harness = createClientLifecycleHarness();
|
|
listenForResize(globalThis.window);
|
|
const win = globalThis.window as Window & { innerWidth: number };
|
|
try {
|
|
await harness.render(
|
|
<SidebarProvider>
|
|
<ShellFrame sidebar={<Probe record={sidebar} />}>
|
|
{/* 原值:<ChatChartFrame>;新值:chart 必填;原因:BUG-2307 没有盘时不渲染面板。 */}
|
|
<ChatChartFrame chart>
|
|
<Probe record={column} />
|
|
</ChatChartFrame>
|
|
</ShellFrame>
|
|
</SidebarProvider>,
|
|
);
|
|
await harness.idle();
|
|
assert.equal(sidebar.mount, 1, "sidebar mounted once before the split");
|
|
assert.equal(sidebar.unmount, 0, "sidebar unmounted before the split");
|
|
assert.equal(column.mount, 1, "chat column mounted once before the split");
|
|
assert.equal(column.unmount, 0, "chat column unmounted before the split");
|
|
|
|
await harness.update(() => {
|
|
win.innerWidth = 500;
|
|
win.dispatchEvent(new Event("resize"));
|
|
});
|
|
await harness.idle();
|
|
await harness.update(() => {
|
|
win.innerWidth = 1440;
|
|
win.dispatchEvent(new Event("resize"));
|
|
});
|
|
await harness.idle();
|
|
await harness.update(() => {
|
|
useUiStore.getState().setChatChartOpen(true);
|
|
});
|
|
for (let attempt = 0; attempt < 8; attempt += 1) await harness.idle();
|
|
|
|
assert.equal(sidebar.mount, 1, "sidebar mounted once across the breakpoint");
|
|
assert.equal(sidebar.unmount, 0, "sidebar unmounted across the breakpoint");
|
|
assert.equal(column.mount, 1, "chat column mounted once when the chart split arrived");
|
|
assert.equal(column.unmount, 0, "chat column unmounted when the chart split arrived");
|
|
assert.equal(harness.errors.length, 0, harness.errors.map(String).join("\n"));
|
|
} finally {
|
|
await harness.close();
|
|
}
|
|
});
|