From 68b87f3bffcebc5b91ac4330f5d7ccefd2809a3c Mon Sep 17 00:00:00 2001 From: canisminor1990 Date: Tue, 10 Sep 2024 12:55:39 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=85=20test:=20Fix=20test?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../model/[slug]/features/ChatWithModel.tsx | 15 +++++++++++---- src/app/api/assistant/[id]/route.ts | 2 -- src/app/api/assistant/store/route.ts | 2 -- src/app/api/plugin/store/route.ts | 2 -- src/services/__tests__/tool.test.ts | 2 +- 5 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/app/(main)/discover/(detail)/model/[slug]/features/ChatWithModel.tsx b/src/app/(main)/discover/(detail)/model/[slug]/features/ChatWithModel.tsx index fa67201967eb0..461c9337c92ad 100644 --- a/src/app/(main)/discover/(detail)/model/[slug]/features/ChatWithModel.tsx +++ b/src/app/(main)/discover/(detail)/model/[slug]/features/ChatWithModel.tsx @@ -10,8 +10,6 @@ import { memo } from 'react'; import { useTranslation } from 'react-i18next'; import urlJoin from 'url-join'; -import { BASE_PROVIDER_DOC_URL } from '@/const/url'; - import { useProviderList } from '../../../../features/useProviderList'; const useStyles = createStyles(({ css }) => ({ @@ -32,7 +30,7 @@ const ChatWithModel = memo<{ providers?: string[] }>(({ providers = [] }) => { const items = list.map((item) => ({ key: item.id, label: ( - + {[item.name, t('models.guide')].join(' ')} ), @@ -60,6 +58,15 @@ const ChatWithModel = memo<{ providers?: string[] }>(({ providers = [] }) => { ); + if (items.length === 1) + return ( + + + + ); + return ( (({ providers = [] }) => { style={{ flex: 1, width: 'unset' }} type={'primary'} > - {t('models.chat')} + {t('models.guide')} ); diff --git a/src/app/api/assistant/[id]/route.ts b/src/app/api/assistant/[id]/route.ts index 8c2a234cf3dc0..1b45cd9e5ab82 100644 --- a/src/app/api/assistant/[id]/route.ts +++ b/src/app/api/assistant/[id]/route.ts @@ -3,8 +3,6 @@ import { AssistantStore } from '@/server/modules/AssistantStore'; export const runtime = 'edge'; -export const revalidate = 3600 * 12; // revalidate - export const GET = async (req: Request, { params }: { params: { id: string } }) => { const { searchParams } = new URL(req.url); diff --git a/src/app/api/assistant/store/route.ts b/src/app/api/assistant/store/route.ts index 771b766c4daf2..dd8150d5e57f7 100644 --- a/src/app/api/assistant/store/route.ts +++ b/src/app/api/assistant/store/route.ts @@ -3,8 +3,6 @@ import { AssistantStore } from '@/server/modules/AssistantStore'; export const runtime = 'edge'; -export const revalidate = 3600; // revalidate at almost every hour - export const GET = async (req: Request) => { const locale = new URL(req.url).searchParams.get('locale'); diff --git a/src/app/api/plugin/store/route.ts b/src/app/api/plugin/store/route.ts index 0cffecfc82bb1..aaf7fa3dc456b 100644 --- a/src/app/api/plugin/store/route.ts +++ b/src/app/api/plugin/store/route.ts @@ -3,8 +3,6 @@ import { PluginStore } from '@/server/modules/PluginStore'; export const runtime = 'edge'; -export const revalidate = 3600 * 12; // revalidate at almost every 12 hours - export const GET = async (req: Request) => { const locale = new URL(req.url).searchParams.get('locale'); diff --git a/src/services/__tests__/tool.test.ts b/src/services/__tests__/tool.test.ts index 04cc615dd2b1e..8e69fb9978901 100644 --- a/src/services/__tests__/tool.test.ts +++ b/src/services/__tests__/tool.test.ts @@ -36,7 +36,7 @@ describe('ToolService', () => { // Assert expect(globalHelpers.getCurrentLanguage).toHaveBeenCalled(); expect(fetch).toHaveBeenCalledWith('/api/plugin/store?locale=tt'); - expect(pluginList).toEqual(fakeResponse); + expect(pluginList).toEqual(fakeResponse.plugins); }); it('should handle fetch error', async () => {