Files
xinmi/scripts/verify_native_graph_ui.cjs
yawan f7fc992f57
Anydoc / anydoc parser engine (push) Canceled after 0s
App / Format, vet, test, and build (push) Canceled after 0s
CLI / test (macos-latest / go 1.26) (push) Canceled after 0s
CLI / test (ubuntu-latest / go 1.26) (push) Canceled after 0s
CLI / test (windows-latest / go 1.26) (push) Canceled after 0s
Build and Push Docker Image / build-ui (push) Canceled after 0s
Build and Push Docker Image / build-docreader (push) Canceled after 0s
Build and Push Docker Image / build-sandbox (push) Canceled after 0s
Build and Push Docker Image / build-app (amd64, linux/amd64, ubuntu-latest) (push) Canceled after 0s
Build and Push Docker Image / build-app (arm64, linux/arm64, ubuntu-24.04-arm) (push) Canceled after 0s
DocReader / Python tests and Go client tests (push) Canceled after 0s
Build & Publish (dsh-weknora) / Typecheck, test, pack (push) Canceled after 0s
Build & Publish (dsh-weknora) / End-to-end inside dsh (pinned) (push) Canceled after 0s
Build & Publish (dsh-weknora) / End-to-end inside dsh (latest, advisory) (push) Canceled after 0s
Frontend / Test, type-check, and build (push) Canceled after 0s
Go Lint Cache / warm lint cache (.) (push) Canceled after 0s
Go Lint Cache / warm lint cache (cli) (push) Canceled after 0s
Go Lint Cache / warm lint cache (client) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.10) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.11) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.12) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.13) (push) Canceled after 0s
Build and Push Docker Image / merge (push) Canceled after 0s
Build & Publish (dsh-weknora) / Publish to npm (push) Canceled after 0s
Build & Publish (mcp-server) / Build sdist + wheel (push) Canceled after 0s
Build & Publish (mcp-server) / Publish to PyPI (push) Canceled after 0s
WeKnora deployment source with the reviewed wiki identity, summary and recovery fixes
2026-09-22 16:19:06 +08:00

65 lines
4.5 KiB
JavaScript

const fs = require('node:fs')
const path = require('node:path')
const assert = require('node:assert/strict')
const { chromium } = require('/Users/macclaw/.cache/codex-runtimes/codex-primary-runtime/dependencies/node/node_modules/playwright')
const directory = path.resolve(__dirname, '../../acceptance')
const base = 'http://127.0.0.1:18080/api/v1'
const kb = '16c3e59c-4bb6-41cf-ae0a-6d0941b3d032'
;(async () => {
const credentials = JSON.parse(fs.readFileSync(path.join(directory, 'super-admin-login.json'), 'utf8'))
const auth = await (await fetch(base+'/auth/login', {method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify(credentials)})).json()
const headers = {Authorization:`Bearer ${auth.token}`,'X-Tenant-ID':'10059'}
const started = Date.now()
const response = await fetch(`${base}/knowledge-bases/${kb}/evidence-graph`,{headers})
assert.equal(response.status,200)
const overview = (await response.json()).data
assert.equal(overview.counts.knowledgeentity,2)
assert.equal(overview.mapped_sources,3)
assert.equal((await fetch(`${base}/knowledge-bases/${kb}/evidence-graph`)).status,401)
const metrics = {api_ms:Date.now()-started, counts:overview.counts,mapped_sources:overview.mapped_sources,sources:overview.sources}
const browser = await chromium.launch({headless:true,channel:'chrome'})
try {
const context = await browser.newContext({viewport:{width:1440,height:1000}})
await context.addInitScript(a=>{
const values={weknora_user:JSON.stringify({...a.user,tenant_id:String(a.user.tenant_id)}),weknora_tenant:JSON.stringify({...a.active_tenant,id:'10059'}),weknora_token:a.token,weknora_refresh_token:a.refresh_token,weknora_memberships:JSON.stringify(a.memberships),weknora_selected_tenant_id:'10059'}
for(const [key,value] of Object.entries(values))localStorage.setItem(key,value)
localStorage.setItem('weknora:new-user-guide-done:v1','1')
},auth)
const page=await context.newPage(),errors=[]
page.on('pageerror',error=>errors.push(error.message))
await page.goto(`http://127.0.0.1:15173/platform/knowledge-bases/${kb}?tab=evidence`)
await page.locator('.entity-row').first().waitFor({timeout:30000})
await page.locator('.entity-row').first().click()
await page.locator('.evidence-row').first().waitFor({timeout:30000})
assert.ok(await page.getByText('已核验原生分块',{exact:true}).count()>0)
assert.ok(await page.getByText('仅原始证据',{exact:true}).count()>0)
await page.screenshot({path:path.join(directory,'native-graph-desktop.png'),animations:'disabled'})
await page.getByRole('button',{name:'查看原生文档',exact:true}).first().click()
await page.locator('.t-drawer--open').first().waitFor({timeout:30000})
await page.keyboard.press('Escape')
await page.getByRole('textbox',{name:'搜索实体'}).fill('不存在的图谱实体验收查询')
await page.getByRole('button',{name:'搜索',exact:true}).click()
await page.getByText('没有匹配的实体',{exact:true}).waitFor()
await page.getByRole('textbox',{name:'搜索实体'}).fill('')
await page.getByRole('button',{name:'搜索',exact:true}).click()
await page.locator('.entity-row').first().click()
await page.locator('.evidence-row').first().waitFor()
assert.equal(await page.locator('.guide__backdrop--full').count(),0)
await page.setViewportSize({width:390,height:844})
await page.locator('.aside_box--collapsed').waitFor()
await page.screenshot({path:path.join(directory,'native-graph-mobile.png'),animations:'disabled'})
metrics.mobile_no_overflow=await page.evaluate(()=>document.documentElement.scrollWidth<=innerWidth+2)
metrics.mobile_dimensions=await page.evaluate(()=>({viewport:innerWidth,page:document.documentElement.scrollWidth,shell_min_width:getComputedStyle(document.querySelector('.main')).minWidth}))
metrics.mobile_graph_no_overflow=await page.locator('.evidence-graph').evaluate(element=>element.scrollWidth<=element.clientWidth+2)
assert.ok(metrics.mobile_no_overflow)
assert.ok(metrics.mobile_graph_no_overflow)
assert.deepEqual(errors,[])
metrics.browser_errors=errors
metrics.search_empty_state=true
metrics.native_document_link=true
metrics.graph_tab_has_no_document_guide=true
console.log(JSON.stringify(metrics))
fs.writeFileSync(path.join(directory,'native-graph-ui-verification.json'),JSON.stringify(metrics,null,2)+'\n')
} finally {await browser.close()}
})().catch(error=>{console.error(error);process.exitCode=1})