import { describe, expect, it, vi } from "vitest" ;
import { baseConfigSnapshot, createTestRuntime } from "./test-runtime-config-helpers.js" ;
const mocks = vi.hoisted(() => ({
readConfigFileSnapshot: vi.fn(),
resolveCommandConfigWithSecrets: vi.fn(async ({ config }: { config: unknown }) => ({
resolvedConfig: config,
effectiveConfig: config,
diagnostics: [],
})),
loadAuthProfileStoreWithoutExternalProfiles: vi.fn(),
listChannelPlugins: vi.fn(() => []),
}));
vi.mock("../config/config.js" , () => ({
readConfigFileSnapshot: mocks.readConfigFileSnapshot,
}));
vi.mock("../cli/command-config-resolution.js" , () => ({
resolveCommandConfigWithSecrets: mocks.resolveCommandConfigWithSecrets,
}));
vi.mock("../cli/command-secret-targets.js" , () => ({
getChannelsCommandSecretTargetIds: () => new Set<string>(),
}));
vi.mock("../agents/auth-profiles.js" , () => ({
loadAuthProfileStoreWithoutExternalProfiles: mocks.loadAuthProfileStoreWithoutExternalProfiles,
}));
vi.mock("../channels/plugins/index.js" , () => ({
listChannelPlugins: mocks.listChannelPlugins,
}));
import { channelsListCommand } from "./channels/list.js" ;
describe("channels list auth profiles" , () => {
it("includes local auth profiles in JSON output without loading external profiles" , async () => {
const runtime = createTestRuntime();
mocks.readConfigFileSnapshot.mockResolvedValue({
...baseConfigSnapshot,
config: {},
});
mocks.loadAuthProfileStoreWithoutExternalProfiles.mockReturnValue({
version: 1 ,
profiles: {
"anthropic:default" : {
type: "oauth" ,
provider: "anthropic" ,
access: "token" ,
refresh: "refresh" ,
expires: 0 ,
created: 0 ,
},
"openai-codex:default" : {
type: "oauth" ,
provider: "openai" ,
access: "token" ,
refresh: "refresh" ,
expires: 0 ,
created: 0 ,
},
},
});
await channelsListCommand({ json: true , usage: false }, runtime);
expect(mocks.resolveCommandConfigWithSecrets).toHaveBeenCalledTimes(1 );
const payload = JSON.parse(runtime.log.mock.calls[0 ]?.[0 ] as string) as {
auth?: Array<{ id: string }>;
};
const ids = payload.auth?.map((entry) => entry.id) ?? [];
expect(ids).toContain("anthropic:default" );
expect(ids).toContain("openai-codex:default" );
});
});
Messung V0.5 in Prozent C=100 H=100 G=100
¤ Dauer der Verarbeitung: 0.10 Sekunden
(vorverarbeitet am 2026-06-10)
¤
*© Formatika GbR, Deutschland