Files
supabase/e2e/studio/utils/test.ts
Gildas Garcia ac59de1f9e chore: e2e tests reliability (#46496)
## I have read the
[CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md)
file.

YES/NO

## What kind of change does this PR introduce?

Bug fix, feature, docs update, ...

## What is the current behavior?

Please link any relevant issues here.

## What is the new behavior?

Feel free to include screenshots if it includes visual changes.

## Additional context

Add any other context or screenshots.


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

* **Accessibility**
* Improved screen-reader label for table row action menus so table
controls are clearer for assistive‑technology users.

* **Tests**
* Enhanced end-to-end test reliability: tightened selectors, added
dialog/toast visibility and API-wait synchronization, scoped lookup
fixes, removed redundant cleanup helper, and updated test setup to mark
a terms-of-service dismissal to reduce flakiness.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-06-01 10:18:07 +02:00

61 lines
1.5 KiB
TypeScript

import path from 'path'
import { test as base } from '@playwright/test'
import dotenv from 'dotenv'
import { env } from '../env.config.js'
dotenv.config({
path: path.resolve(import.meta.dirname, '../.env.local'),
override: true,
})
export interface TestOptions {
env: string
ref: string
apiUrl: string
}
export const test = base.extend<TestOptions>({
env: env.STUDIO_URL,
ref: env.PROJECT_REF ?? 'default',
apiUrl: env.API_URL,
page: async ({ page }, use) => {
const ref = env.PROJECT_REF ?? 'default'
await page.addInitScript((ref) => {
localStorage.setItem(
`table-editor-queue-operations-banner-dismissed-${ref}`,
JSON.stringify(true)
)
localStorage.setItem(`terms-of-service-update-2026-06-06`, JSON.stringify(true))
}, ref)
await use(page)
},
})
/**
* A function that returns a disposable object. Calling it with using keyword ensures that the cleanup function
* will be called whether the test succeeded or not.
*
* @example
* await using _ = await withSetupCleanup(
* () => createTableWithRLS('pw_table', 'pw_column'),
* async () => {
* await dropTable('pw_table')
* }
* )
* @param setup The setup function (create tables, etc.)
* @param cleanup The cleanup function (remove tables, etc.)
* @returns A disposable object
*/
export const withSetupCleanup = async (
setup: () => Promise<void>,
cleanup: () => Promise<void>
) => {
await setup()
return {
async [Symbol.asyncDispose]() {
await cleanup()
},
}
}