Files
supabase/e2e/studio/utils/clipboard.ts
Gildas Garcia b168ec364a Chore improve e2e tests (#43987)
## Problem

Some tests rely on hard coded timeouts. That makes them
- brittle if the timeout is not long enough
- take longer than necessary if the timeout is too long

## Solution

- Rely on playwright `expect` retries when possible
- Rely on UI updates when possible
2026-03-20 16:45:49 +01:00

22 lines
505 B
TypeScript

import { expect, type Page } from '@playwright/test'
export const expectClipboardValue = ({
page,
value,
exact = false,
timeout = 2000,
}: {
page: Page
value: string
exact?: boolean
timeout?: number
}) =>
expect(async () => {
await using handle = await page.evaluateHandle(() => navigator.clipboard.readText())
if (exact) {
expect(await handle.jsonValue()).toEqual(value)
} else {
expect(await handle.jsonValue()).toContain(value)
}
}).toPass({ timeout })