feat: 建立组件化模板预览基线并规划可视化编辑
This commit is contained in:
1 parent
c5af790554
commit
0b14b5a814
46 files changed
+1880
-427
No files matched your search
@@ -2,12 +2,11 @@ import assert from "node:assert/strict";
|
||||
import test from "node:test";
|
||||
import { templatePreviewUrl } from "../src/lib/template-preview.ts";
|
||||
|
||||
test("template preview URL is resolved from generic deployment configuration", () => {
|
||||
test("template preview URL is resolved from one shared deployment address", () => {
|
||||
const url = templatePreviewUrl(
|
||||
"new-template",
|
||||
"brand-a",
|
||||
"profile",
|
||||
JSON.stringify({ "new-template": "https://preview.example.test/app/" }),
|
||||
"https://preview.example.test/app/",
|
||||
"https://admin.example.test",
|
||||
"/pages/profile/index",
|
||||
);
|
||||
@@ -17,11 +16,18 @@ test("template preview URL is resolved from generic deployment configuration", (
|
||||
);
|
||||
});
|
||||
|
||||
test("missing, malformed or invalid template preview configuration fails closed", () => {
|
||||
assert.equal(templatePreviewUrl("missing", "brand-a", "home", undefined), undefined);
|
||||
assert.equal(templatePreviewUrl("missing", "brand-a", "home", "{"), undefined);
|
||||
test("the shared same-origin preview address is the default", () => {
|
||||
assert.equal(
|
||||
templatePreviewUrl("broken", "brand-a", "home", JSON.stringify({ broken: "not a URL" })),
|
||||
undefined,
|
||||
templatePreviewUrl("brand-a", "home", undefined),
|
||||
"http://localhost:3002/?editor=1&brand=brand-a#/pages/home/index",
|
||||
);
|
||||
assert.equal(templatePreviewUrl("brand-a", "home", "{"), undefined);
|
||||
assert.equal(templatePreviewUrl("brand-a", "home", "not a URL"), undefined);
|
||||
});
|
||||
|
||||
test("same-origin static preview uses its explicit entry document", () => {
|
||||
assert.equal(
|
||||
templatePreviewUrl("brand-a", "home", "/template-preview/index.html", "http://localhost:3005"),
|
||||
"http://localhost:3005/template-preview/index.html?editor=1&parentOrigin=http%3A%2F%2Flocalhost%3A3005&brand=brand-a#/pages/home/index",
|
||||
);
|
||||
});
|
||||
Reference in new issue
Block a user