mirror of
https://github.com/ThearchyHelios/AgentLab.git
synced 2026-11-24 22:03:01 +00:00
数据目录阶段 4A 发布与运行:发布时记下模板 SQL 用到的表的目录版本,正式运行时目录有变化就发提醒事件、不拦运行,运行详情和时间线显示提醒,版本历史显示发布时的目录版本及之后的变化
This commit is contained in:
@@ -720,6 +720,26 @@ await section('Copilot:建议更新数据目录(catalog_patch 操作)', as
|
||||
]).length === 0 && mod.decodeCopilot([{ op: 'catalog_patch', source: 's', table: 't' }]).length === 0)
|
||||
})
|
||||
|
||||
await section('正式运行:发布之后数据目录有变化(catalog.drift 事件)', async () => {
|
||||
const steps = mod.decodeRun([
|
||||
{ seq: 1, type: 'run.started', node_id: null, ts: 1, data: { nodes: 1 } },
|
||||
{ seq: 2, type: 'catalog.drift', node_id: null, ts: 1.01, data: { version: 3, count: 2, tables: [
|
||||
{ source: 'scenic', source_id: 'src-scenic', table: 'visits', label: '入园记录', published: 3, current: 5 },
|
||||
{ source: 'scenic', source_id: 'src-scenic', table: 'parks', label: null, published: 0, current: 1 },
|
||||
] } },
|
||||
])
|
||||
const row = steps.find((s) => s.code === 'catalog_drift')
|
||||
check('一行提醒:「入园记录」等 2 张表有变化', row?.title === '自发布以来,数据目录中「入园记录」等 2 张表有变化', row?.title)
|
||||
check('是警告、不是失败', row?.level === 'warn' && row?.status === 'done' && row?.kind === 'note')
|
||||
check('副标题写明运行未被拦截', !!row?.sub?.includes('运行未被拦截'), row?.sub)
|
||||
check('展开逐表写版本,没有目录写「尚无目录」', !!row?.detail?.includes('「scenic」入园记录(visits):发布时第 3 版,现为第 5 版')
|
||||
&& row.detail.includes('「scenic」parks:发布时尚无目录,现为第 1 版'), row?.detail)
|
||||
const one = mod.catalogDrift({ tables: [{ source: 's', table: 't', label: null, published: 1, current: 2 }] })
|
||||
check('只有一张表:标题不写「等」', one?.title === '自发布以来,数据目录中「t」有变化', one?.title)
|
||||
check('形状不对不出行', mod.decodeRun([{ seq: 1, type: 'catalog.drift', node_id: null, ts: 1, data: { tables: 'x' } }])
|
||||
.every((s) => s.code !== 'catalog_drift'))
|
||||
})
|
||||
|
||||
await section('Copilot:心跳穿插、回话、少了一步、报错', async () => {
|
||||
const steps = mod.decodeCopilot(synthetic.COPILOT_STUCK, { context: 'canvas' })
|
||||
check('心跳穿插的思考仍然并成一条', steps.filter((s) => s.kind === 'think').length === 1,
|
||||
|
||||
@@ -690,6 +690,50 @@ await section('提取模板', async () => {
|
||||
fakes.delete('GET /api/conversations')
|
||||
})
|
||||
|
||||
// ------------------------------------------------------------------ 发布之后数据目录有变化(catalog.drift)
|
||||
|
||||
await section('正式运行:发布之后数据目录有变化,提醒但不拦', async () => {
|
||||
const id = 'fake0catdrift000000000000000000'
|
||||
const t = Date.now() / 1000 - 30
|
||||
const run = {
|
||||
...base, id, status: 'succeeded', run_class: 'formal', version: 3, workflow_id: null,
|
||||
created_at: new Date(t * 1000).toISOString(), started_at: new Date(t * 1000).toISOString(),
|
||||
finished_at: new Date((t + 2) * 1000).toISOString(), output: { 结果: '共 128 人次' },
|
||||
}
|
||||
const graph = { nodes: [
|
||||
{ id: 'a', type: 'input', position: { x: 0, y: 0 }, data: { label: '输入', config: {} } },
|
||||
{ id: 'q', type: 'tool', position: { x: 200, y: 0 }, data: { label: '查询入园人数', config: {} } },
|
||||
], edges: [{ source: 'a', target: 'q' }] }
|
||||
const events = [
|
||||
{ seq: 1, type: 'run.started', node_id: null, ts: t, data: { nodes: 2 } },
|
||||
{ seq: 2, type: 'catalog.drift', node_id: null, ts: t + 0.01, data: { version: 3, count: 2, tables: [
|
||||
{ source: 'scenic', source_id: 'src-scenic', table: 'visits', label: '入园记录', published: 3, current: 5 },
|
||||
{ source: 'scenic', source_id: 'src-scenic', table: 'parks', label: null, published: 0, current: 1 },
|
||||
] } },
|
||||
{ seq: 3, type: 'node.started', node_id: 'a', ts: t + 0.1, data: {} },
|
||||
{ seq: 4, type: 'node.finished', node_id: 'a', ts: t + 0.2, data: { duration_ms: 100 } },
|
||||
{ seq: 5, type: 'node.started', node_id: 'q', ts: t + 0.3, data: {} },
|
||||
{ seq: 6, type: 'node.finished', node_id: 'q', ts: t + 0.4, data: { duration_ms: 100 } },
|
||||
{ seq: 7, type: 'run.finished', node_id: null, ts: t + 2, data: { output: run.output } },
|
||||
]
|
||||
fakes.set(`GET /api/runs/${id}`, () => ({ status: 200, json: run }))
|
||||
fakes.set(`GET /api/runs/${id}/events`, () => ({ status: 200, json: events }))
|
||||
fakes.set(`GET /api/runs/${id}/graph`, () => ({ status: 200, json: { graph, workflow_id: null, version: 3 } }))
|
||||
await page.goto(`${WEB}/runs/${id}`, { waitUntil: 'networkidle' })
|
||||
const banner = page.locator('[data-run-banner="catalog-drift"]')
|
||||
check('详情显示目录变化的横幅', await banner.waitFor({ timeout: 5000 }).then(() => true, () => false))
|
||||
const text = await banner.innerText().catch(() => '')
|
||||
check('横幅标题:「入园记录」等 2 张表有变化', text.includes('自发布以来,数据目录中「入园记录」等 2 张表有变化'), text.split('\n')[0])
|
||||
check('写明运行未被拦截', text.includes('运行未被拦截'))
|
||||
check('逐表写发布时和现在的版本,没有目录写「尚无目录」', text.includes('「scenic」入园记录(visits):发布时第 3 版,现为第 5 版')
|
||||
&& text.includes('「scenic」parks:发布时尚无目录,现为第 1 版'), text.replace(/\s+/g, ' '))
|
||||
check('每张表给到数据目录的入口', (await banner.locator('[data-drift-open="visits"]').getAttribute('href')) === '/data/catalog/src-scenic/visits')
|
||||
check('运行照常完成:没有失败横幅', await page.locator('[data-run-banner=failed]').count() === 0)
|
||||
const row = page.locator('[data-step-code="catalog_drift"]')
|
||||
check('时间线里也有一行提醒', await row.count() === 1 && (await row.innerText()).includes('等 2 张表有变化'))
|
||||
for (const k of [`GET /api/runs/${id}`, `GET /api/runs/${id}/events`, `GET /api/runs/${id}/graph`]) fakes.delete(k)
|
||||
})
|
||||
|
||||
// ------------------------------------------------------------------ 运行中:接流、停止、不能删
|
||||
|
||||
const FAKE = 'fake0running0000000000000000000'
|
||||
|
||||
@@ -263,8 +263,11 @@ async function open({ width = 1440, height = 900, path = '/studio/st-main', pref
|
||||
if (sub === 'versions' && !v) return json(route, VERSIONS)
|
||||
if (sub === 'versions' && v) {
|
||||
const n = Number(v)
|
||||
// 已发布的 v2 记着发布时的目录版本:入园记录之后改过(第 3 版 → 第 5 版),景区表没变
|
||||
return json(route, { ...VERSIONS.find((x) => x.version === n), workflow_id: id,
|
||||
graph: n === 1 ? V1 : GRAPH, graph_hash: 'x', input_fields: [{ name: 'goal' }], published: n === 2 })
|
||||
graph: n === 1 ? V1 : GRAPH, graph_hash: 'x', input_fields: [{ name: 'goal' }], published: n === 2,
|
||||
catalog_versions: n === 2 ? { shop: { parks: 1, visits: 3 } } : null,
|
||||
catalog_changes: n === 2 ? [{ source: 'shop', source_id: 'src-shop', table: 'visits', label: '入园记录', published: 3, current: 5 }] : [] })
|
||||
}
|
||||
if (method === 'GET' && !sub) return state.deleted.has(id) ? json(route, { detail: '工作流不存在,可能已被删除' }, 404) : json(route, FAKES[id])
|
||||
if (method === 'DELETE' && !sub) {
|
||||
@@ -1001,7 +1004,18 @@ await section('版本历史:预览、恢复成一次可撤销的改动', async
|
||||
const rows = await count(page, 'ol[aria-label="版本"] > li')
|
||||
check('列出全部版本', rows === 3, `${rows} 版`)
|
||||
check('标出已发布的那一版', (await page.locator('ol[aria-label="版本"] > li').nth(1).innerText()).includes('已发布'))
|
||||
// 已发布的那一版:看得到发布时的目录版本,之后改过的表标出来
|
||||
await page.locator('ol[aria-label="版本"] > li').nth(1).locator('button').first().click()
|
||||
const cat = page.locator('[data-version-catalog]')
|
||||
await cat.waitFor({ timeout: 3000 }).catch(() => {})
|
||||
const catText = await cat.innerText().catch(() => '')
|
||||
check('已发布的版本写「发布时的目录版本」', catText.includes('发布时的目录版本') && catText.includes('parks') && catText.includes('第 1 版'), catText)
|
||||
check('之后改过的表标出来', (await page.locator('[data-version-catalog-table="visits"]').getAttribute('data-changed')) === 'true'
|
||||
&& catText.includes('之后有变化,现为第 5 版') && catText.includes('1 张表在发布之后有变化'), catText.replace(/\s+/g, ' '))
|
||||
check('没改过的表不标', (await page.locator('[data-version-catalog-table="parks"]').getAttribute('data-changed')) === null)
|
||||
await page.locator('ol[aria-label="版本"] > li').nth(2).locator('button').first().click()
|
||||
await page.waitForTimeout(300)
|
||||
check('没发布过的版本没有目录版本这一栏', await count(page, '[data-version-catalog]') === 0)
|
||||
await page.waitForTimeout(500)
|
||||
check('选一版给出缩略图预览', await count(page, 'svg[aria-label^="缩略图"]') === 1)
|
||||
check('预览列出恢复后将移除的节点', (await page.locator('[role="dialog"][aria-label="版本历史"]').innerText()).includes('将移除'))
|
||||
|
||||
Reference in New Issue
Block a user