fix: align desktop habit detail with task pane
ci / gitleaks (push) Successful in 7s
ci / docker (push) Successful in 3m33s

This commit is contained in:
2026-09-20 10:52:39 +08:00
parent 5a3620bf8a
commit 3a23c6cd44
6 changed files with 70 additions and 18 deletions
+28 -4
View File
@@ -61,9 +61,24 @@ test('habit detail paper flow is responsive, ordered, scrollable, and preserves
await openHabits(page)
await expectNoHorizontalOverflow(page)
const shell = page.locator('.shell')
const main = page.locator('main')
const mainBeforeDetail = await main.boundingBox()
const numericOpener = page.locator('.habit-row').filter({ hasText: numericName }).getByRole('button', { name: `查看习惯详情:${numericName}` })
await numericOpener.click()
let dialog = page.getByRole('dialog', { name: numericName })
await expect(shell).toHaveClass(/detail-open/)
if ((page.viewportSize()?.width ?? 0) > 930) {
const [mainAfterDetail, detailBox] = await Promise.all([main.boundingBox(), dialog.boundingBox()])
expect(mainBeforeDetail).not.toBeNull()
expect(mainAfterDetail).not.toBeNull()
expect(detailBox).not.toBeNull()
expect(mainBeforeDetail!.width - mainAfterDetail!.width).toBeCloseTo(350, 0)
expect(detailBox!.width).toBeCloseTo(350, 0)
expect(detailBox!.x).toBeCloseTo(mainAfterDetail!.x + mainAfterDetail!.width, 0)
expect(detailBox!.height).toBeCloseTo(page.viewportSize()!.height, 0)
}
await expect(dialog.locator('.habit-detail-hero')).toContainText('68 / 100')
await expect(dialog.locator('.habit-detail-progress-row')).toContainText('68%')
await expect(dialog.locator('.habit-detail-archive-note')).toHaveCount(0)
@@ -135,8 +150,10 @@ test('habit detail paper flow is responsive, ordered, scrollable, and preserves
const restoreGate = new Promise<void>(resolve => { releaseRestore = resolve })
await page.route(`**/api/v1/habits/${archived.id}/restore`, async route => { await restoreGate; await route.continue() })
await dialog.getByRole('button', { name: '恢复习惯' }).click()
const mask = page.locator('.app-sheet-mask').filter({ has: dialog })
await expect(mask).toHaveAttribute('aria-busy', 'true')
const overlay = (page.viewportSize()?.width ?? 0) <= 930
? page.locator('.app-sheet-mask').filter({ has: dialog })
: dialog
await expect(overlay).toHaveAttribute('aria-busy', 'true')
const closeButton = dialog.getByRole('button', { name: '关闭习惯详情' })
const deleteButton = dialog.getByRole('button', { name: '永久删除' })
const restoreButton = dialog.getByRole('button', { name: '恢复习惯' })
@@ -145,11 +162,18 @@ test('habit detail paper flow is responsive, ordered, scrollable, and preserves
await expect(restoreButton).toBeDisabled()
await closeButton.click({ force: true })
await expect(dialog).toBeVisible()
await mask.click({ position: { x: 2, y: 2 }, force: true })
if ((page.viewportSize()?.width ?? 0) <= 930) await overlay.click({ position: { x: 2, y: 2 }, force: true })
await expect(dialog).toBeVisible()
await page.keyboard.press('Escape')
await expect(dialog).toBeVisible()
// Desktop same-view navigation must force-close a busy detail even though user dismissal stays locked.
if ((page.viewportSize()?.width ?? 0) > 930) {
await page.locator('.sidebar').getByRole('button', { name: '习惯', exact: true }).click()
await expect(dialog).toBeHidden()
await expect(shell).not.toHaveClass(/detail-open/)
}
releaseRestore()
await expect(dialog).toBeHidden()
await expect(archiveToggle).toBeFocused()
await expect(page.locator('.habit-row').filter({ hasText: archivedName })).toBeVisible()
})