Allow fenced HTML tutorials in agent response smoke checks
wiki CI and deployment / verify-and-deploy (push) Successful in 12m37s
wiki CI and deployment / verify-and-deploy (push) Successful in 12m37s
This commit is contained in:
@@ -39,7 +39,7 @@ try {
|
||||
const indexText=await indexResponse.text();
|
||||
const id=indexText.match(/\/explore\/([a-f0-9]{24})/)?.[1];assert.ok(id);
|
||||
const agent=await fetch(`http://127.0.0.1:${port}/explore/${id}?agent_mode=True`);
|
||||
assert.equal(agent.status,200);assert.match(agent.headers.get('content-type'),/text\/plain/);assert.ok(!(await agent.text()).includes('<html'));
|
||||
assert.equal(agent.status,200);assert.match(agent.headers.get('content-type'),/text\/plain/);const agentText=await agent.text();assert.match(agentText,/^# /);assert.doesNotMatch(agentText,/^\s*(?:<!doctype html|<html)/i);
|
||||
const preview=await fetch(`http://127.0.0.1:${port}/api/preview?source=${encodeURIComponent('/skills/shadow-puppet/egret-example.png')}&width=480`);
|
||||
assert.equal(preview.status,200);assert.match(preview.headers.get('content-type'),/image\/webp/);assert.ok((await preview.arrayBuffer()).byteLength<=100000);
|
||||
console.log("Production smoke test passed");
|
||||
|
||||
@@ -15,3 +15,16 @@ test('independent notes expose their own description, tags and complete image co
|
||||
const workflow=(await getEntry(pageId('guidance:shadow-puppet/workflow')))!;
|
||||
assert.notEqual(workflow.description,note.description);assert.notEqual(workflow.id,note.id);
|
||||
});
|
||||
|
||||
test('agent text preserves tutorial HTML and TSX code without returning an HTML page',async()=>{
|
||||
const entry=(await getEntry(pageId('guidance:premium-layout/offset-panels')))!;
|
||||
let body='';const headers:Record<string,string>={};
|
||||
const response={setHeader:(k:string,v:string)=>headers[k]=v,end:(value:string)=>{body=value}};
|
||||
await getServerSideProps({params:{id:entry.id},query:{agent_mode:'True'},res:response,req:{method:'GET'}} as never);
|
||||
assert.match(headers['Content-Type'],/text\/plain/);
|
||||
assert.ok(body.startsWith('# '+entry.title));
|
||||
assert.match(body,/```\n<!doctype html>\n<html lang="zh-CN">/);
|
||||
assert.ok(body.includes('export default function LayoutPoster'));
|
||||
assert.ok(body.includes('app/designs/offset-panels/page.tsx'));
|
||||
assert.equal(body,entryText(entry));
|
||||
});
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
- `apps/wiki/src/content/page-ids.json`:为 13 篇文档持久保存独立 ID,标题与排序变化不改变地址。
|
||||
- `apps/wiki/scripts/generate-layout-recipes.ts`:重新生成独立 HTML 演示和 PNG 结构封面,无第三方素材和浏览器依赖。
|
||||
- `apps/wiki/public/layout-recipes/router.png`:12 套构图的总览封面。
|
||||
- `apps/wiki/scripts/smoke.mjs`:以响应类型与 Markdown 开头检查纯文本,允许教程代码块合法包含 HTML。
|
||||
- `apps/wiki/tests/explore.test.ts`:新增回归检查,确保 agent 模式原样保留 HTML 与 TSX 代码示例。
|
||||
- `docs/premium-layouts.md`:内容入口、文件职责、重建与验证说明(本文)。
|
||||
|
||||
以下每个文件基名各对应 `.html` 与 `.png` 两个文件,全部位于 `apps/wiki/public/layout-recipes/`。HTML 为实际可运行示例;PNG 是独立绘制的结构示意,明确标注并非代码截图。
|
||||
|
||||
Reference in New Issue
Block a user