fix: match Today paper concept
This commit is contained in:
@@ -20,6 +20,44 @@ async function assertInsideViewport(locator: Locator, page: Page) {
|
||||
expect(box!.y + box!.height).toBeLessThanOrEqual(viewport!.height + 1)
|
||||
}
|
||||
|
||||
test('Today paper composition has no overlap or horizontal overflow', async ({ page }) => {
|
||||
await page.goto('/')
|
||||
await expect(await bottomTab(page, '今天')).toHaveAttribute('aria-current', 'page')
|
||||
const board = page.locator('.today-board')
|
||||
const environment = page.locator('.today-environment')
|
||||
const tracks = board.locator('.today-track')
|
||||
await expect(board).toBeVisible()
|
||||
await expect(environment).toBeVisible()
|
||||
await expect(tracks).toHaveCount(2)
|
||||
|
||||
const geometry = await board.evaluate((node) => {
|
||||
const boardRect = node.getBoundingClientRect()
|
||||
const environmentRect = node.querySelector('.today-environment')!.getBoundingClientRect()
|
||||
const trackRects = [...node.querySelectorAll('.today-track')].map(item => item.getBoundingClientRect())
|
||||
return {
|
||||
boardRight: boardRect.right,
|
||||
boardBottom: boardRect.bottom,
|
||||
boardScrollWidth: node.scrollWidth,
|
||||
boardClientWidth: node.clientWidth,
|
||||
environmentBottom: environmentRect.bottom,
|
||||
trackTops: trackRects.map(rect => rect.top),
|
||||
trackRights: trackRects.map(rect => rect.right),
|
||||
trackBottoms: trackRects.map(rect => rect.bottom),
|
||||
}
|
||||
})
|
||||
expect(geometry.boardScrollWidth).toBeLessThanOrEqual(geometry.boardClientWidth)
|
||||
expect(Math.min(...geometry.trackTops)).toBeGreaterThanOrEqual(geometry.environmentBottom - 1)
|
||||
expect(Math.max(...geometry.trackRights)).toBeLessThanOrEqual(geometry.boardRight + 1)
|
||||
expect(Math.max(...geometry.trackBottoms)).toBeLessThanOrEqual(geometry.boardBottom + 1)
|
||||
|
||||
for (const track of await tracks.all()) {
|
||||
const head = track.locator('.today-track-head')
|
||||
const labels = head.locator('strong, span')
|
||||
await expect(labels).toHaveCount(2)
|
||||
const boxes = await labels.evaluateAll(nodes => nodes.map(node => node.getBoundingClientRect()))
|
||||
expect(Math.abs(boxes[0].top - boxes[1].top)).toBeLessThan(4)
|
||||
}
|
||||
})
|
||||
test('Today task persists through detail, completion and reopen', async ({ page }, testInfo) => {
|
||||
const title = `E2E 今日任务 ${testInfo.project.name}`
|
||||
await page.goto('/')
|
||||
|
||||
Reference in New Issue
Block a user