[verified] harden trash actions and mobile details
ci / gitleaks (push) Successful in 26s
ci / docker (push) Successful in 5m5s

This commit is contained in:
2026-09-21 09:37:55 +08:00
parent 8a4d1de9be
commit 927e15cf17
5 changed files with 108 additions and 14 deletions
+34 -3
View File
@@ -1,5 +1,5 @@
import type { APIRequestContext, Page } from '@playwright/test'
import { expect, test } from './fixtures'
import { allowExpectedError, expect, test } from './fixtures'
async function csrf(request: APIRequestContext) {
const state = await request.storageState()
@@ -51,10 +51,33 @@ test('Trash uses compact deadline groups without exposing child-level actions',
const row = page.locator('.task-row--trash').filter({ hasText: title })
await expect(row).toHaveCount(1)
await expect(row.getByRole('button', { name: '恢复' })).toBeVisible()
await expect(row.getByRole('button', { name: '永久删除' })).toBeVisible()
await expect(row.getByRole('button', { name: '打开任务操作' })).toBeVisible()
expect(await row.locator('.task-check').count()).toBe(0)
}
await expect(page.locator('.trash-safety-note')).toContainText('不支持子任务脱离父任务单独恢复或删除')
const overdueRow = page.locator('.task-row--trash').filter({ hasText: overdueTitle })
await expect(overdueRow.locator('.task-tail')).toBeVisible()
const actionTrigger = overdueRow.getByRole('button', { name: '打开任务操作' })
await actionTrigger.focus()
await actionTrigger.press('Enter')
const menu = page.getByRole('menu', { name: '回收站任务操作' })
await expect(menu).toBeVisible()
await expect(menu.getByRole('menuitem', { name: '永久删除' })).toBeFocused()
await menu.getByRole('menuitem', { name: '永久删除' }).press('Tab')
await expect(menu.getByRole('menuitem', { name: '永久删除' })).toBeFocused()
await menu.getByRole('menuitem', { name: '永久删除' }).press('Shift+Tab')
await expect(menu.getByRole('menuitem', { name: '永久删除' })).toBeFocused()
await menu.getByRole('menuitem', { name: '永久删除' }).press('Escape')
await expect(menu).toBeHidden()
await expect(actionTrigger).toBeFocused()
await actionTrigger.click()
await page.getByRole('menuitem', { name: '永久删除' }).click()
const dialog = page.getByRole('dialog')
await expect(dialog).toContainText(`输入任务名称“${overdueTitle}”确认`)
await dialog.getByRole('button', { name: '永久删除' }).click()
await expect(dialog.getByRole('alert')).toContainText('任务名称不匹配')
await dialog.getByRole('button', { name: '取消' }).click()
await expect(actionTrigger).toBeFocused()
const geometry = await page.evaluate(() => ({
viewport: innerWidth,
@@ -69,4 +92,12 @@ test('Trash uses compact deadline groups without exposing child-level actions',
expect(control.width).toBeGreaterThanOrEqual(44)
expect(control.height).toBeGreaterThanOrEqual(44)
}
await actionTrigger.click()
await page.getByRole('menuitem', { name: '永久删除' }).click()
await dialog.getByLabel(`输入任务名称“${overdueTitle}”确认`).fill(overdueTitle)
allowExpectedError(page, `requestfailed: DELETE ${baseURL}/api/v1/trash/`)
await dialog.getByRole('button', { name: '永久删除' }).click()
await expect(overdueRow).toHaveCount(0)
await expect(page.getByRole('heading', { name: '回收站', exact: true })).toBeFocused()
})