






















@@ -198,113 +198,66 @@ function renderInto(props: DreamingProps): HTMLDivElement {
198198}
199199200200describe("dreaming view", () => {
201-it("renders the sleeping lobster SVG", () => {
202-const container = renderInto(buildProps());
201+it("renders the active dream scene chrome and status", () => {
202+const container = renderInto(buildProps({ dreamingOf: "reindexing old chats\u2026" }));
203+203204const svg = container.querySelector(".dreams__lobster svg");
204205expect(svg).not.toBeNull();
205-});
206206207-it("shows three floating Z elements", () => {
208-const container = renderInto(buildProps());
209207const zs = container.querySelectorAll(".dreams__z");
210208expect(zs.length).toBe(3);
211-});
212209213-it("renders stars", () => {
214-const container = renderInto(buildProps());
215210const stars = container.querySelectorAll(".dreams__star");
216211expect(stars.length).toBe(12);
217-});
218212219-it("renders moon", () => {
220-const container = renderInto(buildProps());
221213expect(container.querySelector(".dreams__moon")).not.toBeNull();
222-});
223214224-it("displays sleep phase cards", () => {
225-const container = renderInto(buildProps());
226215const phases = [...container.querySelectorAll(".dreams__phase-name")].map((node) =>
227216node.textContent?.trim(),
228217);
229218expect(phases).toEqual(["Light", "Deep", "Rem"]);
230219expect(container.querySelectorAll(".dreams__phase").length).toBe(3);
231220expect(container.querySelector(".dreams__phase--off")?.textContent).toContain("off");
232-});
233-234-it("shows unknown phase status when phase data is unavailable", () => {
235-const container = renderInto(buildProps({ phases: undefined }));
236-const statuses = [...container.querySelectorAll(".dreams__phase-next")].map((node) =>
237-node.textContent?.trim(),
238-);
239-expect(statuses).toEqual(["—", "—", "—"]);
240-expect(container.querySelectorAll(".dreams__phase--off").length).toBe(0);
241-});
242221243-it("keeps maintenance controls out of the scene tab", () => {
244-const container = renderInto(buildProps());
245222const buttons = [...container.querySelectorAll("button")].map((node) =>
246223node.textContent?.trim(),
247224);
248225expect(buttons).not.toContain("Backfill");
249226expect(buttons).not.toContain("Reset");
250227expect(buttons).not.toContain("Clear Replayed");
251-});
252-253-it("shows dream bubble when active", () => {
254-const container = renderInto(buildProps({ active: true }));
255228expect(container.querySelector(".dreams__bubble")).not.toBeNull();
256-});
257-258-it("hides dream bubble when idle", () => {
259-const container = renderInto(buildProps({ active: false }));
260-expect(container.querySelector(".dreams__bubble")).toBeNull();
261-});
262-263-it("shows custom dreamingOf text when provided", () => {
264-const container = renderInto(buildProps({ dreamingOf: "reindexing old chats\u2026" }));
265229const text = container.querySelector(".dreams__bubble-text");
266230expect(text?.textContent).toBe("reindexing old chats\u2026");
267-});
268-269-it("shows active status label when active", () => {
270-const container = renderInto(buildProps({ active: true }));
271231const label = container.querySelector(".dreams__status-label");
272232expect(label?.textContent).toBe("Dreaming Active");
273-});
274-275-it("shows idle status label when inactive", () => {
276-const container = renderInto(buildProps({ active: false }));
277-const label = container.querySelector(".dreams__status-label");
278-expect(label?.textContent).toBe("Dreaming Idle");
279-});
280-281-it("applies idle class when not active", () => {
282-const container = renderInto(buildProps({ active: false }));
283-expect(container.querySelector(".dreams--idle")).not.toBeNull();
284-});
285-286-it("shows next cycle info when provided", () => {
287-const container = renderInto(buildProps({ nextCycle: "4:00 AM" }));
288233const detail = container.querySelector(".dreams__status-detail span");
289234expect(detail?.textContent).toContain("4:00 AM");
290-});
291-292-it("renders control error when present", () => {
293-const container = renderInto(buildProps({ statusError: "patch failed" }));
294-expect(container.querySelector(".dreams__controls-error")?.textContent).toContain(
295-"patch failed",
296-);
297-});
298-299-it("renders sub-tab navigation", () => {
300-const container = renderInto(buildProps());
301235const tabs = container.querySelectorAll(".dreams__tab");
302236expect(tabs.length).toBe(3);
303237expect(tabs[0]?.textContent).toContain("Scene");
304238expect(tabs[1]?.textContent).toContain("Diary");
305239expect(tabs[2]?.textContent).toContain("Advanced");
306240});
307241242+it("renders idle and unavailable scene states", () => {
243+const idleContainer = renderInto(buildProps({ active: false }));
244+expect(idleContainer.querySelector(".dreams__bubble")).toBeNull();
245+expect(idleContainer.querySelector(".dreams__status-label")?.textContent).toBe("Dreaming Idle");
246+expect(idleContainer.querySelector(".dreams--idle")).not.toBeNull();
247+248+const unknownPhaseContainer = renderInto(buildProps({ phases: undefined }));
249+const statuses = [...unknownPhaseContainer.querySelectorAll(".dreams__phase-next")].map(
250+(node) => node.textContent?.trim(),
251+);
252+expect(statuses).toEqual(["—", "—", "—"]);
253+expect(unknownPhaseContainer.querySelectorAll(".dreams__phase--off").length).toBe(0);
254+255+const errorContainer = renderInto(buildProps({ statusError: "patch failed" }));
256+expect(errorContainer.querySelector(".dreams__controls-error")?.textContent).toContain(
257+"patch failed",
258+);
259+});
260+308261it("renders imported memory topics inside the diary tab", () => {
309262setDreamSubTab("diary");
310263setDreamDiarySubTab("insights");
@@ -515,28 +468,20 @@ describe("dreaming view", () => {
515468setDreamSubTab("scene");
516469});
517470518-it("shows empty diary state when no diary content exists", () => {
471+it("renders diary empty, error, and removed-navigation states", () => {
519472setDreamSubTab("diary");
520473setDreamDiarySubTab("dreams");
521-const container = renderInto(buildProps({ dreamDiaryContent: null }));
522-expect(container.querySelector(".dreams-diary__empty")).not.toBeNull();
523-expect(container.querySelector(".dreams-diary__empty-text")?.textContent).toContain(
474+const emptyContainer = renderInto(buildProps({ dreamDiaryContent: null }));
475+expect(emptyContainer.querySelector(".dreams-diary__empty")).not.toBeNull();
476+expect(emptyContainer.querySelector(".dreams-diary__empty-text")?.textContent).toContain(
524477"No dreams yet",
525478);
526-setDreamSubTab("scene");
527-});
528479529-it("shows diary error message when diary load fails", () => {
530-setDreamSubTab("diary");
531-setDreamDiarySubTab("dreams");
532-const container = renderInto(buildProps({ dreamDiaryError: "read failed" }));
533-expect(container.querySelector(".dreams-diary__error")?.textContent).toContain("read failed");
534-setDreamSubTab("scene");
535-});
480+const errorContainer = renderInto(buildProps({ dreamDiaryError: "read failed" }));
481+expect(errorContainer.querySelector(".dreams-diary__error")?.textContent).toContain(
482+"read failed",
483+);
536484537-it("does not render the old page navigation chrome", () => {
538-setDreamSubTab("diary");
539-setDreamDiarySubTab("dreams");
540485const container = renderInto(buildProps());
541486expect(container.querySelector(".dreams-diary__page")).toBeNull();
542487expect(container.querySelector(".dreams-diary__nav-btn")).toBeNull();
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。