feat: connect inbox confirmation workflow
This commit is contained in:
@@ -7,6 +7,7 @@ const requiredFiles = [
|
||||
'src/pages/workspace-home.tsx',
|
||||
'src/pages/workspace-explore.tsx',
|
||||
'src/pages/projects/project-overview.tsx',
|
||||
'src/pages/projects/project-inbox.tsx',
|
||||
'src/pages/projects/project-channel-page.tsx',
|
||||
'src/pages/projects/project-tasks.tsx',
|
||||
'src/pages/projects/project-ai.tsx',
|
||||
@@ -33,7 +34,7 @@ for (const token of ['--color-primary: #165dff', '--font-sans', '--space-4: 16px
|
||||
if (!tokenSource.toLowerCase().includes(token)) failures.push(`missing token ${token}`)
|
||||
}
|
||||
for (const forbidden of ['森林Agent', 'AI智能体', '实时接口', '进度 60%']) {
|
||||
for (const file of requiredFiles.filter((name) => name.endsWith('.tsx'))) {
|
||||
for (const file of requiredFiles.filter((name) => name.endsWith('.tsx') && existsSync(name))) {
|
||||
if (readFileSync(file, 'utf8').includes(forbidden)) failures.push(`${file} contains forbidden copy ${forbidden}`)
|
||||
}
|
||||
}
|
||||
@@ -42,7 +43,7 @@ if (existsSync('src/App.tsx')) {
|
||||
failures.push('legacy src/App.tsx should be removed after page split')
|
||||
}
|
||||
|
||||
for (const removed of ['src/pages/projects/project-data.tsx', 'src/pages/projects/project-inspector.tsx', 'src/pages/projects/project-inbox.tsx']) {
|
||||
for (const removed of ['src/pages/projects/project-data.tsx', 'src/pages/projects/project-inspector.tsx']) {
|
||||
if (existsSync(removed)) {
|
||||
failures.push(`${removed} should be removed; frontend data must come from backend APIs`)
|
||||
}
|
||||
@@ -105,6 +106,11 @@ const inboxSource = existsSync('src/api/inbox.ts') ? readFileSync('src/api/inbox
|
||||
for (const path of ['/api/v1/projects/', '/api/v1/inbox/']) {
|
||||
if (inboxSource && !inboxSource.includes(path)) failures.push(`inbox API must use ${path}`)
|
||||
}
|
||||
if (inboxSource.includes('body: { suggestions }')) failures.push('inbox confirm must not send client-authored suggestion content')
|
||||
if (!inboxSource.includes('body: { suggestionIds }')) failures.push('inbox confirm must send only saved suggestion identities')
|
||||
|
||||
const inboxPageSource = existsSync('src/pages/projects/project-inbox.tsx') ? readFileSync('src/pages/projects/project-inbox.tsx', 'utf8') : ''
|
||||
if (inboxPageSource && !inboxPageSource.includes('确认创建')) failures.push('project inbox must expose the single confirmation action')
|
||||
|
||||
const html = readFileSync('index.html', 'utf8')
|
||||
if (!html.includes('<html lang="zh-CN">')) failures.push('index language must be zh-CN')
|
||||
|
||||
@@ -20,6 +20,14 @@ const errors = []
|
||||
const failures = []
|
||||
const projectId = '019b0000-0000-7000-8000-000000000001'
|
||||
const taskSearchResultId = '019b0000-0000-7000-8000-000000000003'
|
||||
const inboxItemId = '019b0000-0000-7000-8000-000000000004'
|
||||
const inboxTaskSuggestionId = '019b0000-0000-7000-8000-000000000005'
|
||||
const inboxNoteSuggestionId = '019b0000-0000-7000-8000-000000000006'
|
||||
const inboxSourceSuggestionId = '019b0000-0000-7000-8000-000000000007'
|
||||
const secondInboxItemId = '019b0000-0000-7000-8000-000000000008'
|
||||
const secondInboxTaskSuggestionId = '019b0000-0000-7000-8000-000000000009'
|
||||
const secondInboxNoteSuggestionId = '019b0000-0000-7000-8000-000000000010'
|
||||
const secondInboxSourceSuggestionId = '019b0000-0000-7000-8000-000000000011'
|
||||
const unknownProjectId = '019b0000-0000-7000-8000-000000000099'
|
||||
const externalProjectId = '019b0000-0000-7000-8000-000000000088'
|
||||
const externalTaskId = '019b0000-0000-7000-8000-000000000089'
|
||||
@@ -27,8 +35,16 @@ const externalNoteId = '019b0000-0000-7000-8000-000000000090'
|
||||
const searchRequests = []
|
||||
const workspaceRequests = []
|
||||
const projectPatchRequests = []
|
||||
const inboxAnalyzeRequests = []
|
||||
const inboxConfirmRequests = []
|
||||
let expectingProjectPatchError = false
|
||||
let expectedProjectPatchConsoleErrorCount = 0
|
||||
let expectingInboxConfirmError = false
|
||||
let expectedInboxConfirmConsoleErrorCount = 0
|
||||
let expectingInboxRefreshError = false
|
||||
let expectedInboxRefreshConsoleErrorCount = 0
|
||||
let failNextInboxConfirm = true
|
||||
let failNextInboxWorkspaceRefresh = false
|
||||
page.on('console', (message) => {
|
||||
if (message.type() !== 'error') return
|
||||
if (
|
||||
@@ -39,6 +55,22 @@ page.on('console', (message) => {
|
||||
expectedProjectPatchConsoleErrorCount += 1
|
||||
return
|
||||
}
|
||||
if (
|
||||
expectingInboxConfirmError &&
|
||||
expectedInboxConfirmConsoleErrorCount === 0 &&
|
||||
message.text() === 'Failed to load resource: the server responded with a status of 500 (Internal Server Error)'
|
||||
) {
|
||||
expectedInboxConfirmConsoleErrorCount += 1
|
||||
return
|
||||
}
|
||||
if (
|
||||
expectingInboxRefreshError &&
|
||||
expectedInboxRefreshConsoleErrorCount === 0 &&
|
||||
message.text() === 'Failed to load resource: the server responded with a status of 500 (Internal Server Error)'
|
||||
) {
|
||||
expectedInboxRefreshConsoleErrorCount += 1
|
||||
return
|
||||
}
|
||||
errors.push(message.text())
|
||||
})
|
||||
|
||||
@@ -55,16 +87,38 @@ const visualCheckWorkspace = {
|
||||
},
|
||||
channels: [
|
||||
{ id: 'overview', projectId, type: 'overview', title: '概况', icon: 'home', count: 0, url: '', sortOrder: 0 },
|
||||
{ id: 'tasks', projectId, type: 'tasks', title: '工作计划', icon: 'list', count: 1, url: '', sortOrder: 1 },
|
||||
{ id: 'ai', projectId, type: 'ai_sessions', title: 'AI 助手', icon: 'robot', count: 0, url: '', sortOrder: 2 },
|
||||
{ id: 'notes', projectId, type: 'notes_sources', title: '笔记资料', icon: 'file', count: 0, url: '', sortOrder: 3 },
|
||||
{ id: 'cron', projectId, type: 'cron', title: '计划任务', icon: 'clock', count: 0, url: '', sortOrder: 4 },
|
||||
{ id: 'inbox', projectId, type: 'inbox', title: 'Inbox 消息流', icon: 'mail', count: 2, url: '', sortOrder: 1 },
|
||||
{ id: 'tasks', projectId, type: 'tasks', title: '工作计划', icon: 'list', count: 1, url: '', sortOrder: 2 },
|
||||
{ id: 'ai', projectId, type: 'ai_sessions', title: 'AI 助手', icon: 'robot', count: 0, url: '', sortOrder: 3 },
|
||||
{ id: 'notes', projectId, type: 'notes_sources', title: '笔记资料', icon: 'file', count: 0, url: '', sortOrder: 4 },
|
||||
{ id: 'cron', projectId, type: 'cron', title: '计划任务', icon: 'clock', count: 0, url: '', sortOrder: 5 },
|
||||
],
|
||||
tags: [{ id: '019b0000-0000-7000-8000-000000000002', name: '产品' }],
|
||||
recentSessions: [
|
||||
{ id: 'session-1', projectId, title: '移动导航会话', summary: '检查抽屉关闭行为', updatedAt: '2026-07-21T02:00:00Z', references: [] },
|
||||
],
|
||||
inbox: [],
|
||||
inbox: [
|
||||
{
|
||||
id: inboxItemId,
|
||||
projectId,
|
||||
source: '手动收集',
|
||||
title: '整理客户访谈',
|
||||
summary: '把访谈结论整理为后续任务、会议纪要和背景资料。',
|
||||
status: 'open',
|
||||
tag: '待处理',
|
||||
time: '2026-07-21T02:30:00Z',
|
||||
},
|
||||
{
|
||||
id: secondInboxItemId,
|
||||
projectId,
|
||||
source: '手动收集',
|
||||
title: '项目复盘记录',
|
||||
summary: '整理项目复盘中的行动项和背景信息。',
|
||||
status: 'open',
|
||||
tag: '待处理',
|
||||
time: '2026-07-21T02:20:00Z',
|
||||
},
|
||||
],
|
||||
tasks: [],
|
||||
aiSessions: [],
|
||||
notesSources: [],
|
||||
@@ -88,9 +142,62 @@ await page.route('http://localhost:9150/api/v1/**', async (route) => {
|
||||
}
|
||||
if (url.pathname === `/api/v1/projects/${projectId}/workspace`) {
|
||||
workspaceRequests.push(url.pathname)
|
||||
if (failNextInboxWorkspaceRefresh) {
|
||||
failNextInboxWorkspaceRefresh = false
|
||||
await route.fulfill({
|
||||
status: 500,
|
||||
json: { error: { code: 'internal_error', message: '工作区刷新失败,请稍后重试' } },
|
||||
})
|
||||
return
|
||||
}
|
||||
await route.fulfill({ json: visualCheckWorkspace })
|
||||
return
|
||||
}
|
||||
if (url.pathname === `/api/v1/inbox/${inboxItemId}/analyze` && method === 'POST') {
|
||||
inboxAnalyzeRequests.push(inboxItemId)
|
||||
if (inboxAnalyzeRequests.length === 1) await new Promise((resolve) => setTimeout(resolve, 250))
|
||||
await route.fulfill({
|
||||
json: {
|
||||
suggestions: [
|
||||
{ id: inboxTaskSuggestionId, kind: 'task', title: '跟进客户反馈', body: '联系客户确认下一步时间。' },
|
||||
{ id: inboxNoteSuggestionId, kind: 'note', title: '客户访谈纪要', body: '保存访谈中的关键结论。' },
|
||||
{ id: inboxSourceSuggestionId, kind: 'source', title: '访谈背景资料', body: '保存为文本资料,不伪造文件路径。' },
|
||||
],
|
||||
},
|
||||
})
|
||||
return
|
||||
}
|
||||
if (url.pathname === `/api/v1/inbox/${secondInboxItemId}/analyze` && method === 'POST') {
|
||||
inboxAnalyzeRequests.push(secondInboxItemId)
|
||||
await route.fulfill({
|
||||
json: {
|
||||
suggestions: [
|
||||
{ id: secondInboxTaskSuggestionId, kind: 'task', title: '整理复盘任务', body: '安排下一次复盘。' },
|
||||
{ id: secondInboxNoteSuggestionId, kind: 'note', title: '复盘记录', body: '保存复盘结论。' },
|
||||
{ id: secondInboxSourceSuggestionId, kind: 'source', title: '复盘资料', body: '保存复盘背景。' },
|
||||
],
|
||||
},
|
||||
})
|
||||
return
|
||||
}
|
||||
if ([`/api/v1/inbox/${inboxItemId}/confirm`, `/api/v1/inbox/${secondInboxItemId}/confirm`].includes(url.pathname) && method === 'POST') {
|
||||
inboxConfirmRequests.push(route.request().postDataJSON())
|
||||
await new Promise((resolve) => setTimeout(resolve, 250))
|
||||
if (failNextInboxConfirm) {
|
||||
failNextInboxConfirm = false
|
||||
await route.fulfill({
|
||||
status: 500,
|
||||
json: { error: { code: 'internal_error', message: '确认创建失败,请稍后重试' } },
|
||||
})
|
||||
return
|
||||
}
|
||||
const confirmedItemId = url.pathname.split('/').at(-2)
|
||||
visualCheckWorkspace.inbox.find((item) => item.id === confirmedItemId).status = 'processed'
|
||||
visualCheckWorkspace.channels.find((channel) => channel.type === 'inbox').count -= 1
|
||||
if (confirmedItemId === secondInboxItemId) failNextInboxWorkspaceRefresh = true
|
||||
await route.fulfill({ json: { createdCount: inboxConfirmRequests.at(-1).suggestionIds.length } })
|
||||
return
|
||||
}
|
||||
if (url.pathname === '/api/v1/search') {
|
||||
const query = url.searchParams.get('q') ?? ''
|
||||
searchRequests.push(query)
|
||||
@@ -487,6 +594,119 @@ const stageHoverMetrics = await collectMetrics()
|
||||
await page.locator('.channel-list').hover()
|
||||
const channelListHoverMetrics = await collectMetrics()
|
||||
|
||||
const inboxChannelButton = page.locator('.channel-button', { hasText: 'Inbox 消息流' })
|
||||
if (await inboxChannelButton.count() === 0) {
|
||||
failures.push('project sidebar must expose the Inbox channel from the workspace API')
|
||||
} else {
|
||||
await inboxChannelButton.click()
|
||||
const inboxPage = page.locator('.project-inbox-page')
|
||||
if (await inboxPage.count() === 0) {
|
||||
failures.push('Inbox channel must render the confirmation workflow page')
|
||||
} else {
|
||||
for (const content of ['整理客户访谈', '把访谈结论整理为后续任务、会议纪要和背景资料。']) {
|
||||
if (!await inboxPage.getByText(content, { exact: true }).first().isVisible()) failures.push(`Inbox content missing ${content}`)
|
||||
}
|
||||
if (await inboxPage.getByRole('button', { name: '确认创建', exact: true }).count() !== 1) {
|
||||
failures.push('Inbox page must render exactly one 确认创建 action')
|
||||
}
|
||||
const firstInboxRow = inboxPage.locator('.mail-item', { hasText: '整理客户访谈' })
|
||||
const secondInboxRow = inboxPage.locator('.mail-item', { hasText: '项目复盘记录' })
|
||||
await inboxPage.getByRole('button', { name: '分析内容', exact: true }).click()
|
||||
await secondInboxRow.click()
|
||||
await page.waitForTimeout(300)
|
||||
if (await inboxPage.getByRole('checkbox').count() !== 0) {
|
||||
failures.push('a stale analysis response must not attach the previous item drafts to the newly selected Inbox item')
|
||||
}
|
||||
await firstInboxRow.click()
|
||||
await inboxPage.getByRole('button', { name: '分析内容', exact: true }).click()
|
||||
await inboxPage.getByRole('checkbox').first().waitFor({ state: 'attached', timeout: 2000 }).catch(() => {})
|
||||
if (inboxAnalyzeRequests.length !== 2 || inboxConfirmRequests.length !== 0) {
|
||||
failures.push('analysis must load drafts without invoking confirmation writes')
|
||||
}
|
||||
if (await inboxPage.getByRole('checkbox').count() !== 3) {
|
||||
failures.push('analysis must render one checkbox for each saved suggestion')
|
||||
}
|
||||
const sourceSuggestionCheckbox = inboxPage.locator('.arco-checkbox', { hasText: '访谈背景资料' })
|
||||
await sourceSuggestionCheckbox.click()
|
||||
if (await sourceSuggestionCheckbox.locator('input[type="checkbox"]').isChecked()) {
|
||||
failures.push('suggestion checkbox must allow the user to exclude a draft before confirmation')
|
||||
}
|
||||
|
||||
const confirmButton = inboxPage.getByRole('button', { name: '确认创建', exact: true })
|
||||
expectingInboxConfirmError = true
|
||||
await confirmButton.click()
|
||||
await page.waitForTimeout(50)
|
||||
if (!await confirmButton.evaluate((button) => button.classList.contains('arco-btn-loading'))) {
|
||||
failures.push('Inbox confirmation must show loading while the write is pending')
|
||||
}
|
||||
await page.waitForTimeout(300)
|
||||
if (!await inboxPage.getByText('确认创建失败,请稍后重试', { exact: true }).isVisible()) {
|
||||
failures.push('failed Inbox confirmation must show the API Chinese error')
|
||||
}
|
||||
expectingInboxConfirmError = false
|
||||
if (expectedInboxConfirmConsoleErrorCount !== 1) {
|
||||
failures.push(`expected one simulated Inbox confirm console error, got ${expectedInboxConfirmConsoleErrorCount}`)
|
||||
}
|
||||
|
||||
const workspaceRequestCount = workspaceRequests.length
|
||||
await confirmButton.click()
|
||||
await inboxPage.getByText('已创建 2 个对象', { exact: true }).waitFor({ state: 'visible', timeout: 2000 }).catch(() => {})
|
||||
if (!await inboxPage.getByText('已创建 2 个对象', { exact: true }).isVisible()) {
|
||||
failures.push('successful Inbox confirmation must show the created object count')
|
||||
}
|
||||
const submitted = inboxConfirmRequests.at(-1)?.suggestionIds ?? []
|
||||
if (JSON.stringify(submitted) !== JSON.stringify([inboxTaskSuggestionId, inboxNoteSuggestionId])) {
|
||||
failures.push(`Inbox confirm must send only checked saved suggestion identities, got ${JSON.stringify(submitted)}`)
|
||||
}
|
||||
if (workspaceRequests.length <= workspaceRequestCount) {
|
||||
failures.push('successful Inbox confirmation must refresh the project workspace')
|
||||
}
|
||||
await page.screenshot({ path: 'test-results/project-inbox-confirmed.png', fullPage: true })
|
||||
await page.setViewportSize({ width: 390, height: 844 })
|
||||
await page.waitForTimeout(250)
|
||||
await page.screenshot({ path: 'test-results/project-inbox-confirmed-mobile.png', fullPage: true })
|
||||
const inboxMobileLayout = await inboxPage.evaluate((node) => {
|
||||
const workflow = node.querySelector('.mail-layout')
|
||||
const detail = node.querySelector('.inbox-detail')
|
||||
const detailRight = detail?.getBoundingClientRect().right ?? node.getBoundingClientRect().right
|
||||
const clippedDetailLabels = [...node.querySelectorAll('.inbox-detail-head > div > .arco-typography-secondary, .inbox-draft-section .section-header > .arco-typography-secondary')]
|
||||
.filter((label) => label.getBoundingClientRect().right > detailRight + 1)
|
||||
.map((label) => label.textContent?.trim())
|
||||
return {
|
||||
pageOverflow: node.scrollWidth > node.clientWidth,
|
||||
workflowOverflow: workflow ? workflow.scrollWidth > workflow.clientWidth : true,
|
||||
clippedDetailLabels,
|
||||
}
|
||||
})
|
||||
if (inboxMobileLayout.pageOverflow || inboxMobileLayout.workflowOverflow || inboxMobileLayout.clippedDetailLabels.length) {
|
||||
failures.push(`Inbox confirmation page must stack without mobile horizontal overflow, got ${JSON.stringify(inboxMobileLayout)}`)
|
||||
}
|
||||
await page.setViewportSize({ width: 1440, height: 1024 })
|
||||
|
||||
await secondInboxRow.click()
|
||||
await inboxPage.getByRole('button', { name: '分析内容', exact: true }).click()
|
||||
await inboxPage.getByRole('checkbox').first().waitFor({ state: 'attached', timeout: 2000 }).catch(() => {})
|
||||
expectingInboxRefreshError = true
|
||||
const secondConfirmButton = inboxPage.getByRole('button', { name: '确认创建', exact: true })
|
||||
await secondConfirmButton.click()
|
||||
await inboxPage.getByText('已创建 3 个对象', { exact: true }).waitFor({ state: 'visible', timeout: 2000 }).catch(() => {})
|
||||
if (!await inboxPage.getByText('已创建 3 个对象', { exact: true }).isVisible()) {
|
||||
failures.push('a completed confirmation must preserve its created count when workspace refresh fails')
|
||||
}
|
||||
if (!await inboxPage.getByText('对象已创建,但工作区刷新失败,请稍后重新进入项目', { exact: true }).isVisible()) {
|
||||
failures.push('workspace refresh failure after confirmation must be shown separately in Chinese')
|
||||
}
|
||||
if (!await secondConfirmButton.isDisabled()) {
|
||||
failures.push('a confirmed item must remain non-repeatable when its workspace refresh fails')
|
||||
}
|
||||
expectingInboxRefreshError = false
|
||||
if (expectedInboxRefreshConsoleErrorCount !== 1) {
|
||||
failures.push(`expected one simulated Inbox refresh console error, got ${expectedInboxRefreshConsoleErrorCount}`)
|
||||
}
|
||||
await page.screenshot({ path: 'test-results/project-inbox-refresh-warning.png', fullPage: true })
|
||||
}
|
||||
}
|
||||
|
||||
const channelPageChecks = []
|
||||
for (const channel of [
|
||||
{ label: '工作计划', pageClass: 'project-tasks-page', expectedHeading: '工作计划' },
|
||||
|
||||
Reference in New Issue
Block a user