mirror of
https://github.com/supabase/supabase.git
synced 2026-12-04 07:29:16 +00:00
## Problem The pipeline wizard can validate and review settings, but cannot create a pipeline. This is slice 13 of #49243, following #51823. ## Solution - Enable **Start pipeline** on Review using the sheet’s existing validation, creation and start requests. - Recheck publication settings, block critical failures and show warnings inline before **Start pipeline anyway**. - Preserve values after validation or create failures. Once creation succeeds, finish the start attempt and return to Pipelines, including when starting fails. | After | | --- | | <img width="1234" height="2470" alt="CleanShot 2026-10-19 at 11 22 44@2x" src="https://github.com/user-attachments/assets/23882092-26e2-4d23-b2a1-00d1d2dcba90" /> | **Add pipeline** still opens the sheet. Wizard entry remains behind **Pipeline creation wizard** at `/database/pipelines/new`; routing is the next slice. ## Review instructions 1. Open the [Pipelines preview](https://studio-staging-git-dnywh-featpipeline-review-creation-supabase.vercel.app/dashboard/project/_/database/pipelines), choose a test project and enable **Pipeline creation wizard** in Feature Previews. Open the [wizard preview](https://studio-staging-git-dnywh-featpipeline-review-creation-supabase.vercel.app/dashboard/project/_/database/pipelines/new) for that project. 2. Choose a destination, enter valid test credentials and select a publication. Continue to Review and check the settings, masked secrets and costs. Back and Continue should preserve your values. 3. Click **Start pipeline**. Controls should lock while submitting, then return to Pipelines with one new pipeline and no discard prompt. If warnings appear, review them before clicking **Start pipeline anyway**; critical failures must block creation. 4. Turn the preview off and open the wizard URL again: creation should use the existing sheet. Editing existing pipelines should also keep the sheet. Automated tests cover final validation, changed warnings, create retries, duplicate-click protection, removed publications and start failure recovery.
105 lines
3.9 KiB
TypeScript
105 lines
3.9 KiB
TypeScript
import {
|
|
createBrowserHistory,
|
|
createRootRoute,
|
|
createRouter,
|
|
RouterContextProvider,
|
|
} from '@tanstack/react-router'
|
|
import { act, renderHook, waitFor } from '@testing-library/react'
|
|
import { type ReactNode } from 'react'
|
|
import { describe, expect, it, vi } from 'vitest'
|
|
|
|
import { usePipelineNavigationGuard } from './usePipelineNavigationGuard'
|
|
|
|
const wizard = '/dashboard/project/test/database/pipelines/new'
|
|
const list = '/dashboard/project/test/database/pipelines'
|
|
|
|
const unload = () => {
|
|
const event = new Event('beforeunload', { cancelable: true })
|
|
window.dispatchEvent(event)
|
|
return event.defaultPrevented
|
|
}
|
|
|
|
describe('usePipelineNavigationGuard', () => {
|
|
it('reuses confirmation for explicit exits and bypasses unload only after discard', () => {
|
|
const exit = vi.fn()
|
|
const { result, rerender } = renderHook(({ dirty }) => usePipelineNavigationGuard(dirty), {
|
|
initialProps: { dirty: true },
|
|
})
|
|
act(() => result.current.requestNavigation(exit))
|
|
expect(result.current.modalProps.visible).toBe(true)
|
|
expect(unload()).toBe(true)
|
|
act(() => result.current.modalProps.onCancel())
|
|
expect(exit).not.toHaveBeenCalled()
|
|
expect(unload()).toBe(true)
|
|
act(() => result.current.requestNavigation(exit))
|
|
act(() => result.current.modalProps.onClose())
|
|
expect(exit).toHaveBeenCalledOnce()
|
|
expect(unload()).toBe(false)
|
|
rerender({ dirty: false })
|
|
expect(unload()).toBe(false)
|
|
})
|
|
|
|
it('leaves immediately without changes', () => {
|
|
const exit = vi.fn()
|
|
const { result } = renderHook(() => usePipelineNavigationGuard(false))
|
|
expect(unload()).toBe(false)
|
|
act(() => result.current.requestNavigation(exit))
|
|
expect(exit).toHaveBeenCalledOnce()
|
|
expect(result.current.modalProps.visible).toBe(false)
|
|
})
|
|
|
|
it('uses native TanStack history blocking for links and traversal, allowing step changes', async () => {
|
|
window.history.replaceState({}, '', list)
|
|
const history = createBrowserHistory()
|
|
history.push(wizard)
|
|
const router = createRouter({ routeTree: createRootRoute(), history })
|
|
const wrapper = ({ children }: { children: ReactNode }) => (
|
|
<RouterContextProvider router={router}>{children}</RouterContextProvider>
|
|
)
|
|
let isLocked = true
|
|
const { result, unmount } = renderHook(() => usePipelineNavigationGuard(true, () => isLocked), {
|
|
wrapper,
|
|
})
|
|
try {
|
|
await act(async () => history.push('/blocked-during-submission'))
|
|
expect(history.location.pathname).toBe(wizard)
|
|
expect(result.current.modalProps.visible).toBe(false)
|
|
await act(async () => history.push(`${wizard}?step=review`))
|
|
expect(history.location.search).toBe('')
|
|
isLocked = false
|
|
await act(async () => {
|
|
history.push(`${wizard}?step=connection`)
|
|
})
|
|
expect(history.location.search).toBe('?step=connection')
|
|
await act(async () => {
|
|
history.back()
|
|
})
|
|
await waitFor(() => expect(history.location.search).toBe(''))
|
|
expect(result.current.modalProps.visible).toBe(false)
|
|
await act(async () => {
|
|
history.back()
|
|
})
|
|
await waitFor(() => expect(result.current.modalProps.visible).toBe(true))
|
|
await act(async () => {
|
|
history.push('/another-page')
|
|
})
|
|
act(() => result.current.modalProps.onCancel())
|
|
await waitFor(() => expect(history.location.pathname).toBe(wizard))
|
|
await act(async () => {
|
|
history.forward()
|
|
})
|
|
await waitFor(() => expect(history.location.search).toBe('?step=connection'))
|
|
expect(result.current.modalProps.visible).toBe(false)
|
|
await act(async () => {
|
|
history.go(-2)
|
|
})
|
|
await waitFor(() => expect(result.current.modalProps.visible).toBe(true))
|
|
await act(async () => result.current.modalProps.onClose())
|
|
await waitFor(() => expect(history.location.pathname).toBe(list))
|
|
} finally {
|
|
unmount()
|
|
history.destroy()
|
|
}
|
|
})
|
|
})
|