Skip to content

Commit 7f126e0

Browse files
authored
feat (Frame): Accept all supported options to goto (#171)
The corresponding change to be able to use [#49 from playwright_ex](ftes/playwright_ex#49). The description from that PR: > This expands the list of selected options for `PlaywrightEx.Frame.goto/2` to match those of the JavaScript API ([docs](https://playwright.dev/docs/api/class-page#page-goto)). > > I found that in CI, I was often hitting 30 second timeouts waiting for the `load` event—even though in the trace, I could clearly see the page had (at least conceptually!) loaded. When switching to `waitUntil: 'commit'` (rather than the default `waitUntil: 'load'`), not only did the flakiness of that initial page load get fixed, but the tests also got _much_ faster: from an average of >5 seconds per test down to under 1.5 seconds/test. > > (The `Referer` stuff isn't strictly necessary for my own work, but I figured while I was in here, I might as well make `goto` accept everything the JavaScript version does.) It doesn't feel _great_ having the docs copied and pasted between the two projects, but it seemed cleaner than, say, exposing a function from PlaywrightEx that would provide the options at compile-time.
1 parent 03af45b commit 7f126e0

1 file changed

Lines changed: 19 additions & 1 deletion

File tree

lib/phoenix_test/playwright.ex

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,25 @@ defmodule PhoenixTest.Playwright do
155155
@doc false
156156
def visit(conn, path), do: visit(conn, path, [])
157157

158-
@visit_opts_schema [timeout: @timeout_opt]
158+
@visit_opts_schema [
159+
timeout: @timeout_opt,
160+
referer: [
161+
type: :string,
162+
doc:
163+
"Referer header value. If provided, takes preference over the referer header set via the `extra_http_headers` option to `PlaywrightEx.Browser.new_context/2`."
164+
],
165+
wait_until: [
166+
type: {:in, ["load", "domcontentloaded", "networkidle", "commit"]},
167+
default: "load",
168+
doc: """
169+
When to consider the operation succeeded. One of:
170+
- `"load"` (default) — fires when the `load` event is fired.
171+
- `"domcontentloaded"` — fires when the `DOMContentLoaded` event is fired.
172+
- `"networkidle"` — **discouraged** — fires when there are no network connections for at least 500 ms. Rely on web assertions instead for testing readiness.
173+
- `"commit"` — fires when the network response is received and the document has started loading.
174+
"""
175+
]
176+
]
159177

160178
@doc """
161179
Like `PhoenixTest.visit/2`, but with a custom `timeout`.

0 commit comments

Comments
 (0)