diff --git a/packages/ui-checkbox/src/Checkbox/__tests__/Checkbox.test.tsx b/packages/ui-checkbox/src/Checkbox/__tests__/Checkbox.test.tsx index c9a21919c8..e3c3fd7e33 100644 --- a/packages/ui-checkbox/src/Checkbox/__tests__/Checkbox.test.tsx +++ b/packages/ui-checkbox/src/Checkbox/__tests__/Checkbox.test.tsx @@ -279,30 +279,28 @@ describe('', () => { }) describe('`toggle` variant', () => { - it('should expose a button role and pressed state', () => { - renderCheckbox({ variant: 'toggle', defaultChecked: true }) - const toggle = screen.getByRole('button') + it('should expose a button role and pressed state', async () => { + await renderCheckbox({ variant: 'toggle', defaultChecked: true }) + const toggle = page.getByRole('button').element() expect(toggle).toHaveAttribute('aria-pressed', 'true') - expect(screen.queryByRole('checkbox')).not.toBeInTheDocument() + expect(page.getByRole('checkbox').query()).not.toBeInTheDocument() }) it('should update the pressed state when toggled', async () => { - renderCheckbox({ variant: 'toggle', defaultChecked: false }) - const toggle = screen.getByRole('button') + await renderCheckbox({ variant: 'toggle', defaultChecked: false }) + const toggle = page.getByRole('button') - expect(toggle).toHaveAttribute('aria-pressed', 'false') + await expect.element(toggle).toHaveAttribute('aria-pressed', 'false') - await userEvent.click(toggle) + await userEvent.click(toggle, { force: true }) - await waitFor(() => { - expect(toggle).toHaveAttribute('aria-pressed', 'true') - }) + await expect.element(toggle).toHaveAttribute('aria-pressed', 'true') }) - it('should leave the `simple` variant as a checkbox', () => { - renderCheckbox({ variant: 'simple' }) - const input = screen.getByRole('checkbox') + it('should leave the `simple` variant as a checkbox', async () => { + await renderCheckbox({ variant: 'simple' }) + const input = page.getByRole('checkbox').element() expect(input).not.toHaveAttribute('role') expect(input).not.toHaveAttribute('aria-pressed')