chore(web): drop the double cast from the useSessionRef test fixture
Addresses Copilot's review on #2152. The client stand-in was `({ tag }) as unknown as InspectorClient` — a double cast with no justification, which AGENTS.md rejects. `Object.create(InspectorClient.prototype)` gives a real prototype chain without running the constructor, so it needs only a single cast and still drags in no transport or environment. The tag went with it: every assertion compares identity, and `Object.create` already returns a distinct object per call. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MZdpUwhHf943FoprcLVzEm Signed-off-by: cliffhall <cliff@futurescale.com>
This commit is contained in:
parent
104b3c0775
commit
dc026acfea
1 changed files with 13 additions and 6 deletions
|
|
@ -1,5 +1,5 @@
|
||||||
import { describe, it, expect } from "vitest";
|
import { describe, it, expect } from "vitest";
|
||||||
import type { InspectorClient } from "@inspector/core/mcp/index.js";
|
import { InspectorClient } from "@inspector/core/mcp/index.js";
|
||||||
import type { ServerEntry } from "@inspector/core/mcp/types.js";
|
import type { ServerEntry } from "@inspector/core/mcp/types.js";
|
||||||
import { renderWithMantine } from "../test/renderWithMantine";
|
import { renderWithMantine } from "../test/renderWithMantine";
|
||||||
import type { PendingReauth } from "../utils/pendingReauth";
|
import type { PendingReauth } from "../utils/pendingReauth";
|
||||||
|
|
@ -17,8 +17,15 @@ const entry = (id: string, name = id): ServerEntry => ({
|
||||||
connection: { status: "disconnected" },
|
connection: { status: "disconnected" },
|
||||||
});
|
});
|
||||||
|
|
||||||
/** A stand-in for the live client — the hook only ever stores the reference. */
|
/**
|
||||||
const client = (tag: string) => ({ tag }) as unknown as InspectorClient;
|
* A distinct client identity per call. `Object.create` does not run the
|
||||||
|
* constructor, so this is a real `InspectorClient` prototype chain with no
|
||||||
|
* transport or environment behind it — which is all that is needed here: the
|
||||||
|
* hook only stores the reference, and every assertion compares identity rather
|
||||||
|
* than reading a property off it.
|
||||||
|
*/
|
||||||
|
const client = (): InspectorClient =>
|
||||||
|
Object.create(InspectorClient.prototype) as InspectorClient;
|
||||||
|
|
||||||
const stepUp = (serverId: string): PendingStepUp => ({
|
const stepUp = (serverId: string): PendingStepUp => ({
|
||||||
serverId,
|
serverId,
|
||||||
|
|
@ -69,7 +76,7 @@ function harness(initial: SessionValues): Harness {
|
||||||
describe("useSessionRef", () => {
|
describe("useSessionRef", () => {
|
||||||
it("seeds the snapshot from the first render's values", () => {
|
it("seeds the snapshot from the first render's values", () => {
|
||||||
const servers = [entry("a")];
|
const servers = [entry("a")];
|
||||||
const c = client("first");
|
const c = client();
|
||||||
const h = harness(
|
const h = harness(
|
||||||
values({ activeServerId: "a", servers, inspectorClient: c }),
|
values({ activeServerId: "a", servers, inspectorClient: c }),
|
||||||
);
|
);
|
||||||
|
|
@ -91,7 +98,7 @@ describe("useSessionRef", () => {
|
||||||
it("mirrors every field on a later render", () => {
|
it("mirrors every field on a later render", () => {
|
||||||
const h = harness(values());
|
const h = harness(values());
|
||||||
const servers = [entry("a"), entry("b")];
|
const servers = [entry("a"), entry("b")];
|
||||||
const c = client("later");
|
const c = client();
|
||||||
const up = stepUp("a");
|
const up = stepUp("a");
|
||||||
const re = reauth("b");
|
const re = reauth("b");
|
||||||
h.update(
|
h.update(
|
||||||
|
|
@ -117,7 +124,7 @@ describe("useSessionRef", () => {
|
||||||
values({
|
values({
|
||||||
activeServerId: "a",
|
activeServerId: "a",
|
||||||
servers: [entry("a")],
|
servers: [entry("a")],
|
||||||
inspectorClient: client("x"),
|
inspectorClient: client(),
|
||||||
pendingStepUp: stepUp("a"),
|
pendingStepUp: stepUp("a"),
|
||||||
pendingReauth: reauth("a"),
|
pendingReauth: reauth("a"),
|
||||||
}),
|
}),
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue