Skip to content

Commit

Permalink
fix(test): fix breaking annotation popover test (#5838)
Browse files Browse the repository at this point in the history
Signed-off-by: Fred Carlsen <[email protected]>
  • Loading branch information
sjelfull authored Feb 26, 2024
1 parent 1c1c87c commit 042cd34
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,24 @@ test.describe('Portable Text Input', () => {
// Assertion: the annotation toolbar popover should not be visible
await expect(page.getByTestId('annotation-toolbar-popover')).not.toBeVisible()

const $linkEditPopover = page.getByTestId('popover-edit-dialog')
const $linkInput = $linkEditPopover.getByLabel('Link').first()

// Now we check if the edit popover shows automatically
await expect(page.getByLabel('Link').first()).toBeAttached({timeout: 10000})
await expect($linkInput).toBeAttached({timeout: 10000})

// Focus the URL input
await page.getByLabel('Link').first().focus()
await $linkInput.focus()

// Assertion: The URL input should be focused
await expect(page.getByLabel('Link').first()).toBeFocused()
await expect($linkInput).toBeFocused()

// Type in the URL
await page.keyboard.type('https://www.sanity.io')

// Assetion: The URL input should have the correct value
await expect($linkInput).toHaveValue('https://www.sanity.io')

// Close the popover
await page.keyboard.press('Escape')

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export function PopoverEditDialog(props: PopoverEditDialogProps) {
<RootPopover
content={<Content {...props} />}
constrainSize
data-testid="popover-edit-dialog"
data-ui="PopoverEditDialog"
fallbackPlacements={POPOVER_FALLBACK_PLACEMENTS}
floatingBoundary={floatingBoundary}
Expand Down

0 comments on commit 042cd34

Please sign in to comment.