mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-05 12:24:30 +01:00
test(frontend): cover differing provider integration IDs
This commit is contained in:
1 parent
f1868ad3e3
commit
ed7ec938f1
1 file changed
+22
-1
@@ -85,9 +85,10 @@ vi.mock('@/components/ui/delete-dialog', () => ({
|
||||
}) => (open ? <button onClick={onConfirm}>Confirm delete</button> : null),
|
||||
}))
|
||||
|
||||
function providerFixture(id: string, name: string, modelCount: number): Provider {
|
||||
function providerFixture(id: string, name: string, modelCount: number, integrationID?: string): Provider {
|
||||
return {
|
||||
id,
|
||||
integrationID,
|
||||
name,
|
||||
models: Array.from({ length: modelCount }, (_, index) => ({
|
||||
id: `model-${index}`,
|
||||
@@ -321,6 +322,26 @@ describe('ProviderSettings', () => {
|
||||
expect(screen.getByTestId('api-key-dialog')).toHaveTextContent('OpenRouter')
|
||||
})
|
||||
|
||||
it('uses integration IDs for provider entries when catalog IDs differ', async () => {
|
||||
vi.mocked(getProviders).mockResolvedValue({
|
||||
providers: [providerFixture('catalog-anthropic', 'Anthropic Catalog', 2, 'anthropic')],
|
||||
models: [],
|
||||
})
|
||||
vi.mocked(oauthApi.getIntegrations).mockResolvedValue([
|
||||
integrationFixture('anthropic', 'Anthropic Integration', [oauthMethod], true),
|
||||
])
|
||||
const user = userEvent.setup()
|
||||
renderSettings()
|
||||
|
||||
await screen.findByText('Anthropic Integration')
|
||||
expect(screen.getByText('2 models')).toBeInTheDocument()
|
||||
expect(screen.getByText('Connected')).toBeInTheDocument()
|
||||
|
||||
await user.click(screen.getByRole('button', { name: 'Reconnect' }))
|
||||
expect(screen.getByTestId('oauth-authorize-dialog')).toHaveTextContent('anthropic')
|
||||
expect(screen.queryByText('catalog-anthropic')).not.toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('lists OAuth integrations that are not in the active catalog', async () => {
|
||||
vi.mocked(getProviders).mockResolvedValue({ providers: [], models: [] })
|
||||
vi.mocked(oauthApi.getIntegrations).mockResolvedValue([
|
||||
|
||||
Reference in new issue
Block a user