Capture document client navigation failures in CI
creative workspace review checks / verify (pull_request) Failing after 20m32s

This commit is contained in:
2026-10-30 17:44:05 +08:00
parent 40a6076961
commit cfc6686904
@@ -34,6 +34,11 @@ export async function verifyGuidancePublishing(base:string){
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+'/documents',{waitUntil:'domcontentloaded'});
await page.locator(link).waitFor({state:'visible'});assert.equal(await page.locator(link).getByRole('heading').textContent(),httpDoc.title);
@@ -56,7 +61,8 @@ 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');
await page.getByRole('heading',{name:httpDoc.title,exact:true}).waitFor();
try{await page.getByRole('heading',{name:httpDoc.title,exact:true}).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();}