From ec55583bb77aecd264ae3a407f2ecbc3f3ee1af3 Mon Sep 17 00:00:00 2001 From: Seb Slight <19554889+sebslight@users.noreply.github.com> Date: Mon, 9 Feb 2026 14:12:07 -0500 Subject: [PATCH] fix: align extension tests and fetch typing for gate stability (#12816) --- extensions/diagnostics-otel/src/service.test.ts | 1 + extensions/mattermost/src/mattermost/monitor.ts | 2 +- extensions/twitch/src/outbound.test.ts | 11 +++++++++-- extensions/twitch/src/probe.test.ts | 9 +++++---- 4 files changed, 16 insertions(+), 7 deletions(-) diff --git a/extensions/diagnostics-otel/src/service.test.ts b/extensions/diagnostics-otel/src/service.test.ts index fca5467304..c379dc7a9f 100644 --- a/extensions/diagnostics-otel/src/service.test.ts +++ b/extensions/diagnostics-otel/src/service.test.ts @@ -83,6 +83,7 @@ vi.mock("@opentelemetry/sdk-trace-base", () => ({ })); vi.mock("@opentelemetry/resources", () => ({ + resourceFromAttributes: vi.fn((attrs: Record) => attrs), Resource: class { // eslint-disable-next-line @typescript-eslint/no-useless-constructor constructor(_value?: unknown) {} diff --git a/extensions/mattermost/src/mattermost/monitor.ts b/extensions/mattermost/src/mattermost/monitor.ts index 1a6c9d9e5e..e085bed4f1 100644 --- a/extensions/mattermost/src/mattermost/monitor.ts +++ b/extensions/mattermost/src/mattermost/monitor.ts @@ -50,7 +50,7 @@ export type MonitorMattermostOpts = { statusSink?: (patch: Partial) => void; }; -type FetchLike = typeof fetch; +type FetchLike = (input: URL | RequestInfo, init?: RequestInit) => Promise; type MediaKind = "image" | "audio" | "video" | "document" | "unknown"; type MattermostEventPayload = { diff --git a/extensions/twitch/src/outbound.test.ts b/extensions/twitch/src/outbound.test.ts index 10705ef135..7c871e3c77 100644 --- a/extensions/twitch/src/outbound.test.ts +++ b/extensions/twitch/src/outbound.test.ts @@ -36,7 +36,7 @@ vi.mock("./utils/twitch.js", () => ({ describe("outbound", () => { const mockAccount = { username: "testbot", - token: "oauth:test123", + accessToken: "oauth:test123", clientId: "test-client-id", channel: "#testchannel", }; @@ -196,7 +196,14 @@ describe("outbound", () => { expect(result.channel).toBe("twitch"); expect(result.messageId).toBe("twitch-msg-123"); - expect(result.to).toBe("testchannel"); + expect(sendMessageTwitchInternal).toHaveBeenCalledWith( + "testchannel", + "Hello Twitch!", + mockConfig, + "default", + true, + console, + ); expect(result.timestamp).toBeGreaterThan(0); }); diff --git a/extensions/twitch/src/probe.test.ts b/extensions/twitch/src/probe.test.ts index 3a54fb1698..9638120eb6 100644 --- a/extensions/twitch/src/probe.test.ts +++ b/extensions/twitch/src/probe.test.ts @@ -54,7 +54,8 @@ vi.mock("@twurple/auth", () => ({ describe("probeTwitch", () => { const mockAccount: TwitchAccountConfig = { username: "testbot", - token: "oauth:test123456789", + accessToken: "oauth:test123456789", + clientId: "test-client-id", channel: "testchannel", }; @@ -74,7 +75,7 @@ describe("probeTwitch", () => { }); it("returns error when token is missing", async () => { - const account = { ...mockAccount, token: "" }; + const account = { ...mockAccount, accessToken: "" }; const result = await probeTwitch(account, 5000); expect(result.ok).toBe(false); @@ -84,7 +85,7 @@ describe("probeTwitch", () => { it("attempts connection regardless of token prefix", async () => { // Note: probeTwitch doesn't validate token format - it tries to connect with whatever token is provided // The actual connection would fail in production with an invalid token - const account = { ...mockAccount, token: "raw_token_no_prefix" }; + const account = { ...mockAccount, accessToken: "raw_token_no_prefix" }; const result = await probeTwitch(account, 5000); // With mock, connection succeeds even without oauth: prefix @@ -166,7 +167,7 @@ describe("probeTwitch", () => { it("trims token before validation", async () => { const account: TwitchAccountConfig = { ...mockAccount, - token: " oauth:test123456789 ", + accessToken: " oauth:test123456789 ", }; const result = await probeTwitch(account, 5000);