screen.get*ByRole breaking yarn test (#88)

This commit is contained in:
Pierre Jacquier
2023-04-11 05:31:38 -04:00
committed by GitHub
parent b026f51a4f
commit 0ebcbe118d
3 changed files with 7 additions and 3 deletions

View File

@ -8,7 +8,8 @@ it('renders settings popup with both save buttons', async () => {
await waitFor(() => screen.findByText(/github token/i))
// GitHub and KittyCAD buttons
const buttons = screen.getAllByRole('button')
// TODO: understand why screen.getByRole started to hang
const buttons = screen.getAllByText('Save')
expect(buttons[0]).toBeEnabled()
expect(buttons[1]).toBeEnabled()
})

View File

@ -9,10 +9,12 @@ it('renders a token form and checks its callback', () => {
render(<TokenForm service={service} onToken={callback} />)
expect(screen.getByText(`Enter a ${service} token`)).toBeInTheDocument()
const field = screen.getByRole('textbox')
// TODO: understand why screen.getByRole started to hang
const field = screen.getByAltText("Text input for token")
fireEvent.change(field, { target: { value: token } })
const button = screen.getByRole('button')
// TODO: understand why screen.getByRole started to hang
const button = screen.getByText('Save')
expect(button).toBeEnabled()
fireEvent.click(button)

View File

@ -14,6 +14,7 @@ export function TokenForm({ service, onToken }: TokenFormProps) {
<FormControl required>
<FormControl.Label>Enter a {service} token</FormControl.Label>
<TextInput
alt="Text input for token"
value={token}
onChange={e => setToken(e.target.value)}
/>