studio-e2e-tests

द्वारा supabase

Supabase Studio के लिए Playwright E2E परीक्षण लिखें और चलाएं। जब पूछा जाए तब उपयोग करें।

npx skills add https://github.com/supabase/supabase --skill studio-e2e-tests

Studio Playwright E2E Tests

End-to-end tests live in e2e/studio/features/*.spec.ts and cover critical user journeys (covering both mouse and keyboard interactions where each protects the journey) or platform vs self-hosted differences that unit/MSW tests cannot prove.

Running Tests

Always run from e2e/studio (omit -- so pnpm 12 forwards flags directly to Playwright):

cd e2e/studio && pnpm run e2e                               # full suite (auto-starts local containers, 3 workers)
cd e2e/studio && pnpm run e2e features/cron-jobs.spec.ts    # single file
cd e2e/studio && pnpm run e2e --grep "test name pattern"    # grep filter
cd e2e/studio && pnpm run e2e:ui                            # interactive UI mode

Self-hosted mode (IS_PLATFORM=false, CI unset) auto-starts local Supabase containers via Playwright's web server config once browsers are installed (cd e2e/studio && pnpm exec playwright install), provided nothing is already listening on port 8082.

Fixtures & File Setup

Always import test (providing page, ref, and Studio fixtures) from the custom harness:

import { test, withSetupCleanup } from '../utils/test.js'
import { withFileOnceSetup, releaseFileOnceCleanup } from '../utils/once-per-file.js'
  • Use test.describe.configure({ mode: 'serial' }) when tests in a file share database state.
  • Use withFileOnceSetup(import.meta.url, fn) / releaseFileOnceCleanup(import.meta.url) in beforeAll / afterAll for expensive one-time file setup (passing import.meta.url is required — an arbitrary string throws at runtime).
  • Dismiss toasts before clicking elements they can overlay:
    import { dismissToastsIfAny } from '../utils/dismiss-toast.js'
    await dismissToastsIfAny(page)
    

Selectors & Accessibility Sync

Prefer getByRole (with accessible name) -> getByTestId -> exact getByText over CSS/XPath/parent traversal (locator('..')), and scope to containers such as [data-radix-popper-content-wrapper] or a specific side panel test ID.

  • When an icon-only control lacks an accessible name, add one in the component:
    <Button aria-label="Configure API privileges">
      <SettingsIcon />
    </Button>
    
  • When improving accessible names on repeated row buttons (e.g. ${item.name} actions instead of "More options") or changing visible copy, update matching selectors in e2e/studio/ in the same PR.
  • Never bypass hidden controls with click({ force: true }) — hover or open the owning container first, assert visibility, then click.

Avoiding Race Conditions & Waits

Register API waiters BEFORE triggering the action or navigation. Setting up a waiter after .click() or .goto() is the primary cause of E2E flakes:

import { toUrl } from '../utils/to-url.js'
import { waitForApiResponse, waitForTableToLoad } from '../utils/wait-for-response.js'

// ✅ Single waiter registered before action
const createPromise = waitForApiResponse(page, 'pg-meta', ref, 'query?key=table-create')
await page.getByRole('button', { name: 'Save' }).click()
await createPromise

// ✅ Multiple required requests from one action — register BOTH strict waiters before clicking
const savePromise = waitForApiResponse(page, 'pg-meta', ref, 'query?key=table-create')
const tablesPromise = waitForApiResponse(page, 'pg-meta', ref, 'tables?include_columns=true')
await page.getByRole('button', { name: 'Save' }).click()
await Promise.all([savePromise, tablesPromise])

// ✅ Navigation
const loadPromise = waitForTableToLoad(page, ref)
await page.goto(toUrl(`/project/${ref}/editor?schema=public`))
await loadPromise
  • Use strict waitForApiResponse for required responses; reserve { soft: true, fallbackWaitMs: 1000 } or waitForApiResponseWithTimeout (from ../utils/wait-for-response-with-timeout.js, which resolves null on timeout) strictly for optional calls.
  • Avoid waitForLoadState('networkidle') and avoid waitForTimeout for UI or network waits (use explicit API waiters, expect(locator).toBeVisible(), waitForSelector(..., { state: 'detached' }), or expect.poll). The sole exception for waitForTimeout is waiting out a known client-side input debounce (e.g. 300ms).
  • Include descriptive messages on expect(locator, 'reason') and generous explicit timeouts ({ timeout: 30000 } / { timeout: 50000 }) on slow DB/DDL operations.

Studio Utilities & Mocking

  • Clipboard: Use expectClipboardValue instead of manual navigator.clipboard.readText() with sleeps:
    import { expectClipboardValue } from '../utils/clipboard.js'
    await expectClipboardValue({ page, value: 'expectedValue' })
    
  • API mocking: Stub external/analytics endpoints with await page.route('*/**/logs.all*', (route) => route.fulfill({ body: JSON.stringify(mock) })).
  • Domain helpers: Extract reusable flows into e2e/studio/utils/*-helpers.ts (see storage-helpers.ts, filter-bar-helpers.ts).

Cleanup

Prefer withSetupCleanup with await using so cleanup always runs on both pass and failure once setup resolves (keep setup atomic or handle partial-setup cleanup inside setup — if setup throws mid-way, the disposable is never registered). Always generate a unique resource name per run (e.g. createBucket no-ops on name collisions, so cleanup with a fixed/shared name could delete a seeded bucket or another test's data):

import { createBucket, deleteBucket } from '../utils/storage/index.js'

const bucketName = `test-bucket-${crypto.randomUUID().slice(0, 8)}`
await using _ = await withSetupCleanup(
  () => createBucket(bucketName),
  async () => {
    await deleteBucket(bucketName)
  }
)
  • If using manual try / finally, create the resource inside try and guard deletion on whether creation succeeded and !page.isClosed(). For UI cleanup, check (await row.count()) === 0 before deleting.
  • Reset modified local storage with resetLocalStorage(page, ref) from ../utils/reset-local-storage.js.

Debugging & CI Cold Start vs Local Dev

CI starts from a blank database (fresh containers, extensions like pg_cron disabled by default), whereas pnpm dev:studio-local may hold leftover tables or enabled extensions from previous runs.

  1. Reproduce CI failures with a true cold-start run: playwright.config.ts sets reuseExistingServer: true, so stop any Studio server already listening on port 8082 first (and keep IS_PLATFORM=false and CI unset) before running cd e2e/studio && pnpm run e2e features/<file>.spec.ts so Playwright runs e2e:setup:selfhosted and resets the DB — or run pnpm e2e:setup:cli from the repo root to reset the stack explicitly. Warning: both invoke supabase stop --all --no-backup, which wipes data from all local Supabase projects on the machine, not only the E2E stack.
  2. Inspect e2e/studio/test-results/ error context, traces (pnpm exec playwright show-trace <trace.zip>), or HTML reports (pnpm exec playwright show-report). To inspect live UI and locators interactively, start pnpm dev:studio-local and use Playwright MCP tools (bearing in mind local dev holds warm DB state unlike CI).
  3. Watch for the 3 classic cold-start bugs: missing extension setup, parallel tests mutating shared DB state (add mode: 'serial'), or locators assuming pre-existing seed data.

supabase की और Skills

ask-the-docs
supabase
प्रलेखित आर्किटेक्चर, बिल्ड पाइपलाइन और समीक्षा-पैटर्न नोट्स का उपयोग करके Supabase docs ऐप (apps/docs) के बारे में प्रश्नों के उत्तर दें, और फीचर-डिज़ाइन लागू करें…
clickhouse-logs-queries
supabase
Write, review, and migrate Supabase logs queries against the ClickHouse-backed `logs` table (the `logs.all.otel` analytics endpoint). Use this whenever a task…
copywriting
supabase
मोनोरिपो में कहीं भी UI कॉपी (बटन, लेबल, खाली स्थितियाँ, त्रुटि संदेश, टूलटिप्स, फ़ॉर्म टेक्स्ट) लिखें या उसकी समीक्षा करें। शिपिंग या समीक्षा से पहले इसे लोड करें…
dev-toolbar-review
supabase
उन PRs की समीक्षा करते समय उपयोग करें जो packages/dev-tools/, packages/common/posthog-client.ts को छूते हैं,
docs-content
supabase
apps/docs में कहीं भी Supabase सामग्री लिखें, संपादित करें, व्यवस्थित करें और समीक्षा करें — गाइड, व्याख्याकार, ट्यूटोरियल, समस्या निवारण प्रविष्टियाँ, संदर्भ दस्तावेज़, और…
e2e-studio-tests
supabase
स्टूडियो ऐप में e2e परीक्षण चलाएँ। जब e2e परीक्षण चलाने, स्टूडियो परीक्षण चलाने, प्लेराइट परीक्षण चलाने, या फीचर का परीक्षण करने के लिए कहा जाए तो इसका उपयोग करें।
pm-the-docs
supabase
Docs-PM "Write the docs" लेखन प्रक्रिया के लिए निर्णय समर्थन — Frame और Shape चरणों के दौरान दर्शकों, चरण और क्रॉस-कटिंग दायरे के निर्णय लेता है,…
react-hook-form
supabase
React Hook Form का सही उपयोग monorepo में कहीं भी — डेटा फ्लो, सब्सक्रिप्शन, रीसेट, डर्टी स्टेट, नंबर इनपुट, और कंट्रोल्ड इनपुट नियम। इसे लोड करें…