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

Delegate Turbo.session properties to Turbo.config #1306

Merged

Conversation

seanpdoyle
Copy link
Contributor

Follow-up to comment on 238ec2688b2f4907e05ad1eaeb011e93bae75995

hotwired/turbo#1216 unintentionally removed support for the Turbo.session.drive boolean property and the Turbo.session.formMode string property.

This commit re-introduces that support by delegating reads and writes to those properties to their corresponding Turbo.config versions.

Follow-up to comment on [238ec26][]

[hotwired#1216][] unintentionally removed support for
the `Turbo.session.drive` boolean property and the
`Turbo.session.formMode` string property.

This commit re-introduces that support by delegating reads and writes to
those properties to their corresponding `Turbo.config` versions.

[hotwired#1216]: hotwired#1216
[238ec26]: hotwired@238ec26#commitcomment-145954235
seanpdoyle referenced this pull request Aug 28, 2024
The initial implementation aims to replace the ad hoc configurations
spread across `window.Turbo` and `Turbo.session`. Those objects
shouldn't be considered part of the public interface, especially for
extension.

This commit exports a single object from `src/core/config` to serve as a
centralized, user-facing repository for configuration values.

The main `src/core/config` object is composed of two constituent parts:

* `src/core/config/drive`
* `src/core/config/forms`

In the future, the directory structure can be expanded upon to suit the
needs of the project.

Any user-facing configuration outside of `Turbo.config` is deprecated.
@seanpdoyle
Copy link
Contributor Author

@jorgemanrubia and @brunoprietog, could one of you review this change? @botandrose caught it and reported it on the original commit.

Browser tests periodically fail due to a timing issue:

```
1) [firefox] › functional/frame_tests.js:190:5 › failing to follow a link to a page without a matching frame shows an error and throws an exception

    AssertionError: expected 'Missing frame Missing page Unvisitabl…' to match /Content missing/

      196 |   await page.click("#missing-page-link")
      197 |
    > 198 |   assert.match(await page.innerText("#missing"), /Content missing/)
          |          ^
      199 |
      200 |   assert.exists(error)
      201 |   assert.include(error.message, `The response (404) did not contain the expected <turbo-frame id="missing">`)
```

This commit replaces the `assert`-based assertion with an `expect`-based
Playwright assertion that will utilize retries and timing
synchronization.

[CI failure]: https://github.com/hotwired/turbo/actions/runs/10603228414/job/29387060926?pr=1306#step:11:18
@brunoprietog
Copy link
Collaborator

Right! Could you add deprecation warnings please?

@seanpdoyle
Copy link
Contributor Author

@brunoprietog I'm happy to do that.

It's worth mentioning that the original PR only deprecated the methods like setProgressBarDelay but did not deprecate the new properties like Turbo.session. progressBarDelay.

I think deprecating the Turbo.session properties in favor of Turbo.config properties makes sense, but could that be done separately and across all properties?

@brunoprietog
Copy link
Collaborator

Ah, yes, makes sense. Thanks @seanpdoyle!

@brunoprietog brunoprietog merged commit 7ae9546 into hotwired:main Aug 30, 2024
1 check passed
@seanpdoyle seanpdoyle deleted the turbo-session-config-properties branch August 30, 2024 17:58
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.

2 participants