Skip to content
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

Fix flaky specs #153

Merged
merged 1 commit into from
Feb 7, 2023
Merged
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
3 changes: 1 addition & 2 deletions apps/web/tests/examples/forms/edit-values.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,12 @@ test('With JS enabled', async ({ example }) => {
await expect(options.first()).toHaveText('From A Friend')
await expect(options.last()).toHaveText('Google')

await expect(await page.isChecked('input[type=checkbox]:visible')).toBeFalsy()
expect(await page.isChecked('input[type=checkbox]:visible')).toBeFalsy()

await expect(button).toBeEnabled()

// Submit form
button.click()
await expect(button).toBeDisabled()

await example.expectData({
firstName: 'Mary',
Expand Down
14 changes: 7 additions & 7 deletions apps/web/tests/examples/forms/radio-buttons.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ test('With JS enabled', async ({ example }) => {

testWithoutJS('With JS disabled', async ({ example }) => {
const { button, page } = example
const role = example.field('role')

await page.goto(route)

Expand All @@ -59,15 +58,16 @@ testWithoutJS('With JS disabled', async ({ example }) => {
await button.click()

// Show field errors and focus on the first field
await expect(
example.page.locator(`[data-headlessui-state="open"] #errors-for-role:visible`),
).toHaveText("Invalid enum value. Expected 'Designer' | 'Dev', received ''")

await example.expectErrorMessage(
'role',
"Invalid enum value. Expected 'Designer' | 'Dev', received ''",
)
const designerRadio = example.page.locator('[data-headlessui-state="open"] [name="role"][value="Designer"]:visible')

await expect(role.input.first()).toBeFocused()
await example.page.waitForLoadState('networkidle')
await expect(designerRadio).toBeFocused()

await role.input.first().click()
await designerRadio.click()

// Submit form
await button.click()
Expand Down