feat(web): add explore source configuration modals

This commit is contained in:
2026-07-22 15:56:04 +08:00
parent 74775ed64f
commit 5d2f45ad83
3 changed files with 221 additions and 62 deletions

View File

@@ -130,7 +130,7 @@ for (const forbidden of ['DeepSeek V4.0 Flash', '给 DeepSeek 发送消息', 'Ic
}
const explorePageSource = readFileSync('src/pages/workspace-explore.tsx', 'utf8')
for (const required of ['explore-source-card', 'explore-reader-layout', '同步数据源', '添加数据源', 'detectSource']) {
for (const required of ['explore-source-card', 'explore-reader-layout', '同步数据源', '添加数据源', 'detectSource', 'explore-source-modal', 'openAddSource', 'openEditSource']) {
if (!explorePageSource.includes(required)) failures.push(`workspace explore page must restore ${required}`)
}

View File

@@ -200,6 +200,31 @@ await page.waitForTimeout(500)
await page.screenshot({ path: 'test-results/workspace-explore-react-acro-light.png', fullPage: true })
const workspaceExploreMetrics = await collectMetrics()
await page.getByRole('button', { name: '添加数据源' }).click()
await page.waitForSelector('.explore-source-modal')
await page.waitForTimeout(250)
await page.screenshot({ path: 'test-results/explore-add-source-modal.png', fullPage: true })
const addSourceModalCheck = await page.evaluate(() => ({
title: document.querySelector('.explore-source-modal .arco-modal-title')?.textContent ?? '',
inputCount: document.querySelectorAll('.explore-source-modal input, .explore-source-modal textarea').length,
}))
await page.locator('.explore-source-modal input').first().fill('行业资讯')
await page.locator('.explore-source-modal .arco-modal-footer .arco-btn-primary').click()
const addedSourceVisible = await page.locator('.explore-source-card', { hasText: '行业资讯' }).count() === 1
await page.locator('.explore-source-card').nth(1).hover()
await page.getByRole('button', { name: '编辑手动收集' }).click()
await page.waitForSelector('.explore-source-modal')
await page.waitForTimeout(250)
await page.screenshot({ path: 'test-results/explore-edit-source-modal.png', fullPage: true })
const editSourceModalCheck = await page.evaluate(() => ({
title: document.querySelector('.explore-source-modal .arco-modal-title')?.textContent ?? '',
name: document.querySelector('.explore-source-modal input')?.value ?? '',
}))
await page.locator('.explore-source-modal input').first().fill('手动整理')
await page.locator('.explore-source-modal .arco-modal-footer .arco-btn-primary').click()
const editedSourceVisible = await page.locator('.explore-source-card', { hasText: '手动整理' }).count() === 1
await page.locator('.project-button').first().click()
await page.waitForTimeout(500)
await page.screenshot({ path: 'test-results/project-react-acro-light.png', fullPage: true })
@@ -246,6 +271,10 @@ await server.close()
console.log(JSON.stringify({
workspaceMetrics,
workspaceExploreMetrics,
addSourceModalCheck,
addedSourceVisible,
editSourceModalCheck,
editedSourceVisible,
projectMetrics,
channelSidebarHoverMetrics,
stageHoverMetrics,
@@ -341,6 +370,14 @@ if (workspaceExploreMetrics.channelSidebar) failures.push(`expected workspace ex
if (workspaceExploreMetrics.inspector) failures.push(`expected workspace explore to hide inspector, got ${JSON.stringify(workspaceExploreMetrics.inspector)}`)
if (workspaceExploreMetrics.exploreSourceCardCount !== 4) failures.push(`expected four legacy explore source cards, got ${workspaceExploreMetrics.exploreSourceCardCount}`)
if (!workspaceExploreMetrics.hasExploreReader) failures.push('expected legacy explore article reader to render')
if (!addSourceModalCheck.title.includes('添加数据源') || addSourceModalCheck.inputCount < 3) {
failures.push(`expected add data source modal with fields, got ${JSON.stringify(addSourceModalCheck)}`)
}
if (!addedSourceVisible) failures.push('expected saved data source to appear in the source cards')
if (!editSourceModalCheck.title.includes('编辑数据源') || editSourceModalCheck.name !== '手动收集') {
failures.push(`expected prefilled edit data source modal, got ${JSON.stringify(editSourceModalCheck)}`)
}
if (!editedSourceVisible) failures.push('expected edited data source name to update its card')
if (!workspaceExploreMetrics.stage || !workspaceExploreMetrics.projectRail) {
failures.push(`missing workspace explore layout regions: rail=${JSON.stringify(workspaceExploreMetrics.projectRail)}, stage=${JSON.stringify(workspaceExploreMetrics.stage)}`)
} else if (Math.abs(workspaceExploreMetrics.stage.left - workspaceExploreMetrics.projectRail.right) > 1) {