Files
supabase/.github/instructions/studio-e2e-tests.instructions.md
T
Ali WaseemandCopilot 3ece134d52 chore: updated copilot instructions (#44247)
## I have read the
[CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md)
file.

YES

## What kind of change does this PR introduce?

Improve code review guidelines for copilot

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-03-27 05:26:47 -06:00

2.2 KiB

applyTo
applyTo
e2e/studio/**,apps/studio/**

Studio E2E Test Review Rules

All comments are advisory.

Selector Priority (best to worst)

  1. getByRole with accessible name — most robust, tests accessibility

    page.getByRole('button', { name: 'Save' })
    
  2. getByTestId — stable, explicit test hooks

    page.getByTestId('table-editor-side-panel')
    
  3. getByText with exact match — good for unique text

    page.getByText('Data API Access', { exact: true })
    
  4. locator with CSS — use sparingly, more fragile

    page.locator('[data-state="open"]')
    

Patterns to Flag

  • XPath selectors — fragile to DOM changes

    // BAD
    locator('xpath=ancestor::div[contains(@class, "space-y")]')
    
  • Parent traversal with locator('..') — breaks when structure changes

    // BAD
    element.locator('..').getByRole('button')
    
  • waitForTimeout — never use; wait for something specific instead

    // BAD
    await page.waitForTimeout(1000)
    
    // GOOD — wait for UI element
    await expect(page.getByText('Success')).toBeVisible()
    
    // GOOD — wait for API response
    const apiPromise = waitForApiResponse(page, 'pg-meta', ref, 'query?key=table-create')
    await saveButton.click()
    await apiPromise
    
  • force: true on clicks — make elements visible first instead

    // BAD
    await menuButton.click({ force: true })
    
    // GOOD — hover to reveal, then click
    await tableRow.hover()
    await expect(menuButton).toBeVisible()
    await menuButton.click()
    
  • Broad filter({ hasText }) on generic elements — may match multiple elements; scope to specific containers instead

Good Practices to Encourage

  • Scope selectors to containers: page.getByTestId('side-panel').getByRole('switch')
  • Add aria-label to icon-only buttons in source code for better test selectors
  • Use test.describe.configure({ mode: 'serial' }) for tests sharing database state
  • Add messages to expects: await expect(locator, 'why').toBeVisible({ timeout: 30000 })

Canonical standard: .claude/skills/e2e-studio-tests/SKILL.md