-
-
Notifications
You must be signed in to change notification settings - Fork 426
Expand file tree
/
Copy pathmeasure-element.spec.ts
More file actions
42 lines (32 loc) · 1.63 KB
/
measure-element.spec.ts
File metadata and controls
42 lines (32 loc) · 1.63 KB
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
import { expect, test } from './fixtures'
test('positions items correctly after expand → collapse → delete → expand', async ({
page,
}) => {
await page.goto('/measure-element/')
// All 3 items visible at ~36px each
await expect(page.locator('[data-testid="item-a"]')).toBeVisible()
await expect(page.locator('[data-testid="item-b"]')).toBeVisible()
await expect(page.locator('[data-testid="item-c"]')).toBeVisible()
// Step 1: Expand A → should grow to ~160px
await page.click('[data-testid="expand-item-a"]')
await expect(page.locator('[data-testid="content-item-a"]')).toBeVisible()
// Step 2: Collapse A → back to ~36px
await page.click('[data-testid="expand-item-a"]')
await expect(page.locator('[data-testid="content-item-a"]')).not.toBeVisible()
// Step 3: Delete A
await page.click('[data-testid="delete-item-a"]')
await expect(page.locator('[data-testid="item-a"]')).not.toBeVisible()
// Step 4: Expand B → should grow to ~160px
await page.click('[data-testid="expand-item-b"]')
await expect(page.locator('[data-testid="content-item-b"]')).toBeVisible()
// Wait for ResizeObserver to measure the expanded B
await page.waitForTimeout(200)
// C should be positioned after the expanded B, not overlapping it
const bBox = await page.locator('[data-testid="item-b"]').boundingBox()
const cBox = await page.locator('[data-testid="item-c"]').boundingBox()
expect(bBox).not.toBeNull()
expect(cBox).not.toBeNull()
// C's top should be at or after B's bottom (with no overlap)
const bBottom = bBox!.y + bBox!.height
expect(cBox!.y).toBeGreaterThanOrEqual(bBottom - 1) // 1px tolerance
})