mirror of
https://github.com/supabase/supabase.git
synced 2026-12-04 15:39:13 +00:00
The current add-ons page only lists a subset of available add-ons, which often causes confusion with things like Advanced MFA Auth (customers cant find where to configure it). The revised add-on page covers all potentially configured project add-ons including replicas and advanced disk. This should help the customer locate configured add-ons and at the same time discover potentially interesting add-ons. This can be enhanced further in the future with "smart" suggestions based on usage.
61 lines
2.0 KiB
TypeScript
61 lines
2.0 KiB
TypeScript
import { screen } from '@testing-library/react'
|
|
import userEvent from '@testing-library/user-event'
|
|
import { beforeEach, expect, test, vi } from 'vitest'
|
|
|
|
import { DocsButton } from './DocsButton'
|
|
import { customRender } from '@/tests/lib/custom-render'
|
|
|
|
const { track } = vi.hoisted(() => ({ track: vi.fn() }))
|
|
|
|
vi.mock('@/lib/telemetry/track', () => ({ useTrack: () => track }))
|
|
|
|
beforeEach(() => {
|
|
track.mockClear()
|
|
})
|
|
|
|
test('clicking tracks once with the topic', async () => {
|
|
const user = userEvent.setup()
|
|
customRender(<DocsButton href="https://supabase.com/docs/guides/auth" topic="Auth" />)
|
|
|
|
await user.click(screen.getByRole('link', { name: /auth documentation/i }))
|
|
|
|
expect(track).toHaveBeenCalledTimes(1)
|
|
expect(track).toHaveBeenCalledWith('docs_button_clicked', { topic: 'Auth' })
|
|
})
|
|
|
|
test('clicking without a topic omits the topic property', async () => {
|
|
const user = userEvent.setup()
|
|
customRender(<DocsButton href="https://supabase.com/docs/guides/auth" />)
|
|
|
|
await user.click(screen.getByRole('link', { name: 'Docs' }))
|
|
|
|
expect(track).toHaveBeenCalledTimes(1)
|
|
expect(track).toHaveBeenCalledWith('docs_button_clicked', {})
|
|
})
|
|
|
|
test('clicking does not bubble to a clickable parent', async () => {
|
|
const user = userEvent.setup()
|
|
const onParentClick = vi.fn()
|
|
customRender(
|
|
<div onClick={onParentClick}>
|
|
<DocsButton href="https://supabase.com/docs/guides/auth" />
|
|
</div>
|
|
)
|
|
|
|
await user.click(screen.getByRole('link', { name: 'Docs' }))
|
|
|
|
expect(onParentClick).not.toHaveBeenCalled()
|
|
})
|
|
|
|
test('icon-only keeps the topic in the accessible name and still tracks clicks', async () => {
|
|
const user = userEvent.setup()
|
|
customRender(<DocsButton iconOnly href="https://supabase.com/docs/guides/auth" topic="Auth" />)
|
|
|
|
const link = screen.getByRole('link', { name: 'Auth documentation (opens in new tab)' })
|
|
expect(link).not.toHaveTextContent('Docs')
|
|
|
|
await user.click(link)
|
|
|
|
expect(track).toHaveBeenCalledWith('docs_button_clicked', { topic: 'Auth' })
|
|
})
|