Files
supabase/apps/studio/components/interfaces/Database/Replication/CreatePipeline/PipelineDataValidation.utils.test.ts
T
Danny White 25ede7243e feat(studio): validate pipeline wizard data settings (#51821)
## Problem

The pipeline wizard lets users reach Review without a valid publication
or initial-sync selection. This is a slice of #49243, following the
merged #51818.

## Solution

- Refresh publication metadata on **Continue** and reject unavailable
publications or removed initial-sync tables.
- Validate initial-sync and advanced data settings, reveal invalid
fields and preserve values for retry.
- Block browser-history shortcuts to Review after data settings change.

| Normal State | Error State (Expanded) |
| --- | --- |
| <img width="1486" height="1010" alt="CleanShot 2026-10-16 at 13 18
25@2x"
src="https://github.com/user-attachments/assets/74ec0785-3bd4-407a-aa3c-7fe69c338488"
/> | <img width="1506" height="2516" alt="CleanShot 2026-10-16 at 13 21
27@2x"
src="https://github.com/user-attachments/assets/6193d8c4-ab9d-47ca-9d9d-1a31198145d1"
/> |

Pipeline creation and navigation-out guards remain for later slices.
**Start pipeline** stays disabled.

## Review instructions

1. Open the [Pipelines
preview](https://studio-staging-git-dnywh-featpipeline-data-validation-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-data-validation-supabase.vercel.app/dashboard/project/_/database/pipelines/new),
choose a destination, then enter credentials and test the connection to
reach Data.
2. Click **Continue** without a publication. Check the field error.
Select a publication, choose a selective initial-sync mode and leave its
table selection empty. Check Continue requires at least one table.
Select a table and confirm you can reach Review.
3. Return to Data. Enter a negative **Batch wait time** under **Advanced
settings**, collapse it and click Continue. Check it reopens with the
error. Correct it and continue, then use browser Back, change a data
setting and try browser Forward. Check you stay on Data until you click
Continue again.
4. For a stale-selection check, select an initial-sync table, remove it
from the publication in another tab, then click Continue. Check the
selection is rejected and your other values remain. A failed metadata
request should also keep values and allow retry with Continue.
2026-10-19 10:32:09 +11:00

75 lines
2.7 KiB
TypeScript

import { describe, expect, it } from 'vitest'
import { generateDefaultValues } from '../DestinationPanel/DestinationForm/DestinationForm.utils'
import { getDataValidationIssues } from './PipelineDataValidation.utils'
import type { ReplicationPublicationData } from '@/data/replication/publication-query'
const data = {
...generateDefaultValues({ catalogToken: '', editMode: false }),
publicationName: 'analytics',
}
const publication: ReplicationPublicationData = {
name: 'analytics',
config: { type: 'tables', tables: [], operations: ['insert'], publish_via_partition_root: false },
tables: [{ id: 1, name: 'orders', schema: 'public', kind: 'table', partition_parent_id: null }],
}
describe('getDataValidationIssues', () => {
it.each(['include_all_tables', 'skip_all_tables'] as const)(
'accepts %s without a table selection',
(tableSyncCopyMode) => {
expect(
getDataValidationIssues({ ...data, tableSyncCopyMode }, 'BigQuery', publication)
).toEqual([])
}
)
it.each(['include_tables', 'skip_tables'] as const)(
'requires current tables for %s',
(tableSyncCopyMode) => {
expect(
getDataValidationIssues(
{ ...data, tableSyncCopyMode, tableSyncCopyTableIds: ['1'] },
'BigQuery',
publication
)
).toEqual([])
for (const tableSyncCopyTableIds of [[], ['bad'], ['42']]) {
expect(
getDataValidationIssues(
{ ...data, tableSyncCopyMode, tableSyncCopyTableIds },
'BigQuery',
publication
)
).toEqual([expect.objectContaining({ path: 'tableSyncCopyTableIds' })])
}
}
)
it('rejects unavailable or mismatched publications and invalid advanced settings', () => {
expect(getDataValidationIssues(data, 'BigQuery')).toEqual([
expect.objectContaining({ path: 'publicationName' }),
])
expect(
getDataValidationIssues(data, 'BigQuery', { ...publication, name: 'other' })
).toHaveLength(1)
for (const path of [
'maxFillMs',
'maxTableSyncWorkers',
'maxCopyConnectionsPerTable',
] as const) {
expect(getDataValidationIssues({ ...data, [path]: -1 }, 'Snowflake', publication)).toEqual([
expect.objectContaining({ path }),
])
}
})
it('validates BigQuery table layouts only for BigQuery', () => {
const invalidLayout = {
...data,
tableOptions: [{ tableId: 1, partitionBy: { kind: 'time_column' as const, column: '' } }],
}
expect(getDataValidationIssues(invalidLayout, 'BigQuery', publication)).toEqual([
expect.objectContaining({ path: 'tableOptions.0.partitionBy.column' }),
])
expect(getDataValidationIssues(invalidLayout, 'Snowflake', publication)).toEqual([])
})
})