Skip to content

Commit 7bd49bd

Browse files
committed
Retry refute_has
1 parent adb6fa9 commit 7bd49bd

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [tbd]
9+
### Fixed
10+
- `refute_has/3` add retry, don't fail if element initially found
11+
812
## [0.7.0] 2025-06-16
913
### Added
1014
- Dialog handling

lib/phoenix_test/playwright.ex

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -608,9 +608,11 @@ defmodule PhoenixTest.Playwright do
608608

609609
@doc false
610610
def refute_has(conn, selector, opts) do
611-
if found?(conn, selector, opts) do
612-
flunk("Found element #{selector} #{inspect(opts)}")
613-
end
611+
retry(fn ->
612+
if found?(conn, selector, opts) do
613+
flunk("Found element #{selector} #{inspect(opts)}")
614+
end
615+
end)
614616

615617
conn
616618
end

test/phoenix_test/playwright_test.exs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -703,6 +703,13 @@ defmodule PhoenixTest.PlaywrightTest do
703703
|> refute_has(".multiple_links", count: 2)
704704
end
705705
end
706+
707+
test "retries if element initially visible", %{conn: conn} do
708+
conn
709+
|> visit("/live/index")
710+
|> click_button("Button with push navigation")
711+
|> refute_has("h1", text: "main page")
712+
end
706713
end
707714

708715
describe "refute_has/3" do

0 commit comments

Comments
 (0)