Skip to content

Commit 04baf9f

Browse files
matt2eclaude
andcommitted
test(shell): cover pages that replace the Messages sidebar
Keep navigationOwner returning Messages for a sidebar-placed page that supplies its own sidebar: anything opened from the Messages sidebar keeps Messages selected in the dock. Correct buzz-help.md, shell-design.md and the navigationOwner comment, which said the Messages sidebar always stays open. It stays open unless the page supplies its own sidebar, which replaces it. Add AppShell tests for that case (Messages selected, the page's own sidebar as the only complementary landmark, Messages returns) and for the narrow navigation drawer on Drafts & sent. Rename the primary plugin page test after what it now checks. Build the bundled rows of the navigation owner table by applying each page plugin's real registration, so a placement change in a bundled page fails the test. Link Lab drops out because it is not bundled. Assert in the page sidebar browser journey that Messages stays selected while the fixture page's own sidebar is open. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: mtoohey <[email protected]>
1 parent 52445b5 commit 04baf9f

6 files changed

Lines changed: 210 additions & 35 deletions

File tree

‎docs/buzz-help.md‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,9 @@ revokes all of them, and a pairing unused for 30 days expires.
434434
sit at the bottom of the dock. Search stays wide in the top bar.
435435
Messages has All / Solo / Team sidebar filters; other apps use their main
436436
view unless they provide their own sidebar. Pages listed in the Messages
437-
sidebar, such as Drafts & sent, keep Messages selected and its sidebar open.
437+
sidebar, such as Drafts & sent, keep Messages selected in the dock. The
438+
Messages sidebar stays open unless the page provides its own sidebar, which
439+
replaces it.
438440
The sidebar and message pane share one surface with a persistent divider;
439441
panel headers also have bottom hairlines. Dock icons stay still, highlight
440442
on hover, and show instant labels to their right. Bestie uses your

‎docs/shell-design.md‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,10 @@ semantic tokens, UI authoring rules and the local component reference.
5656
channel sidebar's surface, resize owner, row treatment and section recipes.
5757
Bestie and Inbox lead the left app dock, followed by Messages and the other
5858
dock destinations. Sidebar-placed contributions remain in the conversation
59-
sidebar; `navigationOwner` keeps Messages selected, with its sidebar, while
60-
one is open. Its plus opens New for chat, project, DM and channel creation;
59+
sidebar; while one is open, `navigationOwner` keeps Messages selected in the
60+
dock and the conversation sidebar stays open unless the page supplies its own
61+
sidebar, which replaces it. The conversation sidebar's plus opens New for
62+
chat, project, DM and channel creation;
6163
Cmd/Ctrl+N opens that menu only where the current app has a creation sidebar. Every conversation, Solo or Team, opens in Messages; see
6264
[Solo](solo/README.md) for the Solo treatment, placement and the relay privacy
6365
boundary. Messages is the default destination.

‎src/app/shell/AppShell.test.tsx‎

Lines changed: 132 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@ import {
1919
import userEvent from "@testing-library/user-event";
2020
import { useEffect, type ReactNode } from "react";
2121
import { afterEach, beforeEach, expect, it, vi } from "vitest";
22-
import type { RegisteredPage } from "../../features/pages/service";
22+
import type {
23+
PageSidebarProps,
24+
RegisteredPage,
25+
} from "../../features/pages/service";
2326
import { createServices, type AppServices } from "../services";
2427
import { ToastProvider } from "../../shared/design-system/ui/Toast";
2528
import { AppShell } from "./AppShell";
@@ -139,7 +142,7 @@ it("hides and shows the channel sidebar without re-rendering its content", async
139142
});
140143

141144
it.each([true, false])(
142-
"shows app navigation only for primary plugin pages (primary: %s)",
145+
"keeps the Messages sidebar for a plugin page listed in it, not for an unlisted one (primary: %s)",
143146
(primary) => {
144147
const current = createServices();
145148
services = current;
@@ -556,6 +559,133 @@ it.each([
556559
},
557560
);
558561

562+
it("keeps Messages selected when a page listed in its sidebar supplies its own sidebar", async () => {
563+
const current = createServices();
564+
services = current;
565+
const onSelect = vi.fn();
566+
const page = (pluginId: string, id: string, title: string) => ({
567+
id,
568+
pluginId,
569+
title,
570+
key: `${pluginId}/${id}`,
571+
revision: "one",
572+
primary: true,
573+
component: () => null,
574+
});
575+
function PlaygroundSidebar({ children }: PageSidebarProps) {
576+
return <aside aria-label="Playground sidebar">{children}</aside>;
577+
}
578+
const playground: RegisteredPage = {
579+
...page("example.playground", "sidebar", "Sidebar playground"),
580+
sidebar: PlaygroundSidebar,
581+
};
582+
render(
583+
<ToastProvider>
584+
<AppShell
585+
pages={[
586+
page("buzz.channels", "channels", "Channels"),
587+
page("buzz.inbox", "inbox", "Activity"),
588+
playground,
589+
]}
590+
selected={playground.key}
591+
navigationAttempt=""
592+
onSelect={onSelect}
593+
tone="default"
594+
// As in App, the open page's own sidebar replaces the Messages sidebar.
595+
sidebar={(links) => (
596+
<PlaygroundSidebar
597+
target={{
598+
version: 1,
599+
kind: "page",
600+
pluginId: playground.pluginId,
601+
pageId: playground.id,
602+
}}
603+
>
604+
{links}
605+
</PlaygroundSidebar>
606+
)}
607+
communities={current.communities}
608+
accountActions={current.accountActions}
609+
appearance={testAppearance}
610+
>
611+
Page content
612+
</AppShell>
613+
</ToastProvider>,
614+
);
615+
const dock = screen.getByRole("navigation", { name: "Apps dock" });
616+
const messages = within(dock).getByRole("tab", { name: "Messages" });
617+
expect(messages).toHaveAttribute("aria-selected", "true");
618+
expect(within(dock).getByRole("tab", { name: "Activity" })).toHaveAttribute(
619+
"aria-selected",
620+
"false",
621+
);
622+
expect(screen.getByRole("tabpanel", { name: "Messages" })).toHaveTextContent(
623+
"Page content",
624+
);
625+
// One sidebar: the page's own, still listing the Messages sidebar pages.
626+
expect(screen.getAllByRole("complementary")).toHaveLength(1);
627+
const sidebar = screen.getByRole("complementary", {
628+
name: "Playground sidebar",
629+
});
630+
expect(sidebar).toBeVisible();
631+
expect(
632+
within(sidebar).getByRole("button", { name: "Sidebar playground" }),
633+
).toBeVisible();
634+
expect(screen.getByRole("button", { name: "Hide sidebar" })).toBeVisible();
635+
636+
await userEvent.click(messages);
637+
expect(onSelect).toHaveBeenCalledExactlyOnceWith("buzz.channels/channels", {
638+
focus: "preserve",
639+
});
640+
});
641+
642+
it("opens the narrow navigation drawer from Drafts & sent", async () => {
643+
vi.stubGlobal("matchMedia", (media: string) => ({
644+
media,
645+
matches: true,
646+
addEventListener() {},
647+
removeEventListener() {},
648+
}));
649+
const current = createServices();
650+
services = current;
651+
const pages = [
652+
{ id: "channels", pluginId: "buzz.channels", title: "Channels" },
653+
{ id: "drafts-sent", pluginId: "buzz.drafts-sent", title: "Drafts & sent" },
654+
].map((page) => ({
655+
...page,
656+
key: `${page.pluginId}/${page.id}`,
657+
revision: "one",
658+
primary: true,
659+
component: () => null,
660+
}));
661+
render(
662+
<ToastProvider>
663+
<AppShell
664+
pages={pages}
665+
selected="buzz.drafts-sent/drafts-sent"
666+
navigationAttempt=""
667+
onSelect={() => {}}
668+
tone="default"
669+
sidebar={(links) => <aside aria-label="Sidebar">{links}</aside>}
670+
communities={current.communities}
671+
accountActions={current.accountActions}
672+
appearance={testAppearance}
673+
>
674+
Drafts content
675+
</AppShell>
676+
</ToastProvider>,
677+
);
678+
const navigation = document.getElementById("shell-navigation");
679+
const toggle = screen.getByRole("button", { name: "Show navigation" });
680+
expect(toggle).toHaveAttribute("aria-expanded", "false");
681+
expect(navigation).toHaveAttribute("aria-hidden", "true");
682+
await userEvent.click(toggle);
683+
expect(navigation).toHaveAttribute("aria-hidden", "false");
684+
expect(navigation).toContainElement(
685+
screen.getByRole("complementary", { name: "Sidebar" }),
686+
);
687+
});
688+
559689
it.each(["sidebar", "topbar", "toolbar"] as const)(
560690
"keeps %s plugin icons, badge failures, selection and removal at the navigation boundary",
561691
async (placement) => {

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

Lines changed: 60 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { describe, expect, test } from "vitest";
2-
import type { RegisteredPage } from "../../features/pages/service";
2+
import { bundledPlugins } from "../../bundled";
3+
import type { Page, RegisteredPage } from "../../features/pages/service";
34
import {
45
BellIcon,
56
BrowserIcon,
@@ -141,24 +142,67 @@ test.each([undefined, "toolbar"] as const)(
141142
},
142143
);
143144

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+
144176
describe("navigation owner", () => {
145-
// Mirrors the bundled registrations' navigation fields.
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+
146200
const primary = (
147201
key: string,
148202
fields: Partial<RegisteredPage> = {},
149203
): RegisteredPage => ({ ...page(key, key), primary: true, ...fields });
150204
const entries = [
151-
primary(messages.key, { placement: "topbar" }),
152-
primary(inbox.key),
153-
primary(bestie.key),
154-
primary("buzz.reminders/reminders"),
155-
primary("buzz.agents/agents"),
156-
primary("buzz.workflows/workflows"),
157-
primary("buzz.relay-notes/notes", { placement: "topbar" }),
158-
primary("buzz.drafts-sent/drafts-sent"),
159-
primary("buzz.usage/usage"),
160-
primary("buzz.link-lab/link-lab"),
161-
primary("buzz.repos/repos", { primary: false }),
205+
...bundled,
162206
primary("example.sidebar/main"),
163207
primary("example.listed/main", { placement: "sidebar" }),
164208
primary("example.own-sidebar/main", { sidebar: () => null }),
@@ -167,26 +211,15 @@ describe("navigation owner", () => {
167211
primary("example.linked/main", { primary: false, placement: "sidebar" }),
168212
];
169213
test.each([
170-
// Channels, DMs, threads and Solo chats all open the Messages page.
171-
[messages.key, messages.key],
172-
// Every page listed in the Messages sidebar keeps Messages selected.
173-
["buzz.drafts-sent/drafts-sent", messages.key],
174-
["buzz.usage/usage", messages.key],
175-
["buzz.link-lab/link-lab", messages.key],
214+
// Every external page listed in the Messages sidebar keeps Messages
215+
// selected, including one that supplies its own sidebar.
176216
["example.sidebar/main", messages.key],
177217
["example.listed/main", messages.key],
178218
["example.own-sidebar/main", messages.key],
179-
// Dock apps own themselves.
180-
[inbox.key, inbox.key],
181-
[bestie.key, bestie.key],
182-
["buzz.reminders/reminders", "buzz.reminders/reminders"],
183-
["buzz.agents/agents", "buzz.agents/agents"],
184-
["buzz.workflows/workflows", "buzz.workflows/workflows"],
185-
["buzz.relay-notes/notes", "buzz.relay-notes/notes"],
219+
// External dock apps own themselves.
186220
["example.header/main", "example.header/main"],
187221
["example.tools/main", "example.tools/main"],
188222
// Destinations without a navigation entry select nothing in the dock.
189-
["buzz.repos/repos", "buzz.repos/repos"],
190223
["example.linked/main", "example.linked/main"],
191224
["settings", "settings"],
192225
["missing/page", "missing/page"],

‎src/app/shell/presentation.ts‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,10 @@ export function pagePlacement(page: RegisteredPage) {
8080
}
8181

8282
/** The app whose navigation lists a destination: the dock selects it and the
83-
* shell shows its sidebar. Pages listed in the Messages sidebar belong to
84-
* Messages; conversations already select the Messages page. Every other
85-
* destination, including Settings and unlisted pages, owns itself. */
83+
* shell shows its sidebar unless the page supplies its own. Pages listed in
84+
* the Messages sidebar belong to Messages; conversations already select the
85+
* Messages page. Every other destination, including Settings and unlisted
86+
* pages, owns itself. */
8687
export function navigationOwner(
8788
pages: readonly RegisteredPage[],
8889
selected: string,

‎tests/browser/page-placement.spec.mjs‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,9 +230,16 @@ test("a page sidebar uses the shell slot, generic toggle, theme, and narrow draw
230230

231231
const sidebar = page.getByRole("complementary", { name: "Fixture sidebar" });
232232
await expect(sidebar).toContainText("Target: sidebar");
233+
// The page's own sidebar replaces the Messages sidebar it is listed in, and
234+
// Messages stays selected.
233235
await expect(
234236
page.getByRole("complementary", { name: "Sidebar", exact: true }),
235237
).toHaveCount(0);
238+
await expect(
239+
page
240+
.getByRole("navigation", { name: "Apps dock" })
241+
.getByRole("tab", { name: "Messages", exact: true }),
242+
).toHaveAttribute("aria-selected", "true");
236243
const wideSize = await sidebar.evaluate(
237244
(element) => element.getBoundingClientRect().width,
238245
);

0 commit comments

Comments
 (0)