From cad84f8a6730f7780cc8c4d851e1c6f9814cb355 Mon Sep 17 00:00:00 2001 From: Codex Bot Date: Fri, 30 Oct 2026 18:13:58 +0800 Subject: [PATCH] Run nested UI checks and align authentication assertions with public workspace routes --- apps/waterfall-wiki/scripts/auth-cli.ts | 6 ++++-- apps/waterfall-wiki/tests/guidance-integration.ts | 2 +- apps/waterfall-wiki/tests/integration.test.ts | 4 +++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/apps/waterfall-wiki/scripts/auth-cli.ts b/apps/waterfall-wiki/scripts/auth-cli.ts index e79ae89..240402a 100644 --- a/apps/waterfall-wiki/scripts/auth-cli.ts +++ b/apps/waterfall-wiki/scripts/auth-cli.ts @@ -47,13 +47,15 @@ async function main() { if (command === 'verify' || command === 'exercise') { const request = (path:string,init:RequestInit={}) => fetch(base+path,{...init,redirect:'manual'}); const buildId = readFileSync('.next/BUILD_ID','utf8').trim(); - assert.equal((await request('/')).status,200,'Public knowledge homepage'); + for(const path of ['/','/workspace','/documents','/account'])assert.equal((await request(path)).status,200,'Public shell '+path); + const studio=await request('/studio');assert.equal(studio.status,307);assert.equal(studio.headers.get('location'),'/workspace'); + for(const [from,to] of [['/studio/graphic','/graphic'],['/studio/infinite_canvas','/infinite_canvas']]){const r=await request(from);assert.equal(r.status,308);assert.equal(r.headers.get('location'),to)} assert.equal((await request('/account')).status,200,'Public account page'); const homeData = await request(`/_next/data/${buildId}/index.json`); assert.ok([200,404].includes(homeData.status),'Public homepage data is readable or absent for static pages'); assert.ok(!isLoginRedirect(homeData.headers.get('location') || homeData.headers.get('x-nextjs-redirect'),base)); assert.equal((await request('/api/posts',{method:'POST',headers:{Cookie:'wiki_account='+ 'a'.repeat(64)},body:'{}'})).status,401,'Account cookies never grant admin rights'); - for (const path of ['/library/import','/skills/shadow-puppet/egret-example.png','/studio',`/_next/data/${buildId}/library/import.json`]) { + for (const path of ['/library/import','/skills/shadow-puppet/egret-example.png','/studio/layouts/ref-01',`/_next/data/${buildId}/library/import.json`]) { const response = await request(path); assert.equal(response.status,307,path); const destination = response.headers.get('location') || response.headers.get('x-nextjs-redirect'); assert.ok(isLoginRedirect(destination,base),path+' must redirect to login: '+destination); } for (const path of ['/api/feed','/api/upload','/studio/api/export/test','/api/media/missing']) assert.equal((await request(path)).status,401,path); diff --git a/apps/waterfall-wiki/tests/guidance-integration.ts b/apps/waterfall-wiki/tests/guidance-integration.ts index 7dfc8be..aa2f694 100644 --- a/apps/waterfall-wiki/tests/guidance-integration.ts +++ b/apps/waterfall-wiki/tests/guidance-integration.ts @@ -61,7 +61,7 @@ export async function verifyGuidancePublishing(base:string){ await page.getByRole('navigation',{name:'主导航',exact:true}).getByRole('link',{name:'社区文档',exact:true}).click();await page.locator(link).waitFor({state:'visible'}); await page.locator(link).click(); await page.waitForURL(url=>url.pathname==='/documents/'+httpDoc.id&&url.searchParams.get('revision')==='1'); - try{await page.getByRole('heading',{name:httpDoc.title,exact:true}).waitFor();} + try{await page.getByRole('heading',{name:httpDoc.title,exact:true,level:1}).waitFor();} catch(error){console.error('Document navigation diagnostics',JSON.stringify({url:page.url(),headings:await page.locator('h1').allTextContents(),events:navigationDiagnostics}));throw error;} assert.equal(await page.locator('h1').textContent(),httpDoc.title); await page.goto(base+'/write',{waitUntil:'domcontentloaded'});assert.equal(await page.locator('h1').textContent(),'发布独立文档'); diff --git a/apps/waterfall-wiki/tests/integration.test.ts b/apps/waterfall-wiki/tests/integration.test.ts index 256b88a..b5b6ceb 100644 --- a/apps/waterfall-wiki/tests/integration.test.ts +++ b/apps/waterfall-wiki/tests/integration.test.ts @@ -33,7 +33,9 @@ test('real PostgreSQL + S3 notes, flat tags, resource sharing and video processi for(const route of ['/','/images','/videos','/audio','/articles','/motion','/library/import','/tools/doodle','/tools/skills','/tools/skills/street-people','/tools/skills/shadow-puppet'])assert.equal((await fetch(base+route)).status,200,route); await verifyEmailAccounts(); await verifyGuidancePublishing(base); - const workspaceUI=spawn(process.execPath,['--import','tsx','--test','tests/guidance-workspace.test.ts'],{env:{...process.env,WORKSPACE_TEST_URL:base},timeout:90000,stdio:'inherit'}); + const workspaceEnv:NodeJS.ProcessEnv={...process.env,WORKSPACE_TEST_URL:base}; + delete workspaceEnv.NODE_TEST_CONTEXT; + const workspaceUI=spawn(process.execPath,['--import','tsx','--test','tests/guidance-workspace.test.ts'],{env:workspaceEnv,timeout:90000,stdio:'inherit'}); const [workspaceExit]=await once(workspaceUI,'exit');assert.equal(workspaceExit,0,'SaaS workspace UI regression checks'); await verifyFlatNoteMigration(); const root=await request('/api/tags',{name:'线条',slug:'lines'});const child=await request('/api/tags',{name:'白色',slug:'white'});