Skip to content

Commit 03bd763

Browse files
matt2eclaude
andcommitted
test(shell): move the bundled navigation owner test beside discovery
The bundled navigation owner rows loaded every bundled plugin through a top-level await in presentation.test.ts. That slowed the file from about 0.2s to 3.2s. A page plugin whose apply trips the inert stubs would also have failed the whole module, so the unrelated orderPages and pagePresentation tests would disappear from the report. Move bundledPages() and the bundled table into src/bundled/navigation-owner.test.ts, beside discovery.test.ts, which already imports the bundled plugins in the node environment. Call bundledPages() inside the test, so a registration failure reports against that test. The hand-written external rows stay in presentation.test.ts without the bundled imports, since navigationOwner reads only the selected page. presentation.test.ts runs in about 0.19s again. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: mtoohey <[email protected]>
1 parent 04baf9f commit 03bd763

2 files changed

Lines changed: 60 additions & 57 deletions

File tree

‎src/app/shell/presentation.test.ts‎

Lines changed: 1 addition & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { describe, expect, test } from "vitest";
2-
import { bundledPlugins } from "../../bundled";
3-
import type { Page, RegisteredPage } from "../../features/pages/service";
2+
import type { RegisteredPage } from "../../features/pages/service";
43
import {
54
BellIcon,
65
BrowserIcon,
@@ -142,67 +141,12 @@ test.each([undefined, "toolbar"] as const)(
142141
},
143142
);
144143

145-
// Each bundled page exactly as its plugin's `apply` registers it, keyed as the
146-
// registry keys it. The other services a page plugin injects are inert stubs.
147-
async function bundledPages() {
148-
const inert: object = new Proxy(() => {}, {
149-
get: (_, key) =>
150-
key === "then" || typeof key === "symbol" ? undefined : inert,
151-
apply: () => inert,
152-
});
153-
const pages: RegisteredPage[] = [];
154-
for (const { manifest, module } of bundledPlugins) {
155-
if (!Array.isArray(module.inject) || !module.inject.includes("pages"))
156-
continue;
157-
const registry = {
158-
register: (registered: Page) =>
159-
pages.push({
160-
...registered,
161-
key: `${manifest.id}/${registered.id}`,
162-
pluginId: manifest.id,
163-
revision: "bundled",
164-
}),
165-
};
166-
const ctx = new Proxy(
167-
{},
168-
{ get: (_, key) => (key === "pages" ? registry : inert) },
169-
);
170-
await module.apply(ctx as Parameters<typeof module.apply>[0]);
171-
}
172-
return pages;
173-
}
174-
const bundled = await bundledPages();
175-
176144
describe("navigation owner", () => {
177-
test("every bundled page belongs to the app whose navigation lists it", () => {
178-
expect(
179-
Object.fromEntries(
180-
bundled.map(({ key }) => [key, navigationOwner(bundled, key)]),
181-
),
182-
).toEqual({
183-
// Channels, DMs, threads and Solo chats all open the Messages page.
184-
[messages.key]: messages.key,
185-
// Pages listed in the Messages sidebar keep Messages selected.
186-
"buzz.drafts-sent/drafts-sent": messages.key,
187-
"buzz.usage/usage": messages.key,
188-
// Dock apps own themselves.
189-
[inbox.key]: inbox.key,
190-
[bestie.key]: bestie.key,
191-
"buzz.reminders/reminders": "buzz.reminders/reminders",
192-
"buzz.agents/agents": "buzz.agents/agents",
193-
"buzz.workflows/workflows": "buzz.workflows/workflows",
194-
"buzz.relay-notes/notes": "buzz.relay-notes/notes",
195-
// An unlisted destination selects nothing in the dock.
196-
"buzz.repos/repos": "buzz.repos/repos",
197-
});
198-
});
199-
200145
const primary = (
201146
key: string,
202147
fields: Partial<RegisteredPage> = {},
203148
): RegisteredPage => ({ ...page(key, key), primary: true, ...fields });
204149
const entries = [
205-
...bundled,
206150
primary("example.sidebar/main"),
207151
primary("example.listed/main", { placement: "sidebar" }),
208152
primary("example.own-sidebar/main", { sidebar: () => null }),
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
import { expect, it } from "vitest";
2+
import { bundledPlugins } from ".";
3+
import { navigationOwner } from "../app/shell/presentation";
4+
import type { Page, RegisteredPage } from "../features/pages/service";
5+
6+
// Each bundled page exactly as its plugin's `apply` registers it, keyed as the
7+
// registry keys it. The other services a page plugin injects are inert stubs.
8+
async function bundledPages() {
9+
const inert: object = new Proxy(() => {}, {
10+
get: (_, key) =>
11+
key === "then" || typeof key === "symbol" ? undefined : inert,
12+
apply: () => inert,
13+
});
14+
const pages: RegisteredPage[] = [];
15+
for (const { manifest, module } of bundledPlugins) {
16+
if (!Array.isArray(module.inject) || !module.inject.includes("pages"))
17+
continue;
18+
const registry = {
19+
register: (registered: Page) =>
20+
pages.push({
21+
...registered,
22+
key: `${manifest.id}/${registered.id}`,
23+
pluginId: manifest.id,
24+
revision: "bundled",
25+
}),
26+
};
27+
const ctx = new Proxy(
28+
{},
29+
{ get: (_, key) => (key === "pages" ? registry : inert) },
30+
);
31+
await module.apply(ctx as Parameters<typeof module.apply>[0]);
32+
}
33+
return pages;
34+
}
35+
36+
it("gives every bundled page to the app whose navigation lists it", async () => {
37+
const pages = await bundledPages();
38+
const messages = "buzz.channels/channels";
39+
expect(
40+
Object.fromEntries(
41+
pages.map(({ key }) => [key, navigationOwner(pages, key)]),
42+
),
43+
).toEqual({
44+
// Channels, DMs, threads and Solo chats all open the Messages page.
45+
[messages]: messages,
46+
// Pages listed in the Messages sidebar keep Messages selected.
47+
"buzz.drafts-sent/drafts-sent": messages,
48+
"buzz.usage/usage": messages,
49+
// Dock apps own themselves.
50+
"buzz.inbox/inbox": "buzz.inbox/inbox",
51+
"buzz.bestie/bestie": "buzz.bestie/bestie",
52+
"buzz.reminders/reminders": "buzz.reminders/reminders",
53+
"buzz.agents/agents": "buzz.agents/agents",
54+
"buzz.workflows/workflows": "buzz.workflows/workflows",
55+
"buzz.relay-notes/notes": "buzz.relay-notes/notes",
56+
// An unlisted destination selects nothing in the dock.
57+
"buzz.repos/repos": "buzz.repos/repos",
58+
});
59+
});

0 commit comments

Comments
 (0)