Files
supabase/apps/studio/components/interfaces/Database/Replication/CreatePipeline/PipelineConnectionValidation.utils.test.ts
T
Danny White 8047d93e3c feat(studio): validate pipeline wizard connections (#51818)
## Problem

The pipeline wizard from #51776 allows users to continue without valid
destination credentials. This is the next slice of #49243.

## Solution

- Validate connection fields for all four destinations using the
existing schemas and helpers.
- Validate the destination on **Continue** and advance to Data on
success. Show field errors and connection failures inline; pause for
warnings before continuing.
- Require a new check after connection settings change and block
browser-history shortcuts past an unverified connection.

| Errored Test | Success Test |
| --- | --- |
| <img width="1532" height="2062" alt="CleanShot 2026-10-16 at 12 19
51@2x"
src="https://github.com/user-attachments/assets/a40a6c01-ee89-4601-b5d7-6ffc85071dc7"
/> | <img width="1500" height="1950" alt="CleanShot 2026-10-16 at 12 18
33@2x"
src="https://github.com/user-attachments/assets/c50c1ad4-256b-44b5-bd06-ec0685aae759"
/> |
 
The screenshots show earlier test states; successful checks now advance
directly to Data.

Data validation and pipeline creation remain for later slices. **Start
pipeline** stays disabled.

## Review instructions

1. Open the [Pipelines
preview](https://studio-staging-git-dnywh-featpipeline-connectio-eb9566-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-connectio-eb9566-supabase.vercel.app/dashboard/project/_/database/pipelines/new)
for that project.
2. Choose a destination and click **Continue** with empty or invalid
fields. Check the errors, then enter valid credentials and retry. A
failed check keeps your values. A failed result stays visible while
editing, until retry or destination change. Changed settings still
require a fresh check. A successful check opens Data automatically;
warnings remain for review before continuing.
3. Continue to Data, return to Connection and change a credential or
advanced connection setting. Check that browser **Forward** cannot skip
the new check, then click **Continue** to validate again.
2026-10-19 10:15:08 +11:00

60 lines
2.2 KiB
TypeScript

import { describe, expect, it } from 'vitest'
import { generateDefaultValues } from '../DestinationPanel/DestinationForm/DestinationForm.utils'
import {
getConnectionFieldNames,
getConnectionValidationIssues,
} from './PipelineConnectionValidation.utils'
const validData = {
...generateDefaultValues({ catalogToken: '', editMode: false }),
name: 'Warehouse',
projectId: 'project',
datasetId: 'dataset',
serviceAccountKey: '{}',
ducklakeMode: 'custom' as const,
ducklakeCatalogUrl: 'postgresql://user:password@host/catalog',
ducklakeDataPath: 's3://bucket/data',
ducklakeS3AccessKeyId: 'key',
ducklakeS3SecretAccessKey: 'secret',
ducklakeS3Region: 'us-east-1',
ducklakeS3Endpoint: 's3.us-east-1.amazonaws.com',
snowflakeAccountId: 'account',
snowflakeUser: 'user',
snowflakePrivateKey: '-----BEGIN PRIVATE KEY-----\nkey\n-----END PRIVATE KEY-----',
snowflakeDatabase: 'database',
snowflakeSchema: 'PUBLIC',
clickhouseUrl: 'https://host:8443',
clickhouseUser: 'default',
clickhousePassword: 'password',
clickhouseDatabase: 'database',
}
describe('connection validation', () => {
it.each(['BigQuery', 'DuckLake', 'Snowflake', 'ClickHouse'] as const)(
'validates %s independently of unfilled data fields and other destinations',
(type) => {
expect(getConnectionValidationIssues(type, validData)).toEqual([])
expect(getConnectionValidationIssues(type, { ...validData, name: ' ' })).toContainEqual({
path: 'name',
message: 'Name is required.',
})
const fields = getConnectionFieldNames(type)
expect(fields).toContain('name')
expect(fields).not.toContain('publicationName')
expect(fields).not.toContain('tableOptions')
}
)
it.each([
['BigQuery', { serviceAccountKey: 'invalid' }, 'serviceAccountKey'],
['DuckLake', { ducklakeCatalogUrl: '' }, 'ducklakeCatalogUrl'],
['Snowflake', { snowflakePrivateKey: 'invalid' }, 'snowflakePrivateKey'],
['ClickHouse', { clickhouseUrl: '' }, 'clickhouseUrl'],
] as const)('rejects invalid %s connection settings (%s)', (type, changes, path) => {
expect(getConnectionValidationIssues(type, { ...validData, ...changes })).toEqual(
expect.arrayContaining([expect.objectContaining({ path })])
)
})
})