Files
supabase/apps/studio/components/interfaces/Database/Replication/CreatePipeline/PipelineCreationHeader.test.tsx
Danny White 4593b3ffc0 feat(studio): compose pipeline creation step navigation (#51776)
## Problem

The pipeline wizard in #49243 needs its merged components composed into
a full-page flow, with values preserved when moving backwards and
forwards.

## Solution

- Compose four full-page SteppedFlow steps behind **Pipeline creation
wizard**.
- Preserve values through step navigation and browser Back/Forward.
Refresh starts at Destination.
- Reuse Studio’s header controls and confirm before discarding changes.
- Defer step validation and creation; **Start pipeline** is disabled.
**Add pipeline** and preview-off visits keep the sheet.

| After |
| --- |
| <img width="1024" height="759" alt="New Pipeline Supabase"
src="https://github.com/user-attachments/assets/7c3c4511-9a00-4e64-a86a-d6d9489f7d75"
/> |
| _Only available by navigating to `database/pipelines/new` with the
feature preview on._ |

## Review instructions

1. Open the [Pipelines
preview](https://studio-staging-git-dnywh-featpipeline-stepped-n-ce5307-supabase.vercel.app/dashboard/project/_/database/pipelines),
select a test project and enable **Pipeline creation wizard**. Open the
[wizard
preview](https://studio-staging-git-dnywh-featpipeline-stepped-n-ce5307-supabase.vercel.app/dashboard/project/_/database/pipelines/new)
for that project. Check the full-page layout and header at desktop and
phone widths.
2. Enter connection details, select a publication and change
initial-sync and advanced settings. Use **Back/Continue**, browser
**Back/Forward**, and switch destinations to confirm values remain.
3. Check Review shows your settings, masks secrets and disables **Start
pipeline**. Refresh and confirm it restarts at Destination. Incomplete
steps are allowed in this navigation-only slice.
4. With changes, try header navigation or **Close**. Check **Keep
editing** preserves values and **Discard changes** leaves the flow. Turn
the preview off and confirm the wizard URL opens the sheet.
2026-10-16 11:09:21 +11:00

55 lines
2.1 KiB
TypeScript

import { fireEvent, screen } from '@testing-library/react'
import { describe, expect, it, vi } from 'vitest'
import { PipelineCreationHeader } from './PipelineCreationHeader'
import { customRender } from '@/tests/lib/custom-render'
vi.mock('@/components/layouts/Navigation/LayoutHeader/HomeIcon', () => ({
HomeIcon: () => (
<a tabIndex={0} href="/organizations">
Supabase home
</a>
),
}))
vi.mock('@/components/layouts/AppLayout/OrganizationDropdown', () => ({
OrganizationDropdown: () => <span>Organization</span>,
}))
vi.mock('@/components/layouts/Navigation/NavigationBar/OrgSelector', async () => {
const { SidebarMenuButton } = await import('ui')
return { OrgSelector: () => <SidebarMenuButton>Organization</SidebarMenuButton> }
})
vi.mock('@/components/layouts/AppLayout/ProjectDropdown', async () => {
const { createPortal } = await import('react-dom')
return {
ProjectDropdown: () =>
createPortal(
<a tabIndex={0} href="/project/other/database/pipelines">
Project
</a>,
document.body
),
}
})
describe('PipelineCreationHeader', () => {
it('shows the project context and routes close through its handler', () => {
const onClose = vi.fn()
customRender(<PipelineCreationHeader onClose={onClose} onNavigate={vi.fn()} />)
expect(screen.getByRole('navigation', { name: 'Pipeline creation' })).toBeInTheDocument()
expect(screen.getByText('New pipeline')).toBeInTheDocument()
fireEvent.click(screen.getByRole('button', { name: 'Close' }))
expect(onClose).toHaveBeenCalledOnce()
})
it.each(['Supabase home', 'Project'])('guards navigation from %s', (name) => {
const onNavigate = vi.fn()
customRender(<PipelineCreationHeader onClose={vi.fn()} onNavigate={onNavigate} />)
const link = screen.getByRole('link', { name })
expect(fireEvent.click(link)).toBe(false)
expect(onNavigate).toHaveBeenCalledWith(
link.getAttribute('href') === '/organizations'
? 'http://localhost:3000/organizations'
: 'http://localhost:3000/project/other/database/pipelines'
)
})
})