From 90c43356c19f2ac0f60dcc6aa9724bd382d25252 Mon Sep 17 00:00:00 2001 From: darkskygit Date: Wed, 2 Apr 2025 14:59:22 +0000 Subject: [PATCH] fix(server): copilot test condition (#11417) --- .../src/__tests__/copilot-provider.spec.ts | 44 +++++-------------- 1 file changed, 10 insertions(+), 34 deletions(-) diff --git a/packages/backend/server/src/__tests__/copilot-provider.spec.ts b/packages/backend/server/src/__tests__/copilot-provider.spec.ts index 18a6aae115..e97dd613b6 100644 --- a/packages/backend/server/src/__tests__/copilot-provider.spec.ts +++ b/packages/backend/server/src/__tests__/copilot-provider.spec.ts @@ -2,7 +2,7 @@ import type { ExecutionContext, TestFn } from 'ava'; import ava from 'ava'; import { z } from 'zod'; -import { ConfigModule } from '../base/config'; +import { ServerFeature, ServerService } from '../core'; import { AuthService } from '../core/auth'; import { QuotaModule } from '../core/quota'; import { CopilotModule } from '../plugins/copilot'; @@ -36,13 +36,7 @@ type Tester = { }; const test = ava as TestFn; -const isCopilotConfigured = - !!process.env.COPILOT_OPENAI_API_KEY && - !!process.env.COPILOT_FAL_API_KEY && - !!process.env.COPILOT_PERPLEXITY_API_KEY && - process.env.COPILOT_OPENAI_API_KEY !== '1' && - process.env.COPILOT_FAL_API_KEY !== '1' && - process.env.COPILOT_PERPLEXITY_API_KEY !== '1'; +let isCopilotConfigured = false; const runIfCopilotConfigured = test.macro( async ( t, @@ -59,30 +53,12 @@ const runIfCopilotConfigured = test.macro( test.serial.before(async t => { const module = await createTestingModule({ - imports: [ - ConfigModule.override({ - copilot: { - providers: { - openai: { - apiKey: process.env.COPILOT_OPENAI_API_KEY || '', - }, - fal: { - apiKey: process.env.COPILOT_FAL_API_KEY || '', - }, - perplexity: { - apiKey: process.env.COPILOT_PERPLEXITY_API_KEY || '', - }, - gemini: { - apiKey: process.env.COPILOT_GOOGLE_API_KEY || '', - }, - }, - }, - }), - QuotaModule, - CopilotModule, - ], + imports: [QuotaModule, CopilotModule], }); + const service = module.get(ServerService); + isCopilotConfigured = service.features.includes(ServerFeature.Copilot); + const auth = module.get(AuthService); const prompt = module.get(PromptService); const factory = module.get(CopilotProviderFactory); @@ -357,10 +333,10 @@ const actions = [ .trim(); t.notThrows(() => { z.object({ - speaker: z.string(), - start: z.string(), - end: z.string(), - transcription: z.string(), + a: z.string(), + s: z.number(), + e: z.number(), + t: z.string(), }) .array() .parse(JSON.parse(cleaned));