feat(desktop): align explore view with web reader

This commit is contained in:
2026-07-25 22:59:35 +08:00
parent ac674d71e7
commit 4ffd51a831
5 changed files with 60 additions and 11 deletions

View File

@@ -23,6 +23,8 @@ const workspace = {
cronPlans: [{ id: 'cron-1', projectId, title: '每周复盘', schedule: '0 17 * * 5', nextRun: null, enabled: true, lastResult: '', owner: '张明' }],
}
const expert = { id: 'expert-1', slug: 'product-manager', category: 'product', categoryName: '产品', name: '产品经理', description: '负责需求分析', emoji: '📘', color: '#165DFF' }
const datasetSource = { id: 'source-1', name: '行业资讯', kind: 'rss', url: 'https://example.com/feed', iconUrl: '', description: '行业动态', enabled: true, builtIn: false, lastSyncedAt: null, itemCount: 1, createdAt: '2026-07-22T10:00:00Z', updatedAt: '2026-07-22T10:00:00Z' }
const datasetItem = { id: 'item-1', sourceId: 'source-1', title: 'AI 工作台趋势', summary: '新的协作方式正在改变项目管理。', content: '这是来自数据源的探索内容,可在 Web 工作台继续管理数据源和同步任务。', url: '', imageUrl: '', status: 'unread', starred: false, publishedAt: '2026-07-22T10:00:00Z', createdAt: '2026-07-22T10:00:00Z', updatedAt: '2026-07-22T10:00:00Z' }
await page.route('http://localhost:9150/api/v1/**', async (route) => {
const request = route.request(); const path = new URL(request.url()).pathname
@@ -31,6 +33,8 @@ await page.route('http://localhost:9150/api/v1/**', async (route) => {
if (path === '/api/v1/projects') return route.fulfill({ json: [workspace.project] })
if (path === `/api/v1/projects/${projectId}/workspace`) return route.fulfill({ json: workspace })
if (path === '/api/v1/ai-experts') return route.fulfill({ json: [expert] })
if (path === '/api/v1/dataset-sources') return route.fulfill({ json: [datasetSource] })
if (path === '/api/v1/dataset-items') return route.fulfill({ json: { items: [datasetItem], total: 1, limit: 50, offset: 0 } })
if (path.includes('/tasks/') && request.method() === 'PATCH') return route.fulfill({ json: {} })
return route.fulfill({ status: 404, json: { error: { code: 'not_found', message: '未配置的检查接口' } } })
})
@@ -52,7 +56,10 @@ await page.locator('.task-row').first().click()
const taskModal = await page.getByText('编辑任务').count()
await page.getByRole('button', { name: '取消' }).click()
await page.getByRole('button', { name: '探索' }).click()
const exploreProjects = await page.locator('.project-explore-card').count()
await page.waitForSelector('.explore-detail')
const exploreSources = await page.locator('.explore-source-strip button').count()
const exploreDetail = await page.locator('.explore-detail').count()
await page.screenshot({ path: 'test-results/app-explore.png', fullPage: true })
await page.locator('.project-current').click()
await page.getByRole('option', { name: '森林项目' }).click()
await page.waitForSelector('.channel-rail')
@@ -74,10 +81,10 @@ if (home.navCount !== 0) failures.push(`all-projects view must hide the right ra
if (home.statCount !== 4) failures.push(`expected four summary cards, got ${home.statCount}`)
if (home.pending !== 1 || home.completed !== 0) failures.push(`all-project task sections incorrect: ${JSON.stringify(home)}`)
if (taskModal !== 1) failures.push('task editor did not open')
if (exploreProjects !== 1) failures.push(`expected one project in explore, got ${exploreProjects}`)
if (exploreSources !== 2 || exploreDetail !== 1) failures.push(`explore reader did not render: ${JSON.stringify({ exploreSources, exploreDetail })}`)
if (documents !== 1) failures.push(`expected one document, got ${documents}`)
if (experts !== 1) failures.push(`expected one AI expert, got ${experts}`)
if (profileMenu !== 1) failures.push('profile menu did not open')
if (errors.length) failures.push(`console errors: ${errors.join('; ')}`)
console.log(JSON.stringify({ home, documents, experts, taskModal, exploreProjects, profileMenu, errors }, null, 2))
console.log(JSON.stringify({ home, documents, experts, taskModal, exploreSources, exploreDetail, profileMenu, errors }, null, 2))
if (failures.length) throw new Error(failures.join('\n'))