Skip to content

chore(devdeps): update dependency eslint-plugin-testing-library to v7.5.3 #5268

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@
"esbuild-plugin-browserslist": "1.0.1",
"eslint": "9.29.0",
"eslint-plugin-oxlint": "0.18.1",
"eslint-plugin-testing-library": "7.4.0",
"eslint-plugin-testing-library": "7.5.3",
"expect": "29.7.0",
"file-loader": "6.2.0",
"globals": "16.2.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ describe('CheckboxField', () => {
expect(asFragment()).toMatchSnapshot()
})

test('should trigger events correctly', () => {
test('should trigger events correctly', async () => {
const onFocus = vi.fn(() => {})
const onChange = vi.fn(() => {})
const onBlur = vi.fn(() => {})
Expand All @@ -71,7 +71,7 @@ describe('CheckboxField', () => {
const input = screen.getByRole('checkbox', { hidden: true })
act(() => input.focus())
expect(onFocus).toBeCalledTimes(1)
act(() => input.click())
await userEvent.click(input)
expect(onChange).toBeCalledTimes(1)
act(() => input.blur())
expect(onBlur).toBeCalledTimes(1)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { act, screen } from '@testing-library/react'
import { screen } from '@testing-library/react'
import { userEvent } from '@testing-library/user-event'
import { renderWithForm } from '@utils/test'
import { describe, expect, test, vi } from 'vitest'
import { CheckboxGroupField } from '..'

describe('CheckboxField', () => {
test('should render correctly checked', () => {
test('should render correctly checked', async () => {
const { asFragment } = renderWithForm(
<CheckboxGroupField onChange={() => {}} name="Checkbox" legend="Label">
<CheckboxGroupField.Checkbox name="value-1" value="value-1">
Expand All @@ -26,14 +27,14 @@ describe('CheckboxField', () => {
hidden: true,
},
)
act(() => secondInput.click())
await userEvent.click(secondInput)

expect(firstInput).not.toBeChecked()
expect(secondInput).toBeChecked()
expect(asFragment()).toMatchSnapshot()
})

test('should trigger events correctly with required prop', () => {
test('should trigger events correctly with required prop', async () => {
const onChange = vi.fn(() => {})

const { asFragment } = renderWithForm(
Expand All @@ -57,11 +58,11 @@ describe('CheckboxField', () => {
},
)
const input = screen.getAllByRole('checkbox', { hidden: true })[0]
act(() => input.click())
await userEvent.click(input)
expect(onChange).toBeCalledTimes(1)
expect(input).toBeChecked()

act(() => input.click())
await userEvent.click(input)
expect(onChange).toBeCalledTimes(2)
expect(input).not.toBeChecked()

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { act, screen } from '@testing-library/react'
import { screen } from '@testing-library/react'
import { userEvent } from '@testing-library/user-event'
import { renderWithForm } from '@utils/test'
import { describe, expect, it } from 'vitest'
import { KeyValueField } from '..'

describe('KeyValueField', () => {
it('should render with default props', () => {
it('should render with default props', async () => {
const { asFragment } = renderWithForm(
<KeyValueField
name="test"
Expand All @@ -23,14 +24,10 @@ describe('KeyValueField', () => {
/>,
)
const addButton = screen.getByTestId('add-button')
act(() => {
addButton.click()
})
await userEvent.click(addButton)

const removeButton = screen.getByTestId('remove-button-0')
act(() => {
removeButton.click()
})
await userEvent.click(removeButton)
expect(asFragment()).toMatchSnapshot()
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ describe('NumberInputField', () => {
expect(asFragment()).toMatchSnapshot()
})

test('should trigger events correctly', () => {
test('should trigger events correctly', async () => {
const onFocus = vi.fn(() => {})
const onChange = vi.fn(() => {})
const onBlur = vi.fn(() => {})
Expand All @@ -57,9 +57,7 @@ describe('NumberInputField', () => {
input.focus()
})
expect(onFocus).toBeCalledTimes(1)
act(() => {
input.click()
})
await userEvent.click(input)
expect(onChange).toBeCalledTimes(0)
act(() => {
input.blur()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { act, screen } from '@testing-library/react'
import { userEvent } from '@testing-library/user-event'
import { renderWithForm } from '@utils/test'
import { describe, expect, test, vi } from 'vitest'
import { RadioField } from '..'
Expand Down Expand Up @@ -42,7 +43,7 @@ describe('RadioField', () => {
expect(asFragment()).toMatchSnapshot()
})

test('should trigger events correctly', () => {
test('should trigger events correctly', async () => {
const onFocus = vi.fn(() => {})
const onChange = vi.fn(() => {})
const onBlur = vi.fn(() => {})
Expand All @@ -60,7 +61,7 @@ describe('RadioField', () => {
const input = screen.getByRole('radio', { hidden: true })
act(() => input.focus())
expect(onFocus).toBeCalledTimes(1)
act(() => input.click())
await userEvent.click(input)
expect(onChange).toBeCalledTimes(1)
act(() => input.blur())
expect(onBlur).toBeCalledTimes(1)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { act, screen } from '@testing-library/react'
import { screen } from '@testing-library/react'
import { userEvent } from '@testing-library/user-event'
import { renderWithForm } from '@utils/test'
import { describe, expect, test, vi } from 'vitest'
import { RadioGroupField } from '..'

describe('RadioField', () => {
test('should render correctly checked', () => {
test('should render correctly checked', async () => {
const { asFragment } = renderWithForm(
<RadioGroupField
value="value-1"
Expand All @@ -19,15 +20,15 @@ describe('RadioField', () => {
const [firstInput, secondInput] = screen.getAllByRole('radio', {
hidden: true,
})
act(() => secondInput.click())
await userEvent.click(secondInput)

expect(firstInput).not.toBeChecked()
expect(secondInput).toBeChecked()

expect(asFragment()).toMatchSnapshot()
})

test('should trigger events correctly', () => {
test('should trigger events correctly', async () => {
const onChange = vi.fn(() => {})

const { asFragment } = renderWithForm(
Expand All @@ -42,7 +43,7 @@ describe('RadioField', () => {
</RadioGroupField>,
)
const input = screen.getAllByRole('radio', { hidden: true })[0]
act(() => input.click())
await userEvent.click(input)
expect(onChange).toBeCalledTimes(1)
expect(asFragment()).toMatchSnapshot()
})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { act, fireEvent, screen } from '@testing-library/react'
import { userEvent } from '@testing-library/user-event'
import { renderWithForm } from '@utils/test'
import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest'
import { SelectInputField } from '..'
Expand Down Expand Up @@ -50,7 +51,7 @@ describe('SelectInputField', () => {
expect(asFragment()).toMatchSnapshot()
})

test('should display right value on grouped options', () => {
test('should display right value on grouped options', async () => {
const selectedOption = { label: 'Group Label', value: 'Group Value' }
const options = [
{
Expand All @@ -73,7 +74,7 @@ describe('SelectInputField', () => {
// eslint-disable-next-line testing-library/no-node-access
).firstChild as HTMLElement

act(() => option.click())
await userEvent.click(option)

// react-select works with a hidden input to handle value.
// eslint-disable-next-line testing-library/no-node-access, testing-library/no-container
Expand All @@ -86,7 +87,7 @@ describe('SelectInputField', () => {
expect(asFragment()).toMatchSnapshot()
})

test('should trigger events', () => {
test('should trigger events', async () => {
const onChange = vi.fn()

const { asFragment } = renderWithForm(
Expand All @@ -105,7 +106,7 @@ describe('SelectInputField', () => {
// eslint-disable-next-line testing-library/no-node-access
screen.getByTestId('option-test-value').firstChild as HTMLElement

act(() => option.click())
await userEvent.click(option)
expect(onChange).toBeCalledTimes(1)
act(() => select.blur())
expect(asFragment()).toMatchSnapshot()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ describe('SelectInputField', () => {
<SelectInputFieldV2 name="test" options={planets} searchable={false} />,
)
const select = screen.getByTestId('select-input-test')
act(() => select.click())
await userEvent.click(select)
fireEvent.keyDown(select, { key: 'ArrowDown', keyCode: 40 })
const mercury = screen.getByTestId(`option-stack-mercury`)

act(() => mercury.click())
act(() => select.click())
await userEvent.click(mercury)
await userEvent.click(select)
await waitFor(() => {
expect(screen.getByTestId(`option-stack-mercury`)).toBeVisible()
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ describe('SelectableCardField', () => {
expect(asFragment()).toMatchSnapshot()
})

test('should trigger events correctly', () => {
test('should trigger events correctly', async () => {
const onFocus = vi.fn(() => {})
const onChange = vi.fn(() => {})
const onBlur = vi.fn(() => {})
Expand All @@ -57,7 +57,7 @@ describe('SelectableCardField', () => {
const input = screen.getByRole('radio', { hidden: true })
act(() => input.focus())
expect(onFocus).toBeCalledTimes(1)
act(() => input.click())
await userEvent.click(input)
expect(onChange).toBeCalledTimes(1)
act(() => input.blur())
expect(onBlur).toBeCalledTimes(1)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { act, screen } from '@testing-library/react'
import { screen } from '@testing-library/react'
import { userEvent } from '@testing-library/user-event'
import { renderWithForm } from '@utils/test'
import { describe, expect, test, vi } from 'vitest'
import { SelectableCardGroupField } from '../..'
Expand Down Expand Up @@ -61,7 +62,7 @@ describe('SelectableCardField', () => {
expect(asFragment()).toMatchSnapshot()
})

test('should trigger events correctly', () => {
test('should trigger events correctly', async () => {
const onChange = vi.fn(() => {})

const { asFragment } = renderWithForm(
Expand All @@ -77,9 +78,9 @@ describe('SelectableCardField', () => {
</SelectableCardGroupField>,
)
const input = screen.getByLabelText('Radio 1')
act(() => input.click())
await userEvent.click(input)
expect(onChange).toBeCalledTimes(1)
act(() => input.click())
await userEvent.click(input)
expect(onChange).toBeCalledTimes(2)
expect(asFragment()).toMatchSnapshot()
})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { act, fireEvent, screen, waitFor } from '@testing-library/react'
import { userEvent } from '@testing-library/user-event'
import { renderWithForm } from '@utils/test'
import { describe, expect, test, vi } from 'vitest'
import { TimeField } from '..'
Expand All @@ -21,7 +22,7 @@ describe('TimeField', () => {
expect(asFragment()).toMatchSnapshot()
})

test('should trigger events', () => {
test('should trigger events', async () => {
const onChange = vi.fn()

const { asFragment } = renderWithForm(
Expand All @@ -40,7 +41,7 @@ describe('TimeField', () => {
const option =
// eslint-disable-next-line testing-library/no-node-access
screen.getByTestId('option-test-01:00').firstChild as HTMLElement
act(() => option.click())
await userEvent.click(option)
expect(onChange).toBeCalledTimes(1)
act(() => select.blur())
expect(asFragment()).toMatchSnapshot()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { act, screen } from '@testing-library/react'
import { screen } from '@testing-library/react'
import { userEvent } from '@testing-library/user-event'
import { renderWithForm } from '@utils/test'
import { describe, expect, test, vi } from 'vitest'
import { ToggleGroupField } from '..'

describe('GroupField', () => {
test('should render correctly checked', () => {
test('should render correctly checked', async () => {
const { asFragment } = renderWithForm(
<ToggleGroupField onChange={() => {}} name="Group" legend="Label">
<ToggleGroupField.Toggle
Expand All @@ -27,14 +28,14 @@ describe('GroupField', () => {
const [firstInput, secondInput] = screen.getAllByRole('checkbox', {
hidden: true,
})
act(() => secondInput.click())
await userEvent.click(secondInput)

expect(firstInput).not.toBeChecked()
expect(secondInput).toBeChecked()
expect(asFragment()).toMatchSnapshot()
})

test('should trigger events correctly with required prop', () => {
test('should trigger events correctly with required prop', async () => {
const onChange = vi.fn(() => {})

const { asFragment } = renderWithForm(
Expand Down Expand Up @@ -62,11 +63,11 @@ describe('GroupField', () => {
},
)
const input = screen.getAllByRole('checkbox', { hidden: true })[0]
act(() => input.click())
await userEvent.click(input)
expect(onChange).toBeCalledTimes(1)
expect(input).toBeChecked()

act(() => input.click())
await userEvent.click(input)
expect(onChange).toBeCalledTimes(2)
expect(input).not.toBeChecked()
expect(asFragment()).toMatchSnapshot()
Expand Down
Loading
Loading