Files
supabase/apps/studio/components/interfaces/Workers/workerSnippets.test.ts
Jordi Enric 55706ca61b fix(workers): support private deployments FE-4328 (#49902)
## Problem

The dashboard's Workers snippets said that the CLI could only deploy
public Workers and generated the obsolete access configuration field.

## Fix

Use the CLI and backend exposure field in generated config, CLI, and AI
snippets so private Worker deployments are supported.

## How to test

- Run: pnpm --filter studio test
components/interfaces/Workers/workerSnippets.test.ts
- Expected result: all 11 tests pass, including private Worker snippets
using --exposure private.

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **Improvements**
- Worker deployment snippets now pass the selected exposure setting
directly to the CLI.
  - Generated `config.toml` files now use the `exposure` setting.
- AI deployment guidance now documents the exposure flag, helping
clarify deployment configuration.

- **Changes**
- Removed the previous private-worker warning and public-only deployment
note from deployment guidance.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-09-02 16:30:07 +02:00

28 lines
906 B
TypeScript

import { describe, expect, it } from 'vitest'
import { buildWorkerCliCommands, buildWorkerSnippets, EXAMPLE_WORKER } from './workerSnippets'
const input = (overrides: Partial<Parameters<typeof buildWorkerSnippets>[0]> = {}) => ({
...EXAMPLE_WORKER,
endpoint: 'abcdefgh.supabase.co',
...overrides,
})
describe('buildWorkerSnippets', () => {
it('passes private exposure to the CLI and config', () => {
const { cli, configToml } = buildWorkerSnippets(input({ access: 'private' }))
expect(cli).toContain('--exposure private')
expect(configToml).toContain('exposure = "private"')
})
})
describe('buildWorkerCliCommands', () => {
it('targets the requested worker in every management command', () => {
const commands = buildWorkerCliCommands('embed')
expect(commands).toHaveLength(4)
expect(commands.every(({ command }) => command.includes('embed'))).toBe(true)
})
})