From 4e059035a9ee0dcb8d2c7cde6665337c70db9d7a Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Mon, 20 Apr 2026 17:47:01 +0100 Subject: [PATCH] test: share twitch finalize fixture --- extensions/twitch/src/setup-surface.test.ts | 66 ++++++++++----------- 1 file changed, 32 insertions(+), 34 deletions(-) diff --git a/extensions/twitch/src/setup-surface.test.ts b/extensions/twitch/src/setup-surface.test.ts index 967eb3cfba2..bf63afce3bc 100644 --- a/extensions/twitch/src/setup-surface.test.ts +++ b/extensions/twitch/src/setup-surface.test.ts @@ -313,6 +313,20 @@ describe("setup surface helpers", () => { }); describe("setup wizard account routing", () => { + type FinalizeArgs = Parameters>[0]; + + async function finalizeTwitchSetupForAccount(cfg: FinalizeArgs["cfg"]) { + return await twitchSetupWizard.finalize?.({ + cfg, + accountId: "secondary", + credentialValues: {}, + runtime: {} as FinalizeArgs["runtime"], + prompter: mockPrompter, + options: {}, + forceAllowFrom: false, + }); + } + it("rejects reserved account ids before using them as config keys", () => { expect(() => setTwitchAccount( @@ -390,29 +404,21 @@ describe("setup surface helpers", () => { .mockResolvedValueOnce("#secondary" as never); mockPromptConfirm.mockReset().mockResolvedValue(false as never); - const result = await twitchSetupWizard.finalize?.({ - cfg: { - channels: { - twitch: { - defaultAccount: "secondary", - accounts: { - default: { - username: "default-bot", - accessToken: "oauth:default", - clientId: "default-client", - channel: "#default", - }, + const result = await finalizeTwitchSetupForAccount({ + channels: { + twitch: { + defaultAccount: "secondary", + accounts: { + default: { + username: "default-bot", + accessToken: "oauth:default", + clientId: "default-client", + channel: "#default", }, }, }, - } as Parameters>[0]["cfg"], - accountId: "secondary", - credentialValues: {}, - runtime: {} as Parameters>[0]["runtime"], - prompter: mockPrompter, - options: {}, - forceAllowFrom: false, - }); + }, + } as FinalizeArgs["cfg"]); const twitch = result?.cfg?.channels?.twitch; expect(twitch?.accounts?.secondary?.username).toBe("secondary-bot"); @@ -430,21 +436,13 @@ describe("setup surface helpers", () => { .mockResolvedValueOnce("#secondary" as never); mockPromptConfirm.mockReset().mockResolvedValue(false as never); - const result = await twitchSetupWizard.finalize?.({ - cfg: { - channels: { - twitch: { - accounts: {}, - }, + const result = await finalizeTwitchSetupForAccount({ + channels: { + twitch: { + accounts: {}, }, - } as Parameters>[0]["cfg"], - accountId: "secondary", - credentialValues: {}, - runtime: {} as Parameters>[0]["runtime"], - prompter: mockPrompter, - options: {}, - forceAllowFrom: false, - }); + }, + } as FinalizeArgs["cfg"]); const twitch = result?.cfg?.channels?.twitch; expect(twitch?.accounts?.secondary?.accessToken).toBe("oauth:persisted");