Files
supabase/apps/studio/components/interfaces/Database/Replication/DestinationPanel/ReadReplicasMovedCallout.test.tsx
Danny White 417b0fe13e feat(studio): show read replicas moved notice on Replication (#49355)
## What kind of change does this PR introduce?

Feature / communication. Resolves
[PIPE-1008](https://linear.app/supabase/issue/PIPE-1008/communicate-read-replica-move-changelog-leftover-ui-docs).

## What is the current behavior?

Database → Replication is now Pipelines-only. The “Read replicas have
moved” callout only appears inside the New destination sheet, so users
who land on Replication looking for replicas can miss it.
Getting-started already points create at Infrastructure but does not say
the management surface moved.

## What is the new behavior?

Replication shows the moved callout at the top of the page (flag-gated),
with a _Go to Infrastructure_ CTA. The same callout remains in the
destination-type sheet. Getting-started adds a short note that
management moved from Replication to Infrastructure.

This Admonition is dismissible, with its state stored in local storage.

| Before | After |
| --- | --- |
| <img width="1024" height="759" alt="64555"
src="https://github.com/user-attachments/assets/7084bd51-2f48-4a83-ac2a-89bdd3f23804"
/> | <img width="1024" height="759" alt="Replication Database Chisel
Toolshed Supabase"
src="https://github.com/user-attachments/assets/9b26c23a-1b44-4711-919b-c7000f155190"
/> |



## To test

`infrastructure:read_replicas` on by default.

1. Open [Database →
Replication](https://studio-staging-git-danny-pipe-1008-replication-moved-notice-supabase.vercel.app/dashboard/project/_/database/replication)
(preview URL once deployed). Confirm the note “Read replicas have moved”
and Go to Infrastructure.
2. Click the CTA: lands on Settings → Infrastructure.
3. Open New destination: callout still appears under the type selector.
4. Docs preview: getting-started Creating a Read Replica section shows
the move note.

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

## Summary by CodeRabbit

* **New Features**
* Added a callout informing users that read replicas are now managed
through Infrastructure.
* Added a direct link to the Infrastructure page from database
replication settings.
* Added the option to dismiss the callout, with dismissal saved per
project.
* Displayed the callout on the replication page and destination
selection view.

* **Bug Fixes**
* Updated callout visibility behavior to respect project settings and
prior dismissal.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-08-21 02:59:28 +00:00

67 lines
2.2 KiB
TypeScript

import { screen } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import { LOCAL_STORAGE_KEYS } from 'common'
import { beforeEach, describe, expect, test, vi } from 'vitest'
import { ReadReplicasMovedCallout } from './ReadReplicasMovedCallout'
import { customRender } from '@/tests/lib/custom-render'
const mockInfrastructureReadReplicas = vi.fn(() => true)
vi.mock('@/hooks/misc/useIsFeatureEnabled', () => ({
useIsFeatureEnabled: () => ({
infrastructureReadReplicas: mockInfrastructureReadReplicas(),
}),
}))
describe('ReadReplicasMovedCallout', () => {
beforeEach(() => {
mockInfrastructureReadReplicas.mockReturnValue(true)
window.localStorage.clear()
})
test('renders the notice with a link to Infrastructure', async () => {
customRender(<ReadReplicasMovedCallout />)
expect(await screen.findByText('Read replicas have moved')).toBeInTheDocument()
expect(screen.getByRole('link', { name: 'Go to Infrastructure' })).toHaveAttribute(
'href',
expect.stringContaining('/settings/infrastructure')
)
})
test('hides after dismiss and persists via localStorage', async () => {
const user = userEvent.setup()
customRender(<ReadReplicasMovedCallout />)
expect(await screen.findByText('Read replicas have moved')).toBeInTheDocument()
await user.click(screen.getByRole('button', { name: 'Dismiss read replicas moved notice' }))
expect(screen.queryByText('Read replicas have moved')).not.toBeInTheDocument()
expect(
window.localStorage.getItem(
LOCAL_STORAGE_KEYS.READ_REPLICAS_MOVED_CALLOUT_DISMISSED('default')
)
).toBe('true')
})
test('stays hidden when previously dismissed', async () => {
window.localStorage.setItem(
LOCAL_STORAGE_KEYS.READ_REPLICAS_MOVED_CALLOUT_DISMISSED('default'),
'true'
)
customRender(<ReadReplicasMovedCallout />)
await expect(screen.findByText('Read replicas have moved')).rejects.toThrow()
})
test('hides when Infrastructure read replicas are disabled', () => {
mockInfrastructureReadReplicas.mockReturnValue(false)
customRender(<ReadReplicasMovedCallout />)
expect(screen.queryByText('Read replicas have moved')).not.toBeInTheDocument()
})
})