Skip to content

Commit

Permalink
Merge pull request #153 from seasonedcc/fix-flaky-specs
Browse files Browse the repository at this point in the history
Fix flaky specs
  • Loading branch information
diogob authored Feb 7, 2023
2 parents 07e2468 + cdb04e4 commit 6909dba
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
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

0 comments on commit 6909dba

Please sign in to comment.