Align canvas integration with corrected workspace UI and auth checks
creative workspace review checks / verify (pull_request) Has been cancelled

This commit is contained in:
2026-10-30 18:14:26 +08:00
parent 67dea99cd1
commit 8944e59ead
4 changed files with 22 additions and 9 deletions
@@ -30,12 +30,17 @@ export async function verifyGuidancePublishing(base:string){
const own=await fetch(base+'/api/documents?author='+owner).then(r=>r.json());assert.ok(own.documents.some((d:{id:string})=>d.id===httpDoc.id));assert.ok(own.documents.every((d:{author:string})=>d.author===owner));assert.equal((await fetch(base+'/api/documents?author=invalid')).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>往返标签<\/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.
// The document discovery list hydrates from the real API; the homepage is the product landing page.
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 navigationDiagnostics:string[]=[];
const record=(value:string)=>{navigationDiagnostics.push(value.slice(0,1800));if(navigationDiagnostics.length>12)navigationDiagnostics.shift();};
page.on('pageerror',error=>record('pageerror: '+error.message));
page.on('console',message=>{if(message.type()==='error')record('console: '+message.text());});
page.on('response',response=>{if(response.url().includes('/_next/data/'))void response.text().then(body=>record(`data ${response.status()} ${new URL(response.url()).pathname}: ${body.slice(0,1400)}`)).catch(()=>{});});
const link=`a[href="/documents/${httpDoc.id}?revision=1"]`;
await page.goto(base+'/',{waitUntil:'domcontentloaded'});
await page.goto(base+'/documents',{waitUntil:'domcontentloaded'});
await page.locator(link).waitFor({state:'visible'});assert.equal(await page.locator(link).getByRole('heading').textContent(),httpDoc.title);
// Published matches must not inherit the examples' empty state; submitted filters survive reload.
const search=page.getByRole('textbox',{name:'搜索文档'});
@@ -54,7 +59,11 @@ export async function verifyGuidancePublishing(base:string){
await page.locator(link).waitFor({state:'visible'});
assert.equal(await search.inputValue(),'');
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.locator('h1').waitFor();assert.equal(await page.locator('h1').textContent(),httpDoc.title);
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,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(),'发布独立文档');
}finally{await browser.close();}
assert.equal((await request('/'+httpDoc.id,'DELETE',undefined,{cookie:''})).status,401);
@@ -100,11 +100,11 @@ test(
const page = await context.newPage();
page.setDefaultTimeout(10000);
page.on("pageerror", (error) => errors.push(error.message));
await page.goto(base!, { waitUntil: "networkidle" });
await page.goto(base + "/documents", { waitUntil: "networkidle" });
await page
.getByRole("heading", { name: authored.title, exact: true })
.waitFor();
assert.equal(await page.title(), "探索文档 · 织页");
assert.equal(await page.title(), "社区文档 · 织页");
const search = page.getByRole("textbox", { name: "搜索文档" });
await search.fill("不存在的文档");
await search.press("Enter");
@@ -248,7 +248,7 @@ test(
"通过 XML 更新的文档",
);
await page.setViewportSize({ width: 390, height: 844 });
await page.goto(base!, { waitUntil: "networkidle" });
await page.goto(base + "/documents", { waitUntil: "networkidle" });
assert.equal(
await page.evaluate(
() => document.documentElement.scrollWidth <= window.innerWidth,
@@ -35,7 +35,9 @@ test('real PostgreSQL + S3 notes, flat tags, resource sharing and video processi
await verifyEmailAccounts();
await verifyCanvasWorkspace(base);
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'});