Skip to content

Commit aae6399

Browse files
committed
Updating tests
1 parent 0ef633e commit aae6399

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

tests/animate/animate.spec.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,13 @@ async function eachBox(
66
) {
77
const boxes = page.locator(".box")
88
const count = await boxes.count()
9-
expect(count).toBe(3)
9+
1010
await callback(boxes.nth(0), 0)
1111
await callback(boxes.nth(1), 1)
1212
await callback(boxes.nth(2), 2)
13+
if (count === 4) {
14+
await callback(boxes.nth(3), 3)
15+
}
1316
}
1417

1518
async function waitForAnimation(url: string, page: Page, customTimeout = 500) {

tests/scroll/scroll.spec.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,13 @@ test.describe("scroll()", () => {
7777
await page.goto("scroll/scroll-stagger.html")
7878
await page.reload()
7979

80+
// Record the initial bounding box x for each box
81+
const initialXs: number[] = []
82+
await eachStaggerBox(page, async (box) => {
83+
const boundingBox = await box.boundingBox()
84+
initialXs.push(boundingBox?.x ?? 0)
85+
})
86+
8087
// Get the total scroll height (400vh)
8188
const totalScrollHeight = await page.evaluate(() => {
8289
return document.documentElement.scrollHeight - window.innerHeight
@@ -90,10 +97,12 @@ test.describe("scroll()", () => {
9097
// Wait for animations to complete
9198
await page.waitForTimeout(100)
9299

93-
// At the bottom, all boxes should be at 100px translateX regardless of stagger
100+
// At the bottom, all boxes should be at 100px translateX from their initial position regardless of stagger
101+
let i = 0
94102
await eachStaggerBox(page, async (box) => {
95103
const boundingBox = await box.boundingBox()
96-
expect(boundingBox?.x).toBeCloseTo(100, 1)
104+
const initialX = initialXs[i++]
105+
expect(boundingBox?.x).toBeCloseTo(initialX + 100, 1)
97106
})
98107
})
99108
})

0 commit comments

Comments
 (0)