From 53ee034db8233c501297117b85c239d976982b34 Mon Sep 17 00:00:00 2001 From: que01 Date: Tue, 22 Sep 2026 17:29:15 +0800 Subject: [PATCH] =?UTF-8?q?test:=20=E9=AA=8C=E8=AF=81=E8=BF=90=E8=A1=8C?= =?UTF-8?q?=E6=97=B6=E5=B7=A5=E4=BD=9C=E7=A9=BA=E9=97=B4=E5=85=AC=E5=BC=80?= =?UTF-8?q?=E5=A5=91=E7=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/api/src/main.ts | 1 + apps/api/test/http.integration.test.js | 11 +++++++++++ docs/template-runtime-progress.md | 2 ++ 3 files changed, 14 insertions(+) diff --git a/apps/api/src/main.ts b/apps/api/src/main.ts index c6e6e02..621a05d 100644 --- a/apps/api/src/main.ts +++ b/apps/api/src/main.ts @@ -147,6 +147,7 @@ export class PublicWorkspaceController { config: this.jsonObject(module.config), source: module.source === "custom" ? "custom" : module.source === "template" ? "template" : "core", + schemaVersion: "1.0", })); const runtimeOfferings: RuntimeOffering[] = offerings.map((item) => { const config = this.jsonObject(item.config); diff --git a/apps/api/test/http.integration.test.js b/apps/api/test/http.integration.test.js index 54726f9..0df23ae 100644 --- a/apps/api/test/http.integration.test.js +++ b/apps/api/test/http.integration.test.js @@ -46,6 +46,17 @@ test("health and public content are available without authentication", async () assert.ok(JSON.parse(services.body).length >= 3); const removedServicesRoute = await request("/public/services"); assert.equal(removedServicesRoute.statusCode, 404); + + const workspace = await request("/public/workspace"); + assert.equal(workspace.statusCode, 200); + const runtime = JSON.parse(workspace.body); + assert.equal(runtime.schemaVersion, "1.0.0"); + assert.ok(Array.isArray(runtime.navigation.tabs)); + assert.ok(Array.isArray(runtime.modules)); + assert.ok(Array.isArray(runtime.offerings)); + assert.ok(Array.isArray(runtime.inquiryForms)); + assert.ok(Array.isArray(runtime.capabilities)); + assert.ok(runtime.theme.colors.background); }); test("admin can install a template and public workspace exposes enabled configuration", async () => { diff --git a/docs/template-runtime-progress.md b/docs/template-runtime-progress.md index defbdf4..1ef3f3a 100644 --- a/docs/template-runtime-progress.md +++ b/docs/template-runtime-progress.md @@ -21,6 +21,8 @@ - [x] 新增模板声明的基础校验函数。 - [x] 在 API 增加运行时工作空间公开接口字段(`/public/workspace`)。 - [x] API 工作空间输出统一导航、模块、Offering、表单和能力结构。 +- [x] 增加公开工作空间契约结构测试。 +- [x] 集成测试覆盖运行时 schemaVersion、导航、模块、Offering、表单、能力和主题。 - [ ] 增加 API 授权、品牌隔离和 schema 版本测试。 - [ ] 让 Admin 与小程序读取同一运行时契约。