From 78c32abd653359dfa77bc7324a05df28befb0839 Mon Sep 17 00:00:00 2001 From: ocavue Date: Sat, 20 Jun 2026 13:14:36 +1000 Subject: [PATCH 1/3] test: enable clipboard tests on Safari --- packages/react/src/components/code-block-view.test.tsx | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/packages/react/src/components/code-block-view.test.tsx b/packages/react/src/components/code-block-view.test.tsx index 4001ddc4..ea69ff71 100644 --- a/packages/react/src/components/code-block-view.test.tsx +++ b/packages/react/src/components/code-block-view.test.tsx @@ -1,6 +1,5 @@ import '../testing/index.ts' -import { isSafari } from '@meowdown/vitest/helpers' import { createRef } from 'react' import { describe, expect, it, vi } from 'vitest' import { render } from 'vitest-browser-react' @@ -70,10 +69,7 @@ describe('code block language selector', () => { }) }) - it.skipIf( - // Safari doesn't support `navigator.clipboard.readText()` - isSafari(), - )('copies the code block contents to the clipboard', async () => { + it('copies the code block contents to the clipboard', async () => { await render() await expect.element(copyButton).toBeInTheDocument() From cf520e439aa49ec52a1c06879d06594a738a0dae Mon Sep 17 00:00:00 2001 From: ocavue Date: Sat, 20 Jun 2026 13:45:50 +1000 Subject: [PATCH 2/3] wip: test clipboardPermissions --- packages/vitest/src/config.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/packages/vitest/src/config.ts b/packages/vitest/src/config.ts index f4a2c14d..fa03732d 100644 --- a/packages/vitest/src/config.ts +++ b/packages/vitest/src/config.ts @@ -16,6 +16,17 @@ export function defineSharedConfig() { return 'chromium' })() + // WebKit and Chromium reject navigator.clipboard.readText() unless 'clipboard-read' + // is granted. Chromium also needs 'clipboard-write'. Firefox reads without a grant. + const clipboardPermissions = + browserName === 'chromium' + ? ['clipboard-read', 'clipboard-write'] + : browserName === 'webkit' + ? ['clipboard-read'] + : undefined + + console.error('[meowdown][debug] clipboardPermissions', browserName, clipboardPermissions) + return defineProject({ plugins: [playwrightCommands()], oxc: @@ -39,8 +50,7 @@ export function defineSharedConfig() { reducedMotion: 'reduce', hasTouch: true, // A list of permissions to grant to all pages in this context. See https://playwright.dev/docs/api/class-browsercontext#browser-context-grant-permissions - permissions: - browserName === 'chromium' ? ['clipboard-read', 'clipboard-write'] : undefined, + permissions: clipboardPermissions, }, }), headless: true, From 20afd1852c16d92cd6abfc1c614bf9cab747ffa4 Mon Sep 17 00:00:00 2001 From: ocavue Date: Sat, 20 Jun 2026 14:13:30 +1000 Subject: [PATCH 3/3] fix --- packages/vitest/src/config.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/vitest/src/config.ts b/packages/vitest/src/config.ts index fa03732d..fed0b3da 100644 --- a/packages/vitest/src/config.ts +++ b/packages/vitest/src/config.ts @@ -25,8 +25,6 @@ export function defineSharedConfig() { ? ['clipboard-read'] : undefined - console.error('[meowdown][debug] clipboardPermissions', browserName, clipboardPermissions) - return defineProject({ plugins: [playwrightCommands()], oxc: