Skip to content

Commit

Permalink
✅ test: Fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
canisminor1990 committed Sep 10, 2024
1 parent ffcc428 commit 0ca0bf4
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 }) => ({
Expand All @@ -32,7 +30,7 @@ const ChatWithModel = memo<{ providers?: string[] }>(({ providers = [] }) => {
const items = list.map((item) => ({
key: item.id,
label: (
<Link href={urlJoin(BASE_PROVIDER_DOC_URL, item.id)} target={'_blank'}>
<Link href={urlJoin('/discover/provider', item.id)}>
{[item.name, t('models.guide')].join(' ')}
</Link>
),
Expand Down Expand Up @@ -60,6 +58,15 @@ const ChatWithModel = memo<{ providers?: string[] }>(({ providers = [] }) => {
</Dropdown.Button>
);

if (items.length === 1)
return (
<Link href={urlJoin('/discover/provider', items[0].key)} style={{ flex: 1 }}>
<Button block className={styles.button} size={'large'} type={'primary'}>
{t('models.guide')}
</Button>
</Link>
);

return (
<Dropdown
menu={{
Expand All @@ -73,7 +80,7 @@ const ChatWithModel = memo<{ providers?: string[] }>(({ providers = [] }) => {
style={{ flex: 1, width: 'unset' }}
type={'primary'}
>
{t('models.chat')}
{t('models.guide')}
</Button>
</Dropdown>
);
Expand Down
2 changes: 0 additions & 2 deletions src/app/api/assistant/[id]/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 0 additions & 2 deletions src/app/api/assistant/store/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down
2 changes: 0 additions & 2 deletions src/app/api/plugin/store/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down
2 changes: 1 addition & 1 deletion src/services/__tests__/tool.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down

0 comments on commit 0ca0bf4

Please sign in to comment.