Skip to content
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
4 changes: 2 additions & 2 deletions services/frontend/tests/e2e/boards-swipe.motion.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ test.describe("dragging the board page", () => {
// The pass a finger plays measures the board it is dragging in, which is drawn open — the
// axis is claimed before it is mounted — so the figure it aims at is the finished layout.
await dragBand(page, band, {by: 260})
const swiped = await aimedAt(page, SWIPE)
const swiped = await aimedAt(page, SWIPE, from)
await expect(page).toHaveURL(/\?board=2$/)

// Aimed at a real difference rather than at the height it already stood at, which is what
Expand All @@ -198,7 +198,7 @@ test.describe("dragging the board page", () => {
// The pass the band plays for itself, a stop arriving without a gesture, aims at the same
// thing: it measures the arriving board a frame after it was built, and it was built open.
await page.getByTestId("board-node-5").click()
const hit = await aimedAt(page, SWIPE)
const hit = await aimedAt(page, SWIPE, swiped)
await expect(page.getByTestId("board-band-name")).toHaveText("Eeveelutions")

expect(Math.abs(hit - swiped)).toBeGreaterThan(HAIR)
Expand Down
14 changes: 10 additions & 4 deletions services/frontend/tests/e2e/sliceBand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,12 +138,18 @@ export function heldHeight(page: Page, swipe: string): Promise<number | null> {
* Both of the band's height animations set the resting height on the element before animating
* over it, so what is written there is the end of the pass stated at the start of it — which is
* the intention, where a height sampled mid-pass is only a frame of one.
*
* A pass that swaps the stop pins the height it is leaving first, a tick before it can measure
* the one it is arriving at, so the first inline height there is where the band was rather than
* where it is going. [stoodAt] is the height it is leaving, and tells the two apart.
*/
export async function aimedAt(page: Page, swipe: string): Promise<number> {
const handle = await page.waitForFunction((sel) => {
export async function aimedAt(page: Page, swipe: string, stoodAt: number): Promise<number> {
const handle = await page.waitForFunction(([sel, held]) => {
const aim = (document.querySelector(sel) as HTMLElement | null)?.style.height
return aim ? Math.round(parseFloat(aim)) : null
}, swipe)
if (!aim) return null
const px = Math.round(parseFloat(aim))
return px === held ? null : px
}, [swipe, stoodAt] as const)
return handle.jsonValue()
}

Expand Down
Loading