Files
supabase/apps/studio/components/interfaces/Integrations/Integration/IntegrationOverviewTab.test.tsx
T
Francesco SansalvadoreandJoshen Lim 7edbedcbec fix integration overview tab contents (#46179)
Restores proper content in new marketplace detail overview pages
compared to the legacy overview pages.

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **New Features**
* Added Data API URL settings and a visible "Required extensions"
section across integration overviews.
* Unified install/manage UIs for webhooks, Stripe Sync, wrappers,
queues, and others; marketplace mode now shows marketplace-specific
overview content.

* **Style**
* Improved marketplace detail rail and filter-bar button styling;
refined list/link row visuals.

* **Refactor**
* Overview pages reorganized to branch on marketplace mode and extract
shared overview content for consistency.

* **Tests**
  * Stabilized integration overview test data for deterministic runs.

<!-- review_stack_entry_start -->

[![Review Change
Stack](https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg)](https://app.coderabbit.ai/change-stack/supabase/supabase/pull/46179?utm_source=github_walkthrough&utm_medium=github&utm_campaign=change_stack)

<!-- review_stack_entry_end -->
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
2026-05-25 09:08:38 +02:00

97 lines
2.8 KiB
TypeScript

import { screen } from '@testing-library/dom'
import { mockAnimationsApi } from 'jsdom-testing-mocks'
import { beforeEach, describe, expect, it, vi } from 'vitest'
import { IntegrationOverviewTab } from './IntegrationOverviewTab'
import { customRender } from '@/tests/lib/custom-render'
import { routerMock } from '@/tests/lib/route-mock'
mockAnimationsApi()
vi.mock('../Landing/Integrations.constants', () => ({
INTEGRATIONS: [
{
id: 'test-integration',
name: 'Test Integration',
requiredExtensions: ['pg_net'],
},
],
}))
vi.mock('framer-motion', async (importOriginal) => {
const actual = (await importOriginal()) as any
return {
...actual,
motion: {
...actual.motion,
div: ({ children, ...props }: any) => <div {...props}>{children}</div>,
},
}
})
const mockExtensions = vi.fn()
vi.mock('@/data/database-extensions/database-extensions-query', () => ({
useDatabaseExtensionsQuery: () => ({ data: mockExtensions() }),
}))
vi.mock('@/hooks/misc/useSelectedProject', () => ({
useSelectedProjectQuery: () => ({
data: { ref: 'default', connectionString: 'postgres://localhost' },
}),
useIsOrioleDb: () => false,
}))
vi.mock('common', async (importOriginal) => {
const actual = (await importOriginal()) as any
return {
...actual,
useParams: () => ({ id: 'test-integration', ref: 'default' }),
}
})
vi.mock('./MarkdownContent', () => ({
MarkdownContent: () => null,
}))
vi.mock('../Landing/useIntegrationDetail', () => ({
useIntegrationDetail: () => ({
integration: {
id: 'test-integration',
name: 'Test Integration',
requiredExtensions: ['pg_net'],
missingExtensionsAlert: null,
},
}),
}))
describe('IntegrationOverviewTab', () => {
beforeEach(() => {
routerMock.setCurrentUrl('/project/default/integrations/test-integration/overview')
mockExtensions.mockReturnValue([
{ name: 'pg_net', installed_version: null, default_version: '0.6.0' },
])
})
it('does not disable actions when hideRequiredExtensionsSection is true and extensions are uninstalled', () => {
customRender(
<IntegrationOverviewTab
hideRequiredExtensionsSection
actions={<button>Enable webhooks</button>}
/>
)
const actionsArea = screen.getByText('Enable webhooks').closest('[aria-disabled]')
expect(actionsArea).toHaveAttribute('aria-disabled', 'false')
expect(actionsArea).not.toHaveClass('opacity-25')
})
it('disables actions when extensions are uninstalled and hideRequiredExtensionsSection is false', () => {
customRender(<IntegrationOverviewTab actions={<button>Enable integration</button>} />)
const actionsArea = screen.getByText('Enable integration').closest('[aria-disabled]')
expect(actionsArea).toHaveAttribute('aria-disabled', 'true')
expect(actionsArea).toHaveClass('opacity-25')
})
})