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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/core/session.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,22 @@ export class Session {
return config.drive.progressBarDelay
}

set drive(value) {
config.drive.enabled = value
}

get drive() {
return config.drive.enabled
}

set formMode(value) {
config.forms.mode = value
}

get formMode() {
return config.forms.mode
}

get location() {
return this.history.location
}
Expand Down
2 changes: 1 addition & 1 deletion src/tests/fixtures/drive_disabled.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
})
</script>
<script>
Turbo.config.drive = false
Turbo.config.drive.enabled = false
</script>
</head>
<body>
Expand Down
4 changes: 2 additions & 2 deletions src/tests/functional/frame_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ test("successfully following a link to a page without a matching frame shows an

await page.click("#missing-frame-link")

assert.match(await page.innerText("#missing"), /Content missing/)
await expect(page.locator("#missing")).toHaveText("Content missing")

assert.exists(error)
assert.include(error.message, `The response (200) did not contain the expected <turbo-frame id="missing">`)
Expand Down Expand Up @@ -195,7 +195,7 @@ test("failing to follow a link to a page without a matching frame shows an error

await page.click("#missing-page-link")

assert.match(await page.innerText("#missing"), /Content missing/)
await expect(page.locator("#missing")).toHaveText("Content missing")

assert.exists(error)
assert.include(error.message, `The response (404) did not contain the expected <turbo-frame id="missing">`)
Expand Down
19 changes: 19 additions & 0 deletions src/tests/unit/export_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,28 @@ test("Turbo interface", () => {
assert.equal(typeof Turbo.cache.clear, "function")
assert.equal(typeof Turbo.navigator, "object")
assert.equal(typeof Turbo.session, "object")
assert.equal(typeof Turbo.session.drive, "boolean")
assert.equal(typeof Turbo.session.formMode, "string")
assert.equal(typeof Turbo.fetch, "function")
})

test("Session interface", () => {
const { session, config } = Turbo

assert.equal(true, session.drive)
assert.equal(true, config.drive.enabled)
assert.equal("on", session.formMode)
assert.equal("on", config.forms.mode)

session.drive = false
session.formMode = "off"

assert.equal(false, session.drive)
assert.equal(false, config.drive.enabled)
assert.equal("off", session.formMode)
assert.equal("off", config.forms.mode)
})

test("StreamActions interface", () => {
assert.equal(typeof StreamActions, "object")
})
Loading