🐛 fix(frontend): 修复回收站清理失败提示与恢复文案

This commit is contained in:
orion committed 2026-09-18 10:29:20 +08:00
1 parent 21d4c30f80
commit 61845699b3
4 files changed
+53 -6

No files matched your search

+7
View File
@@ -54,3 +54,10 @@ inner cards and action buttons retain their motion. List rows only fade their
background with no border or box-shadow. Light card shadows are bright at the
upper left and shaded at the lower right; dark mode reverses that direction.
Primary submit actions must not add white/gradient hover overlays.
## 清理失败弹窗
`purgeFailure.browser.mjs` 导出 `runPurgeFailureChecks(page, failure)`,接受独立
Playwright Page。Vite 固定运行于 `127.0.0.1:5180`;分别传入 `http` 和 `network`
验证服务端 500、断网时错误显示于弹窗内、原记录保留,以及重新打开时清空旧错误。
测试拦截全部管理 API,不会修改部署实例。
+39
View File
@@ -0,0 +1,39 @@
import assert from 'node:assert/strict'
// Call with a fresh Playwright page and the local Vite fixture; all API calls
// are intercepted, so this check cannot modify a deployed backend.
export async function runPurgeFailureChecks(page, failure = 'http') {
await page.route('**/*', route => {
const url = new URL(route.request().url())
return url.hostname === '127.0.0.1' ? route.continue() : route.abort()
})
await page.route('**/admin/**', async route => {
const url = new URL(route.request().url())
const headers = { 'access-control-allow-origin': '*', 'access-control-allow-headers': '*', 'access-control-allow-methods': '*' }
if (route.request().method() === 'OPTIONS') return route.fulfill({ status: 204, headers })
if (url.pathname === '/admin/trash/list') {
return route.fulfill({ json: { code: 200, detail: {
page: 1, size: 20, total: 1,
data: [{ id: 900001, name: 'isolated-check.txt', code: 'CHECK001', size: 16,
isTrashPurged: false, isTrashPermanent: true, trashReason: 'manual' }],
capabilities: { batch: true, filters: true, customRetention: true },
summary: { total: 1, recoverable: 1, purged: 0 }
} }, headers })
}
if (url.pathname === '/admin/trash/batch') {
assert.deepEqual(route.request().postDataJSON(), { action: 'purge', ids: [900001] })
return failure === 'network' ? route.abort() : route.fulfill({ status: 500, json: { detail: '测试服务暂时不可用' }, headers })
}
throw new Error(`Unexpected API request: ${url.pathname}`)
})
await page.goto('http://127.0.0.1:5180/theme-assets/tests/trash-workflow.html')
await page.getByRole('button', { name: '彻底删除', exact: true }).click()
const dialog = page.getByRole('dialog')
await dialog.getByRole('button', { name: '确认清理 1 项' }).click()
await dialog.getByRole('alert').waitFor({ state: 'visible', timeout: 4000 })
assert.ok((await dialog.getByRole('alert').textContent()).trim())
assert.equal(await page.locator('article').count(), 1)
await dialog.getByRole('button', { name: '取消', exact: true }).click()
await page.getByRole('button', { name: '彻底删除', exact: true }).click()
assert.equal(await page.getByRole('dialog').getByRole('alert').count(), 0)
}
+2 -2
View File
@@ -48,8 +48,8 @@ export async function runTrashWorkflowChecks() {
const selectable=[...document.querySelectorAll('article input')].filter(e=>!e.disabled)
selectable[0].click();await new Promise(r=>setTimeout(r,0));selectable[1].click();await new Promise(r=>setTimeout(r,0));await wait(()=>button('批量恢复'));assert([...document.querySelectorAll('article input')].filter(e=>e.checked).length===2,'未选中两条记录')
button('批量恢复').click();await wait(()=>document.querySelectorAll('article').length===4)
assert(document.querySelectorAll('code').length===2,'未展示恢复后的新取件码')
done('通过:批量恢复、列表刷新和新取件码展示')
assert(document.querySelectorAll('code').length===2,'未展示恢复后的取件码')
done('通过:批量恢复、列表刷新和取件码展示')
document.querySelector('input[type=checkbox]').click();await wait(()=>button('批量清理'))
button('批量清理').click();await wait(()=>document.querySelector('[role=dialog]'))
modal=document.querySelector('[role=dialog]');assert(modal.textContent.includes('不可恢复')&&modal.textContent.includes('3'),'缺少删除数量或后果提示')