Merge pull request 'test: 修复浏览器回归 fixture 契约漂移' (#2) from fix/browser-contract-fixtures into main
Reviewed-on: #2
This commit was merged in pull request #2.
This commit is contained in:
commit
5051839986
5 files changed
+65
-6
No files matched your search
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"schemaVersion": 1,
|
||||
"scope": "模板完成证据登记,保留命令、日志与产物哈希",
|
||||
"generatedAt": "2026-10-21T07:26:30.632Z",
|
||||
"generatedAt": "2026-10-21T08:37:34.818Z",
|
||||
"templates": {
|
||||
"acheng-campus-food": {
|
||||
"real-manifest-interaction": {
|
||||
@@ -256,5 +256,5 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"sourceTreeHash": "83a0afe8d0173132c6cf809e105151e4d435020d70e3f36dce03cd290bc54647"
|
||||
"sourceTreeHash": "ba35ee9629ec5aa84b9984139a4dbabc60fb576b1178f936eb8161eb905184e7"
|
||||
}
|
||||
+27
-1
@@ -61,7 +61,33 @@ pnpm --filter @personal-brand/taro test
|
||||
pnpm --filter @personal-brand/taro test:browser
|
||||
```
|
||||
|
||||
浏览器测试需要先启动 API 和餐饮 H5 预览。`PREVIEW_URL` 指定预览地址,`CHROMIUM_PATH` 指定本机 Chromium;测试只读取开发库,模拟错误响应用于失败路径,不写入真实数据。
|
||||
完整浏览器回归需要同时启动四类服务,缺一会产生误导性的失败:
|
||||
|
||||
```sh
|
||||
# 1. API(3001)。CORS 必须放行 Admin 与两个 H5 预览来源,否则浏览器报 Failed to fetch。
|
||||
CORS_ORIGINS=http://localhost:3002,http://localhost:3003,http://localhost:3005 \
|
||||
pnpm --filter @personal-brand/api dev
|
||||
|
||||
# 2. Admin(3005)。dev server 会把 /api 代理到 3001;静态 preview 没有该代理。
|
||||
ADMIN_PORT=3005 pnpm --filter @personal-brand/admin dev
|
||||
|
||||
# 3. 餐饮 H5(3002)
|
||||
TEMPLATE_KEY=acheng-campus-food PREVIEW_PORT=3002 pnpm --filter @personal-brand/taro dev:h5
|
||||
|
||||
# 4. 林境 H5(3003)
|
||||
TEMPLATE_KEY=linjing-editorial PREVIEW_PORT=3003 pnpm --filter @personal-brand/taro dev:h5
|
||||
```
|
||||
|
||||
然后执行:
|
||||
|
||||
```sh
|
||||
ADMIN_URL=http://127.0.0.1:3005 PREVIEW_URL=http://127.0.0.1:3002 \
|
||||
pnpm --filter @personal-brand/taro test:browser
|
||||
```
|
||||
|
||||
`PREVIEW_URL` 指定餐饮预览地址,林境用例固定访问 `http://localhost:3003`,`CHROMIUM_PATH` 可指定本机 Chromium。测试只读取开发库,模拟错误响应用于失败路径,不写入真实数据。
|
||||
|
||||
当前 Taro 4.3 的 `dev:h5` watch 模式在本地会持续增长直至 OOM,而一次性构建正常。遇到该问题时改用 `TEMPLATE_KEY=<key> pnpm --filter @personal-brand/taro build:h5`,再通过静态服务器托管 `dist/<key>/h5`;静态托管同样需要把对应来源加入 `CORS_ORIGINS`。
|
||||
|
||||
PR 和本地可用轻量 smoke 验证 Admin 会话与创建品牌流程:
|
||||
|
||||
|
||||
@@ -712,6 +712,9 @@ test("林境模板支持首页和主理人区域点选", async ({ page }) => {
|
||||
title: "专业资历",
|
||||
summary: "建筑与门系统经验",
|
||||
content: "持续服务私宅项目",
|
||||
sortOrder: 0,
|
||||
isPublished: true,
|
||||
coverUrl: null,
|
||||
config: {
|
||||
pillars: editorialPillars,
|
||||
serviceFlow: editorialFlow,
|
||||
|
||||
@@ -11,13 +11,17 @@ const manifest = JSON.parse(
|
||||
);
|
||||
const version = {
|
||||
id: "preview-browser-version",
|
||||
templatePackageId: "preview-browser-package",
|
||||
packageKey: manifest.packageKey,
|
||||
version: manifest.version,
|
||||
displayName: manifest.displayName,
|
||||
status: "imported",
|
||||
contentChecksum: "fixture-checksum",
|
||||
archiveChecksum: "fixture-archive-checksum",
|
||||
importedAt: "2026-10-21T00:00:00.000Z",
|
||||
updatedAt: "2026-10-21T00:00:00.000Z",
|
||||
manifestSnapshot: manifest,
|
||||
importedBy: { displayName: "模板管理员" },
|
||||
importedBy: { id: "template-admin", username: "admin", displayName: "模板管理员" },
|
||||
validationReport: {},
|
||||
manifestSummary: { supportedIndustryTemplates: manifest.supportedIndustryTemplates },
|
||||
};
|
||||
@@ -103,6 +107,16 @@ test("模板管理可重试预览,并切换我的、详情和禁止提交的
|
||||
}
|
||||
if (url.pathname.endsWith("/admin/templates"))
|
||||
return route.fulfill({ json: { items: [version], page: 1, pageSize: 20, total: 1 } });
|
||||
if (url.pathname.endsWith("/admin/template-operations/failures"))
|
||||
return route.fulfill({
|
||||
json: {
|
||||
since: "2026-09-21T00:00:00.000Z",
|
||||
until: "2026-10-21T00:00:00.000Z",
|
||||
days: 30,
|
||||
backfilled: true,
|
||||
failures: [],
|
||||
},
|
||||
});
|
||||
if (url.pathname.endsWith("/admin/brands")) return route.fulfill({ json: [] });
|
||||
return route.fulfill({ json: { name: "测试工作区" } });
|
||||
});
|
||||
|
||||
@@ -18,12 +18,15 @@ type PackedChecksums = {
|
||||
|
||||
type PreviewVersion = {
|
||||
id: string;
|
||||
templatePackageId: string;
|
||||
packageKey: string;
|
||||
version: string;
|
||||
displayName: string;
|
||||
status: "imported";
|
||||
manifestSnapshot: PackedManifest;
|
||||
importedBy: { displayName: string };
|
||||
importedBy: { id: string; username: string; displayName: string };
|
||||
importedAt: string;
|
||||
updatedAt: string;
|
||||
validationReport: Record<string, unknown>;
|
||||
manifestSummary: { supportedIndustryTemplates: string[] };
|
||||
artifactPath: string;
|
||||
@@ -88,12 +91,15 @@ async function buildPreviewFixture(mediaCase: MediaCase) {
|
||||
const archivePath = path.join(temporary, archive);
|
||||
const version: PreviewVersion = {
|
||||
id: `preview-media-${mediaCase.packageKey}-${mediaCase.industry}`,
|
||||
templatePackageId: `preview-media-package-${mediaCase.packageKey}`,
|
||||
packageKey: manifest.packageKey,
|
||||
version: manifest.version,
|
||||
displayName: manifest.displayName,
|
||||
status: "imported",
|
||||
manifestSnapshot: manifest,
|
||||
importedBy: { displayName: "模板管理员" },
|
||||
importedBy: { id: "template-admin", username: "admin", displayName: "模板管理员" },
|
||||
importedAt: "2026-10-21T00:00:00.000Z",
|
||||
updatedAt: "2026-10-21T00:00:00.000Z",
|
||||
validationReport: {},
|
||||
manifestSummary: { supportedIndustryTemplates: manifest.supportedIndustryTemplates },
|
||||
artifactPath: archivePath,
|
||||
@@ -216,6 +222,16 @@ test("导入包预览矩阵展示身份、资源和完整媒体槽位", async ({
|
||||
total: 1,
|
||||
},
|
||||
});
|
||||
if (url.pathname.endsWith("/admin/template-operations/failures"))
|
||||
return route.fulfill({
|
||||
json: {
|
||||
since: "2026-09-21T00:00:00.000Z",
|
||||
until: "2026-10-21T00:00:00.000Z",
|
||||
days: 30,
|
||||
backfilled: true,
|
||||
failures: [],
|
||||
},
|
||||
});
|
||||
if (url.pathname.endsWith("/admin/brands")) return route.fulfill({ json: [] });
|
||||
return route.fulfill({ json: { name: "测试工作区" } });
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user