fix multi account id + add unit test
This commit is contained in:
parent
6d7305c901
commit
a2dfdb83a4
37
extensions/twitch/src/plugin.test.ts
Normal file
37
extensions/twitch/src/plugin.test.ts
Normal 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");
|
||||||
|
});
|
||||||
|
});
|
||||||
@ -212,7 +212,7 @@ export const twitchPlugin: ChannelPlugin<TwitchAccountConfig> = {
|
|||||||
DEFAULT_ACCOUNT_ID;
|
DEFAULT_ACCOUNT_ID;
|
||||||
const tokenResolution = resolveTwitchToken(cfg, { accountId: resolvedAccountId });
|
const tokenResolution = resolveTwitchToken(cfg, { accountId: resolvedAccountId });
|
||||||
return {
|
return {
|
||||||
accountId: DEFAULT_ACCOUNT_ID,
|
accountId: resolvedAccountId,
|
||||||
enabled: account?.enabled !== false,
|
enabled: account?.enabled !== false,
|
||||||
configured: isAccountConfigured(account, tokenResolution.token),
|
configured: isAccountConfigured(account, tokenResolution.token),
|
||||||
running: runtime?.running ?? false,
|
running: runtime?.running ?? false,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user