Skip to content
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

Return Promise<void> from FrameElement.reload #661

Merged
merged 2 commits into from Aug 1, 2022

Conversation

seanpdoyle
Copy link
Contributor

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:

const frame = document.getElementById("my-frame")
await frame.reload()
// ...

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()
// ...
```
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
```
@dhh dhh merged commit 60c6463 into hotwired:main Aug 1, 2022
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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants