Skip to content

Commit 117440d

Browse files
committed
Add a test for backward compatibility with legacy setting
1 parent fb4bc81 commit 117440d

File tree

3 files changed

+95
-0
lines changed

3 files changed

+95
-0
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<!DOCTYPE html>
2+
<html>
3+
4+
<head>
5+
<meta charset="utf-8" />
6+
<title>Left</title>
7+
<meta name="view-transition" content="same-origin" />
8+
<script src="/dist/turbo.es2017-umd.js" data-turbo-track="reload"></script>
9+
10+
<style>
11+
.square {
12+
display: block;
13+
width: 100px;
14+
height: 100px;
15+
border-radius: 6px;
16+
background-color: blue;
17+
view-transition-name: square;
18+
}
19+
20+
.square.right {
21+
margin-left: auto;
22+
}
23+
</style>
24+
</head>
25+
26+
<body style="background-color: orange">
27+
<h1>Left</h1>
28+
<p><a id="go-right" href="/src/tests/fixtures/transitions/right_legacy.html">go right</a></p>
29+
<div class="square"></div>
30+
<p><a id="go-other" href="/src/tests/fixtures/transitions/other.html">go other</a></p>
31+
</body>
32+
33+
</html>
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<!DOCTYPE html>
2+
<html>
3+
4+
<head>
5+
<meta charset="utf-8">
6+
<title>Right</title>
7+
<meta name="view-transition" content="same-origin" />
8+
<script src="/dist/turbo.es2017-umd.js" data-turbo-track="reload"></script>
9+
10+
<style>
11+
.square {
12+
display: block;
13+
width: 100px;
14+
height: 100px;
15+
border-radius: 6px;
16+
background-color: blue;
17+
view-transition-name: square;
18+
}
19+
20+
.square.right {
21+
margin-left: auto;
22+
}
23+
</style>
24+
</head>
25+
26+
<body style="background-color: red">
27+
<h1>Right</h1>
28+
<p><a id="go-left" href="/src/tests/fixtures/transitions/left_legacy.html">go left</a></p>
29+
<div class="square right"></div>
30+
</body>
31+
32+
</html>
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import { test } from "@playwright/test"
2+
import { assert } from "chai"
3+
import { nextBody } from "../helpers/page"
4+
5+
test.beforeEach(async ({ page }) => {
6+
await page.goto("/src/tests/fixtures/transitions/left_legacy.html")
7+
8+
await page.evaluate(`
9+
document.startViewTransition = (callback) => {
10+
window.startViewTransitionCalled = true
11+
callback()
12+
}
13+
`)
14+
})
15+
16+
test("navigating triggers the view transition", async ({ page }) => {
17+
await page.locator("#go-right").click()
18+
await nextBody(page)
19+
20+
const called = await page.evaluate(`window.startViewTransitionCalled`)
21+
assert.isTrue(called)
22+
})
23+
24+
test("navigating does not trigger a view transition when meta tag not present", async ({ page }) => {
25+
await page.locator("#go-other").click()
26+
await nextBody(page)
27+
28+
const called = await page.evaluate(`window.startViewTransitionCalled`)
29+
assert.isUndefined(called)
30+
})

0 commit comments

Comments
 (0)