feat: 增加可视化模板页面编辑器
This commit is contained in:
1 parent
9d2038cc93
commit
c5af790554
24 files changed
+773
-129
No files matched your search
@@ -0,0 +1,27 @@
|
||||
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", () => {
|
||||
const url = templatePreviewUrl(
|
||||
"new-template",
|
||||
"brand-a",
|
||||
"profile",
|
||||
JSON.stringify({ "new-template": "https://preview.example.test/app/" }),
|
||||
"https://admin.example.test",
|
||||
"/pages/profile/index",
|
||||
);
|
||||
assert.equal(
|
||||
url,
|
||||
"https://preview.example.test/app/?editor=1&parentOrigin=https%3A%2F%2Fadmin.example.test&brand=brand-a#/pages/profile/index",
|
||||
);
|
||||
});
|
||||
|
||||
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);
|
||||
assert.equal(
|
||||
templatePreviewUrl("broken", "brand-a", "home", JSON.stringify({ broken: "not a URL" })),
|
||||
undefined,
|
||||
);
|
||||
});
|
||||
Reference in new issue
Block a user