style: add habit row state feedback
ci / gitleaks (push) Successful in 7s
ci / docker (push) Successful in 4m14s

This commit is contained in:
2026-09-19 14:53:02 +08:00
parent 462bf00b57
commit 02507ac7a7
4 changed files with 31 additions and 23 deletions
+12 -2
View File
@@ -33,7 +33,9 @@ function bottomTab(page: Page, name: string) {
}
async function openSidebarView(page: Page, name: string) {
await page.locator('.topbar').getByRole('button', { name: /展开菜单|收起菜单/ }).click()
if ((page.viewportSize()?.width ?? 0) <= 930) {
await page.locator('.topbar').getByRole('button', { name: /展开菜单|收起菜单/ }).click()
}
const target = page.locator('.sidebar').getByRole('button', { name, exact: true })
await expect(target).toBeInViewport()
await target.click()
@@ -72,7 +74,8 @@ test('boolean habits complete in place while paused and unscheduled rows explain
expect(pause.ok(), await pause.text()).toBeTruthy()
await page.goto('/')
await bottomTab(page, '习惯').click()
if ((page.viewportSize()?.width ?? 0) <= 930) await bottomTab(page, '习惯').click()
else await page.locator('.sidebar').getByRole('button', { name: '习惯', exact: true }).click()
const booleanRow = page.locator('.habit-row').filter({ hasText: booleanName })
const booleanCheck = booleanRow.getByRole('button', { name: `完成${booleanName}一次` })
const checkGeometry = await booleanCheck.evaluate((element) => {
@@ -87,7 +90,14 @@ test('boolean habits complete in place while paused and unscheduled rows explain
expect(checkGeometry.height).toBeGreaterThanOrEqual(44)
await booleanCheck.click()
await expect(booleanRow).toHaveClass(/done/)
await expect(booleanRow).toHaveCSS('background-color', 'rgb(251, 247, 240)')
await expect(booleanRow.getByRole('button', { name: `减少${booleanName}一次` })).toHaveAttribute('aria-pressed', 'true')
await booleanRow.locator('.habit-main').click()
await expect(booleanRow).toHaveClass(/selected/)
await expect(booleanRow).toHaveCSS('background-color', 'rgb(255, 244, 229)')
await expect(page.getByRole('dialog', { name: booleanName })).toBeVisible()
await page.getByRole('button', { name: '关闭习惯详情' }).click()
await expect(booleanRow).not.toHaveClass(/selected/)
await page.reload()
const persistedBooleanRow = page.locator('.habit-row').filter({ hasText: booleanName })
await expect(persistedBooleanRow).toHaveClass(/done/)