mirror of
https://github.com/tiennm99/ccs.git
synced 2026-10-17 04:14:32 +00:00
feat(cliproxy): separate core and plus provider sections
This commit is contained in:
1 parent
0357f4fee4
commit
f6c86b79fc
10 files changed
+355
-48
No files matched your search
@@ -51,4 +51,28 @@ describe('ProviderInfoTab', () => {
|
||||
expect(screen.queryByText('Change model')).not.toBeInTheDocument();
|
||||
expect(screen.getByText('ccs custom-provider --auth --add')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('shows the plus-extra track note for community-maintained providers', () => {
|
||||
render(
|
||||
<ProviderInfoTab
|
||||
provider="cursor"
|
||||
displayName="Cursor"
|
||||
defaultTarget="claude"
|
||||
authStatus={{
|
||||
...authenticatedStatus,
|
||||
provider: 'cursor',
|
||||
displayName: 'Cursor',
|
||||
}}
|
||||
supportsModelConfig
|
||||
/>
|
||||
);
|
||||
|
||||
expect(screen.getByText('Track')).toBeInTheDocument();
|
||||
expect(screen.getByText('Plus extras / community-maintained')).toBeInTheDocument();
|
||||
expect(
|
||||
screen.getByText(
|
||||
/Requires the optional Plus backend while that track remains community-maintained\./
|
||||
)
|
||||
).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
@@ -2,6 +2,23 @@ import { beforeEach, describe, expect, it, vi } from 'vitest';
|
||||
import { render, screen, userEvent } from '@tests/setup/test-utils';
|
||||
|
||||
const hookState = vi.hoisted(() => ({
|
||||
authData: {
|
||||
authStatus: [
|
||||
{
|
||||
provider: 'gemini',
|
||||
displayName: 'Gemini',
|
||||
authenticated: true,
|
||||
accounts: [{ id: 'acct-1', provider: 'gemini' }],
|
||||
},
|
||||
{
|
||||
provider: 'ghcp',
|
||||
displayName: 'GitHub Copilot (OAuth)',
|
||||
authenticated: false,
|
||||
accounts: [],
|
||||
},
|
||||
],
|
||||
source: 'local' as const,
|
||||
},
|
||||
catalogData: undefined as
|
||||
| {
|
||||
catalogs: Record<
|
||||
@@ -23,17 +40,7 @@ vi.mock('@/hooks/use-cliproxy', () => ({
|
||||
isFetching: false,
|
||||
}),
|
||||
useCliproxyAuth: () => ({
|
||||
data: {
|
||||
authStatus: [
|
||||
{
|
||||
provider: 'gemini',
|
||||
displayName: 'Gemini',
|
||||
authenticated: true,
|
||||
accounts: [{ id: 'acct-1', provider: 'gemini' }],
|
||||
},
|
||||
],
|
||||
source: 'local',
|
||||
},
|
||||
data: hookState.authData,
|
||||
isLoading: false,
|
||||
}),
|
||||
useCliproxyCatalog: () => ({
|
||||
@@ -85,9 +92,39 @@ import { CliproxyPage } from '@/pages/cliproxy';
|
||||
|
||||
describe('CliproxyPage add-account catalog gating', () => {
|
||||
beforeEach(() => {
|
||||
hookState.authData = {
|
||||
authStatus: [
|
||||
{
|
||||
provider: 'gemini',
|
||||
displayName: 'Gemini',
|
||||
authenticated: true,
|
||||
accounts: [{ id: 'acct-1', provider: 'gemini' }],
|
||||
},
|
||||
{
|
||||
provider: 'ghcp',
|
||||
displayName: 'GitHub Copilot (OAuth)',
|
||||
authenticated: false,
|
||||
accounts: [],
|
||||
},
|
||||
],
|
||||
source: 'local',
|
||||
};
|
||||
hookState.catalogData = undefined;
|
||||
});
|
||||
|
||||
it('separates core providers from plus extras in the sidebar', () => {
|
||||
render(<CliproxyPage />);
|
||||
|
||||
expect(screen.getByText('Core / original backend')).toBeInTheDocument();
|
||||
expect(screen.getByText('Plus extras / community-maintained')).toBeInTheDocument();
|
||||
expect(screen.getByText('Default, always-available provider track')).toBeInTheDocument();
|
||||
expect(
|
||||
screen.getByText('Still supported, but separated from the default backend for now')
|
||||
).toBeInTheDocument();
|
||||
expect(screen.getByText('Gemini')).toBeInTheDocument();
|
||||
expect(screen.getByText('GitHub Copilot (OAuth)')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('does not pass a static fallback catalog before the catalog query resolves', async () => {
|
||||
render(<CliproxyPage />);
|
||||
|
||||
|
||||
@@ -1,14 +1,20 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
|
||||
import {
|
||||
CLIPROXY_PROVIDER_SECTIONS,
|
||||
CORE_CLIPROXY_PROVIDERS,
|
||||
formatRequestedUpstreamModelRules,
|
||||
getProviderDescription,
|
||||
getProviderDisplayName,
|
||||
getProviderFallbackVisual,
|
||||
getProviderLogoAsset,
|
||||
getProviderSection,
|
||||
getRequestedUpstreamModelRuleErrors,
|
||||
getRequestedModelId,
|
||||
groupProvidersBySection,
|
||||
isPlusExtraProvider,
|
||||
parseRequestedUpstreamModelRules,
|
||||
PLUS_EXTRA_CLIPROXY_PROVIDERS,
|
||||
PROVIDER_COLORS,
|
||||
} from '@/lib/provider-config';
|
||||
|
||||
@@ -49,6 +55,40 @@ describe('provider model mapping helpers', () => {
|
||||
});
|
||||
|
||||
describe('provider presentation metadata', () => {
|
||||
it('splits providers into core and plus-extra sections', () => {
|
||||
expect(CLIPROXY_PROVIDER_SECTIONS.map((section) => section.id)).toEqual(['core', 'plus-extra']);
|
||||
expect(CORE_CLIPROXY_PROVIDERS).toContain('gemini');
|
||||
expect(CORE_CLIPROXY_PROVIDERS).toContain('kimi');
|
||||
expect(PLUS_EXTRA_CLIPROXY_PROVIDERS).toEqual([
|
||||
'kiro',
|
||||
'ghcp',
|
||||
'cursor',
|
||||
'gitlab',
|
||||
'codebuddy',
|
||||
'kilo',
|
||||
]);
|
||||
expect(getProviderSection('gitlab')?.id).toBe('plus-extra');
|
||||
expect(getProviderSection('gemini')?.id).toBe('core');
|
||||
expect(isPlusExtraProvider('cursor')).toBe(true);
|
||||
expect(isPlusExtraProvider('gemini')).toBe(false);
|
||||
});
|
||||
|
||||
it('groups provider-backed data by shared section metadata', () => {
|
||||
const grouped = groupProvidersBySection(
|
||||
[
|
||||
{ provider: 'cursor', value: 'plus' },
|
||||
{ provider: 'gemini', value: 'core' },
|
||||
],
|
||||
(entry) => entry.provider
|
||||
);
|
||||
|
||||
expect(grouped).toHaveLength(2);
|
||||
expect(grouped[0]?.id).toBe('core');
|
||||
expect(grouped[0]?.items.map((entry) => entry.provider)).toEqual(['gemini']);
|
||||
expect(grouped[1]?.id).toBe('plus-extra');
|
||||
expect(grouped[1]?.items.map((entry) => entry.provider)).toEqual(['cursor']);
|
||||
});
|
||||
|
||||
it.each([
|
||||
['cursor', 'Cursor', 'Cursor browser-authenticated provider', '/assets/sidebar/cursor.svg'],
|
||||
['gitlab', 'GitLab Duo', 'GitLab Duo with OAuth or PAT auth', '/assets/providers/gitlab.svg'],
|
||||
|
||||
Reference in new issue
Block a user