Tests: align media auth fixture with selection checks

This commit is contained in:
Gustavo Madeira Santana
2026-03-16 11:39:20 +00:00
parent d6aa9b516e
commit 5e4851ae2b

View File

@@ -12,12 +12,23 @@ import { withEnvAsync } from "../test-utils/env.js";
import { clearMediaUnderstandingBinaryCacheForTests } from "./runner.js";
import { createSafeAudioFixtureBuffer } from "./runner.test-utils.js";
vi.mock("../agents/model-auth.js", () => ({
resolveApiKeyForProvider: vi.fn(async () => ({
const resolveApiKeyForProviderMock = vi.hoisted(() =>
vi.fn(async () => ({
apiKey: "test-key", // pragma: allowlist secret
source: "test",
mode: "api-key",
})),
);
const hasAvailableAuthForProviderMock = vi.hoisted(() =>
vi.fn(async (...args: unknown[]) => {
const resolved = await resolveApiKeyForProviderMock(...args);
return Boolean(resolved?.apiKey);
}),
);
vi.mock("../agents/model-auth.js", () => ({
resolveApiKeyForProvider: resolveApiKeyForProviderMock,
hasAvailableAuthForProvider: hasAvailableAuthForProviderMock,
requireApiKey: (auth: { apiKey?: string; mode?: string }, provider: string) => {
if (auth?.apiKey) {
return auth.apiKey;
@@ -247,6 +258,7 @@ describe("applyMediaUnderstanding", () => {
source: "test",
mode: "api-key",
});
hasAvailableAuthForProviderMock.mockClear();
mockedFetchRemoteMedia.mockClear();
mockedRunExec.mockReset();
mockedFetchRemoteMedia.mockResolvedValue({