-
Notifications
You must be signed in to change notification settings - Fork 439
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
Dispatch turbo:fetch-request-error on eager/lazy-loaded frame #768
Comments
@nate-at-gusto thank you for opening this issue! I've tried to reproduce the behavior you're describing locally in the test suite, but I'm having trouble writing a failing test. So far, I've tried this: diff --git a/src/tests/fixtures/frames.html b/src/tests/fixtures/frames.html
index c308995..e7087c9 100644
--- a/src/tests/fixtures/frames.html
+++ b/src/tests/fixtures/frames.html
@@ -1,5 +1,5 @@
<!DOCTYPE html>
-<html id="html" data-skip-event-details="turbo:click turbo:before-render">
+<html id="html" data-skip-event-details="turbo:click turbo:before-render turbo:fetch-request-error">
<head>
<meta charset="utf-8">
<title>Frame</title>
@@ -119,6 +119,10 @@
<a id="frame-part" href="/src/tests/fixtures/frames/part.html">Load #part</a>
</turbo-frame>
+ <turbo-frame id="menu" src="/src/tests/fixtures/frames/preloading.html" disabled>
+ Disabled #menu
+ </turbo-frame>
+
<a id="outer-frame-link" href="/src/tests/fixtures/frames/frame.html" data-turbo-frame="frame">Outer frame link</a>
<form data-turbo-frame="frame" method="get" action="/src/tests/fixtures/frames/frame.html">
<input id="outer-frame-submit" type="submit" value="Outer form submit">
diff --git a/src/tests/functional/frame_tests.ts b/src/tests/functional/frame_tests.ts
index e281156..809eb76 100644
--- a/src/tests/functional/frame_tests.ts
+++ b/src/tests/functional/frame_tests.ts
@@ -387,6 +387,13 @@ test("test removing [disabled] attribute from eager-loaded frame navigates it",
await nextEventOnTarget(page, "frame", "turbo:before-fetch-request")
})
+test("test eager-loading a frame emits fetch-request-error event when offline", async ({ page }) => {
+ await page.context().setOffline(true)
+ await page.locator("turbo-frame#menu").evaluate((menu) => menu.removeAttribute("disabled"))
+
+ await nextEventOnTarget(page, "menu", "turbo:fetch-request-error")
+})
+
test("test evaluates frame script elements on each render", async ({ page }) => {
assert.equal(await frameScriptEvaluationCount(page), undefined) The test passes without any implementation changes. Are there any details that I've missed in the test harness or exercise? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
#685 seems to have added this event to most places, but I think one place it could fire but doesn't currently is on an eager or lazy-loaded frame. Frames with
src
attributes don't fire this event when their fetch request fails on initial page load.The text was updated successfully, but these errors were encountered: