Skip to content

Commit 94809a8

Browse files
authored
fix(miner-ui): type a chat-dispatch mock against the union #9815 closed (#9846)
main is red on ui:typecheck, which blocks every open PR. #9659/#9815 correctly tightened ChatActionDispatchResult from a loose `{ ok: boolean; status: string; ... }` into a union discriminated on `ok`, so the miner MCP server's refusal -> error-code mapping could finally be checked. But this miner-UI test mocks the dispatcher with a bare object literal, whose `ok`/`status` widen to boolean/string on inference -- and a widened literal no longer satisfies the closed union. Annotate the mock's return type (and import the real type) so it is validated against the shipped contract instead of inference. That also stops the mock drifting from the union the next time it changes -- the widened version would have kept compiling against any shape at all.
1 parent 5cc8d1f commit 94809a8

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

apps/loopover-miner-ui/src/chat-conversation.test.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { fireEvent, render, screen, waitFor } from "@testing-library/react";
22
import { describe, expect, it, vi } from "vitest";
33

4+
import type { ChatActionDispatchResult } from "../../../packages/loopover-miner/lib/chat-action-dispatch.js";
45
import { createChatActionRegistry } from "../../../packages/loopover-miner/lib/chat-action-registry.js";
56
import { ChatConversation } from "./components/chat/conversation";
67
import { GOVERNOR_CHAT_ACTION_PENDING_MESSAGE } from "./lib/chat-governor-action-copy";
@@ -288,7 +289,11 @@ describe("ChatConversation governor pause/resume chat actions (#8670)", () => {
288289
});
289290

290291
it("surfaces a non-executed dispatch (flag off / gated) as a system note instead of an empty turn", async () => {
291-
const runGovernorChatActionImpl = vi.fn(async () => ({ ok: false, status: "disabled", action: null }));
292+
const runGovernorChatActionImpl = vi.fn(async (): Promise<ChatActionDispatchResult> => ({
293+
ok: false,
294+
status: "disabled",
295+
action: null,
296+
}));
292297
render(
293298
<ChatConversation
294299
streamChatImpl={async function* () {

0 commit comments

Comments
 (0)