Skip to content

Commit

Permalink
fix: update role to menuitem
Browse files Browse the repository at this point in the history
  • Loading branch information
d-rita committed Jun 19, 2024
1 parent 83b6578 commit 23baf75
Showing 1 changed file with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import { CustomDataProvider } from '@dhis2/app-runtime'
import { render, screen, waitFor } from '@testing-library/react'
import {
render,
screen,
waitFor,
waitForElementToBeRemoved,
} from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import '@testing-library/jest-dom'
import React, { useState } from 'react'
Expand Down Expand Up @@ -43,17 +48,18 @@ describe('SharingAutocomplete', () => {
userEvent.type(screen.getByRole('textbox'), searchString)
expect(screen.getByRole('textbox')).toHaveValue(searchString)

await waitFor(() => screen.getByRole('listitem'))
userEvent.click(screen.getByRole('listitem').querySelector('a'))
await waitForElementToBeRemoved(() => screen.getByRole('progressbar'))

userEvent.click(screen.getByRole('menuitem'))
expect(screen.getByRole('textbox')).toHaveValue(userDisplayName)

try {
await waitFor(() => screen.getByRole('listitem'), { timeout: 1 })
await waitFor(() => screen.getByRole('menuitem'), { timeout: 1 })
} catch (error) {
if (!error.message.startsWith('Unable to find role="listitem"')) {
if (!error.message.startsWith('Unable to find role="menuitem"')) {
throw error
}
}
expect(screen.queryByRole('listitem')).not.toBeInTheDocument()
expect(screen.queryByRole('menuitem')).not.toBeInTheDocument()
})
})

0 comments on commit 23baf75

Please sign in to comment.