Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions packages/react/src/components/code-block-view.test.tsx
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -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(<ProseKitEditor initialMarkdown={CODE_BLOCK_MD} />)
await expect.element(copyButton).toBeInTheDocument()

Expand Down
12 changes: 10 additions & 2 deletions packages/vitest/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,15 @@ 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

return defineProject({
plugins: [playwrightCommands()],
oxc:
Expand All @@ -39,8 +48,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,
Expand Down
Loading