-
Notifications
You must be signed in to change notification settings - Fork 412
/
frame_navigation_tests.ts
50 lines (36 loc) · 1.71 KB
/
frame_navigation_tests.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import { TurboDriveTestCase } from "../helpers/turbo_drive_test_case"
export class FrameNavigationTests extends TurboDriveTestCase {
async setup() {
await this.goToLocation("/src/tests/fixtures/frame_navigation.html")
}
async "test frame navigation with descendant link"() {
await this.clickSelector("#inside")
await this.nextEventOnTarget("frame", "turbo:frame-load")
}
async "test frame navigation with self link"() {
await this.clickSelector("#self")
await this.nextEventOnTarget("frame", "turbo:frame-load")
}
async "test frame navigation with exterior link"() {
await this.clickSelector("#outside")
await this.nextEventOnTarget("frame", "turbo:frame-load")
}
async "test promoted frame navigation updates the URL before rendering"() {
await this.goToLocation("/src/tests/fixtures/tabs.html")
this.remote.execute(() => {
document.addEventListener("turbo:before-frame-render", () => {
localStorage.setItem("beforeRenderUrl", window.location.pathname)
localStorage.setItem("beforeRenderContent", document.querySelector("#tab-content")?.textContent || "")
})
})
await this.clickSelector("#tab-2")
await this.nextEventNamed("turbo:before-frame-render")
this.assert.equal(await this.getFromLocalStorage("beforeRenderUrl"), "/src/tests/fixtures/tabs/two.html")
this.assert.equal(await this.getFromLocalStorage("beforeRenderContent"), "One")
await this.nextEventNamed("turbo:frame-render")
const content = await this.querySelector("#tab-content")
this.assert.equal(await this.pathname, "/src/tests/fixtures/tabs/two.html")
this.assert.equal(await content.getVisibleText(), "Two")
}
}
FrameNavigationTests.registerSuite()