Files
supabase/apps/studio/components/interfaces/Settings/API/DataApiEnableSwitch.utils.test.ts
T
Charis c7dcda5644 feat(studio): move data api settings to integrations (#42711)
Feature

## What is the current behavior?

Data API settings live under Project Settings.

## What is the new behavior?

Data API settings are moved to the Integrations page, treating Data API
as a platform integration. Includes security checks when toggling on the
Data API to prevent unintended exposure of project data.

## Additional context

Towards FE-2517

## Summary by CodeRabbit

* **New Features**
* Added a Data API integration with Overview and Settings pages,
endpoint display, and enable/disable toggle with safety checks and
confirmation flow.
* **Navigation Changes**
* Data API moved from Project Settings into the Integrations area and
routes now redirect to the new Overview page.
* **Documentation**
* Added an overview doc describing Data API endpoints and configuration.
* **Tests**
* Added unit tests for endpoint resolution and schema parsing utilities.
2026-02-12 15:18:39 +00:00

43 lines
1.2 KiB
TypeScript

import { describe, expect, it } from 'vitest'
import type { EnableCheckState } from './DataApiEnableSwitch.types'
import { enableCheckReducer, getDefaultSchemas } from './DataApiEnableSwitch.utils'
describe('getDefaultSchemas', () => {
it('returns ["public"] for undefined', () => {
expect(getDefaultSchemas(undefined)).toEqual(['public'])
})
it('returns ["public"] for null', () => {
expect(getDefaultSchemas(null)).toEqual(['public'])
})
it('returns ["public"] for empty string', () => {
expect(getDefaultSchemas('')).toEqual(['public'])
})
it('returns ["public"] for whitespace-only string', () => {
expect(getDefaultSchemas(' , , ')).toEqual(['public'])
})
it('parses a single schema', () => {
expect(getDefaultSchemas('api')).toEqual(['api'])
})
it('parses multiple comma-separated schemas', () => {
expect(getDefaultSchemas('public, storage, graphql_public')).toEqual([
'public',
'storage',
'graphql_public',
])
})
it('trims whitespace from schemas', () => {
expect(getDefaultSchemas(' public , storage ')).toEqual(['public', 'storage'])
})
it('filters out empty segments', () => {
expect(getDefaultSchemas('public,,storage,')).toEqual(['public', 'storage'])
})
})