Skip to content

Commit 06a7209

Browse files
committed
test(webui): update the source expectations the terminal and browser work left behind
The terminal and browser work changed what these suites read. The panel mounts the browser host for the tab it kept mounted rather than for the selected one; the launcher hands the browser its own normalised address, which is what gives a bare host its trailing slash; the terminal's create button became an automatic create once the roster lands, so the panel states what the service says instead of keeping a copy of the limit; the browser control is an icon button whose accessible name is an `aria-label` rather than a title; and the shell's stylesheet list now includes the terminal's own stylesheet, which is a package stylesheet and so is not counted among the shell's rules. Each expectation now names the behaviour that replaced it rather than the shape it used to have.
1 parent 3e25b85 commit 06a7209

5 files changed

Lines changed: 44 additions & 26 deletions

File tree

‎packages/webui/test/unit/browser-web-tab-toolbar.test.tsx‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -136,11 +136,12 @@ describe("a web tab's toolbar", () => {
136136
});
137137

138138
it("is carried by the browser business's host, over the tab's target", () => {
139-
// The toolbar is rendered by the host the strip mounts, and the strip hands
140-
// it the tab's own target and url — so the row and the frame describe the
141-
// same page rather than a pair that has drifted.
142-
expect(WORKSPACE_PANELS_SOURCE).toContain("canGoBack={activeTab.content.canGoBack}");
143-
expect(WORKSPACE_PANELS_SOURCE).toContain("canGoForward={activeTab.content.canGoForward}");
139+
// The toolbar is rendered by the host the panel mounts, and the panel hands
140+
// it one tab's own target and url — so the row and the frame describe the
141+
// same page rather than a pair that has drifted. That tab is the one the
142+
// panel kept mounted, which is the one whose frame the reader is looking at.
143+
expect(WORKSPACE_PANELS_SOURCE).toContain("canGoBack={browserTab.content.canGoBack}");
144+
expect(WORKSPACE_PANELS_SOURCE).toContain("canGoForward={browserTab.content.canGoForward}");
144145
expect(WORKSPACE_PANELS_SOURCE).toContain('type: "return-web-tab-to-launcher"');
145146
});
146147

‎packages/webui/test/unit/webui-shell.test.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,10 @@ describe("WebUI shell", () => {
315315

316316
const controls = renderToStaticMarkup(createElement(WebuiWorkspacePanelControls, { browserPanelOpen: false, progressPanelOpen: true, onOpenBrowser: () => undefined, onToggleProgressPanel: () => undefined }));
317317
expect(controls).toContain('aria-label="浏览器"');
318-
expect(controls).toContain('title="浏览器"');
318+
// The control is an icon button now, so the label is the accessible name
319+
// rather than a tooltip: `aria-label` is what a screen reader reads, and a
320+
// `title` would only add a hover affordance the glyph already carries.
321+
expect(controls).not.toContain('title="浏览器"');
319322
// The control's glyph is the tabler browser icon. It used to be a globe
320323
// drawn by hand, so the assertion names the icon rather than the shape it
321324
// happens to be made of.

‎packages/webui/test/unit/webui-w0-css-structure.test.ts‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,11 @@ beforeAll(() => {
238238
.map((match) => match[1])
239239
.filter(
240240
(specifier) =>
241-
!specifier.startsWith("katex/") &&
241+
// Only the shell's own stylesheets count. A package stylesheet —
242+
// `katex/`, and now `@xterm/` — is not the shell's CSS: its rules sit
243+
// outside the components layer, so counting them would answer questions
244+
// the assertions below never asked.
245+
specifier.startsWith(".") &&
242246
!carved.has(specifier.replace(/^.*\//u, "")),
243247
)
244248
.map((specifier) => path.resolve(stylesDir, specifier));
@@ -512,6 +516,9 @@ describe("W0 · stylesheet composition", () => {
512516
expect(imports).toEqual([
513517
"./tokens.css",
514518
"./shell.css",
519+
// The terminal's own stylesheet, brought in by the package that owns it
520+
// rather than copied into the shell's tree.
521+
"@xterm/xterm/css/xterm.css",
515522
// The shared dropdown surface: the look, the motion and the shape every
516523
// floating popup in the client shares.
517524
"./dropdown.css",

‎packages/webui/test/unit/workspace-panel-state.test.ts‎

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -417,14 +417,14 @@ describe("the terminal roster is read before it is shown", () => {
417417

418418
it("does not paint an empty roster before the first answer lands", () => {
419419
// On a reload whose sessions still hold PTYs, an empty first paint reads as
420-
// "all my terminals exited" and offers a create button that would exceed the
420+
// "all my terminals exited" and invites a create that would exceed the
421421
// limit. The panel waits for the roster instead.
422422
expect(panelSource).toContain("terminalsReady");
423-
expect(panelSource).toContain("{!terminalsReady ? <><p>{DESKTOP_COPY.terminalLoading}</p>");
424-
// The standalone create button lives outside the ready/not-ready branch, so
425-
// it is gated explicitly: offering it before the roster lands is what invites
426-
// the create that exceeds the limit.
427-
expect(panelSource).toContain("terminalsReady && terminals.length === 0");
423+
expect(panelSource).toContain("{!terminalsReady ? DESKTOP_COPY.terminalLoading");
424+
// The create waits for the roster too: the panel opens a terminal only once
425+
// the first answer has landed, so a reload cannot open a second shell
426+
// before the roster has said what is already running.
427+
expect(panelSource).toContain("!terminalsReady || terminalTargetId");
428428
});
429429

430430
it("drops a roster read that a later read has superseded", () => {
@@ -435,16 +435,20 @@ describe("the terminal roster is read before it is shown", () => {
435435
expect(panelSource).toContain("if (rosterRead.current !== read) return;");
436436
});
437437

438-
it("says the limit rather than discovering it through a refused create", () => {
439-
// The panel knows the rule the process half enforces, so a full set is
440-
// stated before the request instead of after it.
441-
expect(panelSource).toContain("const DESKTOP_TERMINAL_LIMIT = 5;");
442-
expect(panelSource).toContain("const terminalSlotsFull = terminals.length >= DESKTOP_TERMINAL_LIMIT;");
443-
expect(panelSource).toContain("const terminalCreateDisabled = terminalSlotsFull || !terminalOwner?.canCreate;");
444-
expect(panelSource).toContain("disabled={terminalCreateDisabled}");
445-
// One helper, not three copies of the create-then-catch dance.
446-
const createHandlers = panelSource.split("onClick={createTerminal}").length - 1;
447-
expect(createHandlers).toBe(2);
448-
expect(panelSource).not.toContain("terminalOwner.create(activeWorkspace).then");
438+
it("states what the terminal service says rather than discovering a refusal", () => {
439+
// The limit is the process half's rule now, so the panel keeps no copy of
440+
// it. It asks the owner what it can do and says that answer — an absent
441+
// service, a service that is not ready, an interface that does not match —
442+
// instead of letting a refused create speak for itself.
443+
expect(panelSource).toContain("terminalSupport");
444+
expect(panelSource).toContain("terminalAvailability");
445+
expect(panelSource).toContain("terminalError");
446+
expect(panelSource).toContain("data-webui-terminal-availability={terminalSupport}");
447+
// The create is gated by what the owner can do, so the panel never opens a
448+
// terminal the service would refuse.
449+
expect(panelSource).toContain("!terminalOwner?.canCreate");
450+
// One create call, not a copy per button.
451+
const createCalls = panelSource.split("terminalOwner.create(").length - 1;
452+
expect(createCalls).toBe(1);
449453
});
450454
});

‎packages/webui/test/unit/workspace-tab-strip.test.tsx‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -415,11 +415,14 @@ describe("the new tab page", () => {
415415
});
416416

417417
it("passes a bare host to the browser as a url it can open", () => {
418-
expect(webuiWorkspaceLauncherUrl("example.test")).toBe("https://example.test");
418+
// The launcher hands the browser its own address form: a bare host is a
419+
// web address, and the browser's normalisation is what says which one it
420+
// is. A host with no path keeps the browser's own trailing slash.
421+
expect(webuiWorkspaceLauncherUrl("example.test")).toBe("https://example.test/");
419422
expect(webuiWorkspaceLauncherUrl(" example.test/a ")).toBe("https://example.test/a");
420423
expect(webuiWorkspaceLauncherUrl("http://example.test/a")).toBe("http://example.test/a");
421424
// A host with a port is a host, not a scheme.
422-
expect(webuiWorkspaceLauncherUrl("localhost:3000")).toBe("https://localhost:3000");
425+
expect(webuiWorkspaceLauncherUrl("localhost:3000")).toBe("https://localhost:3000/");
423426
// An empty box opens nothing rather than opening a blank page.
424427
expect(webuiWorkspaceLauncherUrl(" ")).toBe("");
425428
});

0 commit comments

Comments
 (0)