|
1 | 1 | import { act, cleanup, render, screen, within } from "@testing-library/react"; |
2 | | -import { afterEach, describe, expect, test, vi } from "vitest"; |
| 2 | +import { afterEach, describe, expect, test } from "vitest"; |
3 | 3 | import { moodOf } from "../features/bots/BotAvatar"; |
4 | 4 | import { FakeBotloft } from "../lib/fake"; |
5 | 5 | import { crewOpened, openBot, renderApp } from "../test/app"; |
6 | | -import { SeenSince, useArrival, viewTransition } from "./motion"; |
| 6 | +import { SeenSince, useArrival } from "./motion"; |
7 | 7 |
|
8 | | -afterEach(() => { |
9 | | - cleanup(); |
10 | | - vi.unstubAllGlobals(); |
11 | | - Reflect.deleteProperty(document, "startViewTransition"); |
12 | | -}); |
| 8 | +afterEach(cleanup); |
13 | 9 |
|
14 | 10 | describe("the mascot's mood", () => { |
15 | 11 | test("follows what the bot does", () => { |
@@ -65,29 +61,22 @@ describe("arrivals", () => { |
65 | 61 | }); |
66 | 62 | }); |
67 | 63 |
|
68 | | -describe("view transitions", () => { |
69 | | - test("run the change at once where the webview has none", () => { |
70 | | - const update = vi.fn(); |
71 | | - viewTransition(update); |
72 | | - expect(update).toHaveBeenCalledOnce(); |
73 | | - }); |
74 | | - |
75 | | - test("go through the webview's transition when it has one", () => { |
76 | | - const start = vi.fn((run: () => void) => run()); |
77 | | - Object.assign(document, { startViewTransition: start }); |
78 | | - const update = vi.fn(); |
79 | | - viewTransition(update); |
80 | | - expect(start).toHaveBeenCalledOnce(); |
81 | | - expect(update).toHaveBeenCalledOnce(); |
82 | | - }); |
83 | | - |
84 | | - test("skip the transition when Windows asks for less motion", () => { |
85 | | - const start = vi.fn((run: () => void) => run()); |
86 | | - Object.assign(document, { startViewTransition: start }); |
87 | | - vi.stubGlobal("matchMedia", (query: string) => ({ matches: query.includes("reduce") })); |
88 | | - const update = vi.fn(); |
89 | | - viewTransition(update); |
90 | | - expect(start).not.toHaveBeenCalled(); |
91 | | - expect(update).toHaveBeenCalledOnce(); |
| 64 | +describe("switching views", () => { |
| 65 | + test("the new bot's pane rises in, and the window around it stays", async () => { |
| 66 | + const fake = new FakeBotloft(); |
| 67 | + const ops = fake.addCrew("Ops"); |
| 68 | + for (const name of ["Scout", "Writer"]) { |
| 69 | + fake.setBotState(fake.addBot(ops.id, name, "Works").id, "idle"); |
| 70 | + } |
| 71 | + renderApp(fake); |
| 72 | + await crewOpened("Ops"); |
| 73 | + openBot("Scout"); |
| 74 | + const pane = () => screen.getByRole("main").lastElementChild as HTMLElement; |
| 75 | + const scout = pane(); |
| 76 | + expect(scout.className).toContain("pane-rise"); |
| 77 | + openBot("Writer"); |
| 78 | + await screen.findByLabelText("Message to Writer"); |
| 79 | + expect(pane()).not.toBe(scout); |
| 80 | + expect(pane().className).toContain("pane-rise"); |
92 | 81 | }); |
93 | 82 | }); |
0 commit comments