Return Promise<void> from FrameElement.reload#661
Merged
dhh merged 2 commits intohotwired:mainfrom Aug 1, 2022
Merged
Conversation
Following the pattern established by `Turbo.visit(...)` and
`Turbo.visit(..., { frame: "..." })`, return the `FrameElement.loaded`
promise from calls to `FrameElement.reload()`.
That way, callers can block on it:
```js
const frame = document.getElementById("my-frame")
await frame.reload()
// ...
```
3da1643 to
3da4ab2
Compare
Switch the tests from a time-based waiting mechanism (1200 milliseconds)
to an event-based waiting mechanism (waiting for `turbo:load`).
```
2) [firefox] › navigation_tests.ts:341:1 › test double-clicking on a link ========================
AssertionError: expected '/src/tests/fixtures/navigation.html' to equal '/__turbo/delayed_response'
344 |
345 | await nextBody(page, 1200)
> 346 | assert.equal(pathname(page.url()), "/__turbo/delayed_response")
| ^
347 | assert.equal(await visitAction(page), "advance")
348 | })
349 |
at /home/runner/work/turbo/turbo/src/tests/functional/navigation_tests.ts:346:10
1) [firefox] › navigation_tests.ts:131:1 › test following a same-origin POST form button[data-turbo-action=replace]
page.click: Target closed
=========================== logs ===========================
waiting for selector "#same-origin-replace-form-submitter-post button"
selector resolved to visible <button data-turbo-action="replace">Same-origin form[method="post"] button[data-turbo…</button>
attempting click action
waiting for element to be visible, enabled and stable
element is visible, enabled and stable
scrolling into view if needed
============================================================
130 |
131 | test("test following a same-origin POST form button[data-turbo-action=replace]", async ({ page }) => {
> 132 | page.click("#same-origin-replace-form-submitter-post button")
| ^
133 | await nextBody(page)
134 |
135 | assert.equal(pathname(page.url()), "/src/tests/fixtures/one.html")
at
/home/runner/work/turbo/turbo/src/tests/functional/navigation_tests.ts:132:8
```
3da4ab2 to
962d27c
Compare
dhh
added a commit
to seanpdoyle/turbo
that referenced
this pull request
Aug 3, 2022
* main: Add turbo:fetch-request-error event on frame and form network errors (hotwired#640) Return `Promise<void>` from `FrameElement.reload` (hotwired#661) Replace LinkInterceptor with LinkClickObserver (hotwired#412) Don't convert `data-turbo-stream` links to forms (hotwired#647)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Following the pattern established by
Turbo.visit(...)andTurbo.visit(..., { frame: "..." }), return theFrameElement.loadedpromise from calls to
FrameElement.reload().That way, callers can block on it: