mirror of
https://github.com/supabase/supabase.git
synced 2026-10-05 09:25:06 +03:00
## 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>
2.2 KiB
2.2 KiB
applyTo
| applyTo |
|---|
| e2e/studio/**,apps/studio/** |
Studio E2E Test Review Rules
All comments are advisory.
Selector Priority (best to worst)
-
getByRolewith accessible name — most robust, tests accessibilitypage.getByRole('button', { name: 'Save' }) -
getByTestId— stable, explicit test hookspage.getByTestId('table-editor-side-panel') -
getByTextwith exact match — good for unique textpage.getByText('Data API Access', { exact: true }) -
locatorwith CSS — use sparingly, more fragilepage.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: trueon 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-labelto 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