Skip to content

Commit 4c7519c

Browse files
committed
Add missing assertion tests
1 parent 9dc4609 commit 4c7519c

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

tests/async/test_assertions.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -552,6 +552,35 @@ async def test_assertions_locator_to_be_checked(page: Page, server: Server) -> N
552552
await expect(my_checkbox).to_be_checked()
553553

554554

555+
async def test_assertions_boolean_checked_with_intermediate_true(page: Page) -> None:
556+
await page.set_content("<input type=checkbox></input>")
557+
await page.locator("input").evaluate("e => e.indeterminate = true")
558+
await expect(page.locator("input")).to_be_checked(indeterminate=True)
559+
560+
561+
async def test_assertions_boolean_checked_with_intermediate_true_and_checked(
562+
page: Page,
563+
) -> None:
564+
await page.set_content("<input type=checkbox></input>")
565+
await page.locator("input").evaluate("e => e.indeterminate = true")
566+
with pytest.raises(
567+
Error, match="Can't assert indeterminate and checked at the same time"
568+
):
569+
await expect(page.locator("input")).to_be_checked(
570+
checked=False, indeterminate=True
571+
)
572+
573+
574+
async def test_assertions_boolean_fail_with_indeterminate_true(page: Page) -> None:
575+
await page.set_content("<input type=checkbox></input>")
576+
with pytest.raises(
577+
AssertionError, match='Expect "to_be_checked" with timeout 1000ms'
578+
):
579+
await expect(page.locator("input")).to_be_checked(
580+
indeterminate=True, timeout=1000
581+
)
582+
583+
555584
async def test_assertions_locator_to_be_disabled_enabled(
556585
page: Page, server: Server
557586
) -> None:

tests/sync/test_assertions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,7 @@ def test_assertions_boolean_checked_with_intermediate_true_and_checked(
548548
def test_assertions_boolean_fail_with_indeterminate_true(page: Page) -> None:
549549
page.set_content("<input type=checkbox></input>")
550550
with pytest.raises(
551-
AssertionError, match='Expect "to.be.checked" with timeout 1000ms'
551+
AssertionError, match='Expect "to_be_checked" with timeout 1000ms'
552552
):
553553
expect(page.locator("input")).to_be_checked(indeterminate=True, timeout=1000)
554554

0 commit comments

Comments
 (0)