fix multi account id + add unit test

This commit is contained in:
jaydenfyi 2026-01-25 22:10:21 +08:00
parent 6d7305c901
commit a2dfdb83a4
2 changed files with 38 additions and 1 deletions

View File

@ -0,0 +1,37 @@
import { describe, expect, it } from "vitest";
import type { ClawdbotConfig } from "clawdbot/plugin-sdk";
import { twitchPlugin } from "./plugin.js";
describe("twitchPlugin.status.buildAccountSnapshot", () => {
it("uses the resolved account ID for multi-account configs", () => {
const secondary = {
username: "secondary",
accessToken: "oauth:secondary-token",
clientId: "secondary-client",
enabled: true,
};
const cfg = {
channels: {
twitch: {
accounts: {
default: {
username: "default",
accessToken: "oauth:default-token",
clientId: "default-client",
enabled: true,
},
secondary,
},
},
},
} as ClawdbotConfig;
const snapshot = twitchPlugin.status.buildAccountSnapshot({
account: secondary,
cfg,
});
expect(snapshot.accountId).toBe("secondary");
});
});

View File

@ -212,7 +212,7 @@ export const twitchPlugin: ChannelPlugin<TwitchAccountConfig> = {
DEFAULT_ACCOUNT_ID;
const tokenResolution = resolveTwitchToken(cfg, { accountId: resolvedAccountId });
return {
accountId: DEFAULT_ACCOUNT_ID,
accountId: resolvedAccountId,
enabled: account?.enabled !== false,
configured: isAccountConfigured(account, tokenResolution.token),
running: runtime?.running ?? false,