From 29e4ac849b835adbec6c3699476ecf1dacf0b4c3 Mon Sep 17 00:00:00 2001 From: Codex Bot Date: Thu, 29 Oct 2026 17:17:59 +0800 Subject: [PATCH] Replace legacy homepage expectations with real guidance discovery checks --- apps/waterfall-wiki/tests/guidance-integration.ts | 12 ++++++++++++ apps/waterfall-wiki/tests/integration.test.ts | 5 ++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/apps/waterfall-wiki/tests/guidance-integration.ts b/apps/waterfall-wiki/tests/guidance-integration.ts index ef4d4a2..b7bf9e6 100644 --- a/apps/waterfall-wiki/tests/guidance-integration.ts +++ b/apps/waterfall-wiki/tests/guidance-integration.ts @@ -1,4 +1,5 @@ import assert from 'node:assert/strict'; +import {chromium} from 'playwright-core'; import {randomUUID} from 'node:crypto'; import {newToken,tokenDigest,ACCOUNT_COOKIE} from '../src/lib/account-crypto'; import {guidanceXml} from '../src/content/guides/catalog'; @@ -28,6 +29,17 @@ export async function verifyGuidancePublishing(base:string){ assert.equal((await request('','POST',{...httpDoc,id:'user-'+other+'-http'})).status,400); const xml=await fetch(base+'/api/documents/'+httpDoc.id+'?revision=1&format=xml');assert.equal(xml.status,200);assert.match(await xml.text(),/往返标签<\/tag>/); const page=await fetch(base+'/documents/'+httpDoc.id+'?revision=1');assert.equal(page.status,200);assert.ok((await page.text()).includes('实际数据库文档')); + // The homepage and discovery list hydrate from the real API, so verify them in Chromium on the CI runner. + const browser=await chromium.launch({executablePath:process.env.CHROMIUM_PATH||'/usr/bin/chromium',headless:true,args:['--no-sandbox','--disable-dev-shm-usage']}); + try{ + const page=await browser.newPage(); + const link=`a[href="/documents/${httpDoc.id}?revision=1"]`; + await page.goto(base+'/',{waitUntil:'domcontentloaded'}); + await page.locator(link).waitFor({state:'visible'});assert.equal(await page.locator(link).textContent(),httpDoc.title); + await page.locator('header a[href="/documents"]').click();await page.locator(link).waitFor({state:'visible'}); + await page.locator(link).click();await page.locator('h1').waitFor();assert.equal(await page.locator('h1').textContent(),httpDoc.title); + await page.goto(base+'/write',{waitUntil:'domcontentloaded'});assert.equal(await page.locator('h1').textContent(),'发布独立文档'); + }finally{await browser.close();} assert.equal((await request('/'+httpDoc.id,'DELETE',undefined,{cookie:''})).status,401); assert.equal((await request('/'+httpDoc.id,'DELETE')).status,200); assert.equal((await fetch(base+'/api/documents/'+httpDoc.id)).status,404); diff --git a/apps/waterfall-wiki/tests/integration.test.ts b/apps/waterfall-wiki/tests/integration.test.ts index 3ed898a..3bc49f6 100644 --- a/apps/waterfall-wiki/tests/integration.test.ts +++ b/apps/waterfall-wiki/tests/integration.test.ts @@ -209,7 +209,10 @@ test('real PostgreSQL + S3 notes, flat tags, resource sharing and video processi for(const image of ['egret-example','dancer-example'])assert.equal((await fetch(base+`/skills/shadow-puppet/${image}.png`,{method:'HEAD'})).status,200); for(const path of ['/skills/missing/SKILL.md','/skills/shadow-puppet/missing.md','/tools/skills/shadow-puppet/missing'])assert.equal((await fetch(base+path)).status,404,path); assert.equal((await fetch(base+'/api/skill-docs/shadow-puppet/SKILL',{method:'POST'})).status,405); - const home=await fetch(base+'/').then(r=>r.text());assert.ok(home.includes('/explore/'));assert.ok(home.includes('分类'));assert.ok(home.includes('照片入皮影')); + const home=await fetch(base+'/').then(r=>r.text()); + for(const href of ['/documents','/write','/protocol','/guide/review-changes'])assert.ok(home.includes('href=\"'+href+'\"'),`Guidance homepage links to ${href}`); + assert.ok(home.includes('用户发布'));assert.ok(home.includes('协议样例')); + // Legacy media and skill functionality stays covered by its own routes above and below. const spec=await request('/api/skills/street-people');assert.equal(spec.generation.executor,'coding-agent'); assert.equal((await fetch(base+'/api/skills/street-people?format=md')).headers.get('content-type'),'text/markdown; charset=utf-8');