31 lines
5.2 KiB
Plaintext
31 lines
5.2 KiB
Plaintext
group='shared_regressions';
|
|
for(const name of ['旧工作流回退(隔离测试夹具)','空说明回退(隔离测试夹具)']){await begin(name);await loaded();check((await dialog.innerText()).includes('隔离库旧条目回退测试'),'旧/空说明回退 '+name);await page.keyboard.press('Escape');}
|
|
// Missing summary and mismatched bindings are tested with local GET fixtures, without writes.
|
|
for(const variant of ['missing-overview','mismatched','html-summary']){
|
|
const d=structuredClone(details[0]);
|
|
if(variant==='missing-overview')delete d.doc_json.fixed_version.user_overview;
|
|
if(variant==='mismatched')d.doc_json.fixed_version={matched:false,notice:'固定版本参数说明待核对:源文件、声明版本或说明依据未匹配,未采用旧定义。'};
|
|
if(variant==='html-summary')d.doc_json.fixed_version.user_overview='<img src="https://example.invalid/forbidden">仅纯文本';
|
|
await page.route(`**/api/workflows/${d.id}`,route=>{interceptions.push({variant,url:route.request().url()});return route.fulfill({json:d});});
|
|
const responseReady=page.waitForResponse(r=>new URL(r.url()).pathname===`/api/workflows/${d.id}`&&r.status()===200);
|
|
await begin(d.name);const fixtureResponse=await responseReady;await fixtureResponse.finished();
|
|
const returned=await fixtureResponse.json();assert.deepEqual(returned,d);
|
|
const expectedSummary=variant==='missing-overview'?'这张图的用途和操作重点可在下方使用步骤中查看;目标环境与实际效果仍待核对。':variant==='mismatched'?d.doc_json.fixed_version.notice:d.doc_json.fixed_version.user_overview;
|
|
await dialog.getByText(expectedSummary,{exact:true}).waitFor({timeout:20000});await loaded();
|
|
if(variant==='missing-overview')check((await dialog.innerText()).includes('这张图的用途和操作重点可在下方使用步骤中查看;目标环境与实际效果仍待核对。'),'缺摘要自然中文回退');
|
|
if(variant==='mismatched')check((await dialog.innerText()).includes(d.doc_json.fixed_version.notice)&&!await dialog.getByText('核对范围与来源依据',{exact:true}).count(),'错绑定提示明确且不展示旧字段');
|
|
if(variant==='html-summary')check((await dialog.innerText()).includes(d.doc_json.fixed_version.user_overview)&&await dialog.locator('img').count()===0,'摘要HTML仅纯文本不创建图像或请求');
|
|
check(!(await dialog.innerText()).includes('undefined'),'回退不暴露undefined');await page.keyboard.press('Escape');await page.unroute(`**/api/workflows/${d.id}`);
|
|
}
|
|
let release,entered,delivered;const hold=new Promise(r=>release=r),intercept=new Promise(r=>entered=r),done=new Promise(r=>delivered=r);
|
|
await page.route(`**/api/workflows/${details[0].id}`,async route=>{interceptions.push({variant:"late",url:route.request().url()});entered();await hold;await route.fulfill({json:details[0]});delivered();});
|
|
await begin(details[0].name);await intercept;await page.keyboard.press('Escape');await begin(details[1].name);await loaded();release();await done;
|
|
check((await dialog.innerText()).includes(details[1].doc_json.fixed_version.user_overview)&&await fixedCard.locator('summary').filter({hasText:/^节点 [\d:]+ · /}).count()===details[1].doc_json.fixed_version.fields.length,'迟到新图响应不覆盖旧图摘要/字段');await page.keyboard.press('Escape');await page.unroute(`**/api/workflows/${details[0].id}`);
|
|
await page.route(`**/api/workflows/${details[0].id}`,route=>{interceptions.push({variant:'failure',url:route.request().url()});return route.fulfill({status:500,json:{detail:'隔离失败夹具'}});});await begin(details[0].name);await dialog.getByRole('alert').waitFor({timeout:20000});check(await dialog.getByRole('button',{name:'重试',exact:true}).isVisible(),'GET失败显示重试');check(await dialog.getByText('用途与来源',{exact:true}).count()===0,'读取失败隐藏旧摘要');await page.unroute(`**/api/workflows/${details[0].id}`);await dialog.getByRole('button',{name:'重试',exact:true}).click();await loaded();check((await dialog.innerText()).includes(details[0].doc_json.fixed_version.user_overview),'重试恢复摘要');await page.keyboard.press('Escape');
|
|
check(errors.length===0,'无脚本错误或禁止请求 '+JSON.stringify(errors));check(requests.every(r=>r.method==='GET'&&new URL(r.url).hostname==='127.0.0.1'&&!r.url.includes('/api/view')),'全程本地GET无写/生成/目标/历史预览请求');
|
|
const polling=requests.filter(r=>['/api/jobs','/api/events'].includes(new URL(r.url).pathname));
|
|
const fixed=requests.filter(r=>!polling.includes(r));
|
|
const frequencies=rs=>Object.fromEntries([...new Set(rs.map(r=>new URL(r.url).pathname))].sort().map(p=>[p,rs.filter(r=>new URL(r.url).pathname===p).length]));
|
|
fs.writeFileSync(`${out}/browser-results.json`,JSON.stringify({request_accounting:{fixed_count:fixed.length,fixed_paths:frequencies(fixed),polling_count:polling.length,polling_paths:frequencies(polling),polling_tolerance:1,reason:'固定请求逐路径核账;events零差额,只允许已证末次jobs至多1差额;禁止请求零容忍。'},assertion_count:checks.length,assertionGroups,text_renderings:textRenderings,interceptions,checks,requests,errors,blockedFonts,viewports:[1440,390]},null,2));
|
|
} finally {await browser.close();}
|