feat: 能力插件元数据与运行时消费闭环
This commit is contained in:
1 parent
076c6124c8
commit
bb0709b8cc
26 files changed
+2188
-267
No files matched your search
@@ -25,6 +25,8 @@ import {
|
||||
} from "./admin.dto.js";
|
||||
import {
|
||||
capabilityRegistry,
|
||||
capabilityMetadata,
|
||||
validateCapabilityConfig,
|
||||
capabilityPlugins,
|
||||
getBrandTemplate,
|
||||
getTemplateSampleContent,
|
||||
@@ -102,10 +104,15 @@ class AdminWorkspaceController {
|
||||
]);
|
||||
const installed = new Map(installations.map((item) => [item.capabilityKey, item]));
|
||||
const template = getBrandTemplate(templateKey);
|
||||
return (template?.capabilities ?? [])
|
||||
.map((key) => capabilityRegistry[key])
|
||||
const optionalCapabilityKeys = Object.entries(capabilityRegistry)
|
||||
.filter(([, definition]) => "optional" in definition && definition.optional)
|
||||
.map(([key]) => key);
|
||||
return [...new Set([...(template?.capabilities ?? []), ...optionalCapabilityKeys])]
|
||||
.map((key) => capabilityRegistry[key as keyof typeof capabilityRegistry])
|
||||
.filter(Boolean)
|
||||
.map((definition) => {
|
||||
const item = installed.get(definition.key);
|
||||
const metadata = capabilityMetadata(definition.key);
|
||||
return {
|
||||
id: item?.id ?? null,
|
||||
capabilityKey: definition.key,
|
||||
@@ -113,6 +120,7 @@ class AdminWorkspaceController {
|
||||
status: item?.status ?? "enabled",
|
||||
config: item?.config ?? {},
|
||||
source: item ? "brand" : "template",
|
||||
...(metadata ?? {}),
|
||||
updatedAt: item?.updatedAt ?? null,
|
||||
};
|
||||
});
|
||||
@@ -249,18 +257,25 @@ class AdminWorkspaceController {
|
||||
const existing = await this.prisma.capabilityInstallation.findUnique({
|
||||
where: { brandId_capabilityKey: { brandId, capabilityKey: key } },
|
||||
});
|
||||
const definition = capabilityRegistry[key as keyof typeof capabilityRegistry];
|
||||
if (definition && "disablePolicy" in definition && definition.disablePolicy === "disabled")
|
||||
throw new BadRequestException("核心能力不可移除");
|
||||
const configErrors = validateCapabilityConfig(key as never, body.config);
|
||||
if (configErrors === null) throw new BadRequestException("能力配置字段无效");
|
||||
if (Object.keys(configErrors).length)
|
||||
throw new BadRequestException({ message: "能力配置字段无效", errors: configErrors });
|
||||
return this.prisma.$transaction(async (tx) => {
|
||||
const installation = await tx.capabilityInstallation.upsert({
|
||||
where: { brandId_capabilityKey: { brandId, capabilityKey: key } },
|
||||
create: {
|
||||
brandId,
|
||||
capabilityKey: key,
|
||||
capabilityVersion: body.capabilityVersion,
|
||||
capabilityVersion: definition?.version ?? "1.0.0",
|
||||
status: body.status,
|
||||
config: (body.config ?? {}) as Prisma.InputJsonValue,
|
||||
},
|
||||
update: {
|
||||
capabilityVersion: body.capabilityVersion,
|
||||
...(definition ? { capabilityVersion: definition.version } : {}),
|
||||
status: body.status,
|
||||
...(body.config === undefined ? {} : { config: body.config as Prisma.InputJsonValue }),
|
||||
},
|
||||
|
||||
@@ -108,7 +108,6 @@ export class InstallTemplateDto {
|
||||
}
|
||||
|
||||
export class UpdateCapabilityInstallationDto {
|
||||
@IsString() capabilityVersion!: string;
|
||||
@IsIn(["enabled", "disabled", "degraded"])
|
||||
status!: "enabled" | "disabled" | "degraded";
|
||||
@IsOptional() @IsObject() config?: Record<string, unknown>;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import type { BrandReleaseSnapshot } from "../../brand-release.service.js";
|
||||
import type { Prisma } from "@prisma/client";
|
||||
import {
|
||||
capabilityMetadata,
|
||||
capabilityPlugins,
|
||||
defaultBrandTemplateKey,
|
||||
type BrandTemplateKey,
|
||||
@@ -100,20 +101,23 @@ export function assemblePublicWorkspace(input: {
|
||||
defaultBrandTemplateKey;
|
||||
const template = releaseSnapshot.templateDefinition ?? getBrandTemplate(templateKey);
|
||||
const capabilityData = asArray(releaseSnapshot.capabilities) as Array<Record<string, unknown>>;
|
||||
const capabilityRecord = (item: Record<string, unknown>, fallbackVersion = "1.0.0") => {
|
||||
const key = asString(item.capabilityKey) || asString(item.key);
|
||||
const metadata = capabilityMetadata(key as never);
|
||||
return {
|
||||
key,
|
||||
version: asString(item.capabilityVersion, fallbackVersion),
|
||||
status: capabilityStatus(item.status),
|
||||
config: asRecord(item.config),
|
||||
...(metadata ? { metadata: { ...metadata } } : {}),
|
||||
};
|
||||
};
|
||||
const capabilities = capabilityData.length
|
||||
? capabilityData.map((item) => ({
|
||||
key: asString(item.capabilityKey),
|
||||
version: asString(item.capabilityVersion, "1.0.0"),
|
||||
status: capabilityStatus(item.status),
|
||||
config: asRecord(item.config),
|
||||
}))
|
||||
? capabilityData.map((item) => capabilityRecord(item))
|
||||
: template
|
||||
? resolveCapabilities(template.capabilities).map((item) => ({
|
||||
key: item.key,
|
||||
version: item.version,
|
||||
status: "enabled" as const,
|
||||
config: {},
|
||||
}))
|
||||
? resolveCapabilities(template.capabilities).map((item) =>
|
||||
capabilityRecord({ ...item, config: {} }),
|
||||
)
|
||||
: [];
|
||||
const brandConfig = asRecord(brandData.config);
|
||||
const visualTemplateKey =
|
||||
@@ -183,7 +187,11 @@ export function assemblePublicWorkspace(input: {
|
||||
.filter((capability) => capability.status === "enabled")
|
||||
.map((capability) => capabilityPlugins[capability.key as keyof typeof capabilityPlugins])
|
||||
.filter(Boolean)
|
||||
.map((plugin) => ({ ...plugin, status: "enabled" as const, config: {} })),
|
||||
.map((plugin) => ({
|
||||
...plugin,
|
||||
status: "enabled" as const,
|
||||
config: capabilities.find((capability) => capability.key === plugin.key)?.config ?? {},
|
||||
})),
|
||||
theme: visualTemplate?.theme ?? {
|
||||
colors: { background: "#F7F5F1", foreground: "#252525", accent: "#8A6846" },
|
||||
},
|
||||
|
||||
@@ -4,13 +4,11 @@ import { BrandReleaseService } from "../../brand-release.service.js";
|
||||
import {
|
||||
defaultBrandTemplateKey,
|
||||
defaultVisualTemplateKey,
|
||||
brandTemplates,
|
||||
brandTemplateKeys,
|
||||
getBrandTemplate,
|
||||
getVisualTemplate,
|
||||
isVisualTemplateCompatible,
|
||||
resolveCapabilities,
|
||||
visualTemplates,
|
||||
visualTemplateKeys,
|
||||
} from "@personal-brand/config";
|
||||
|
||||
@@ -78,8 +76,8 @@ export class PublicTemplateController {
|
||||
@Get()
|
||||
list(): unknown {
|
||||
return {
|
||||
industries: brandTemplateKeys.map((key) => brandTemplates[key]),
|
||||
visuals: visualTemplateKeys.map((key) => visualTemplates[key]),
|
||||
industries: brandTemplateKeys.map((key) => getBrandTemplate(key)),
|
||||
visuals: visualTemplateKeys.map((key) => getVisualTemplate(key)),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -991,6 +991,10 @@ test("health and public content are available without authentication", async ()
|
||||
assert.ok(Array.isArray(runtime.capabilities));
|
||||
assert.ok(runtime.theme.colors.background);
|
||||
assert.ok(Array.isArray(runtime.plugins));
|
||||
const inquiryPlugin = runtime.plugins.find((plugin) => plugin.key === "inquiry");
|
||||
assert.ok(inquiryPlugin);
|
||||
assert.deepEqual(inquiryPlugin.config, {});
|
||||
assert.deepEqual(inquiryPlugin.purposeBindings, ["inquiry"]);
|
||||
assert.equal(runtime.brand.founder, "阿成");
|
||||
assert.ok(runtime.offerings.every((item) => item.coverUrl));
|
||||
assert.ok(runtime.trustPresentation);
|
||||
@@ -1023,7 +1027,7 @@ test("visual template compatibility is enforced by catalog, preview, and brand s
|
||||
method: "POST",
|
||||
payload: { username: "admin", password: process.env.SEED_ADMIN_PASSWORD },
|
||||
});
|
||||
const token = JSON.parse(login.body).token;
|
||||
const token = JSON.parse(login.body).data?.token ?? JSON.parse(login.body).token;
|
||||
const compatibleSwitch = await request("/admin/config/brand", {
|
||||
method: "PATCH",
|
||||
headers: { authorization: `Bearer ${token}` },
|
||||
@@ -1107,6 +1111,24 @@ test("public workspace uses brand-scoped capability installations and preserves
|
||||
version: "1.0.0",
|
||||
status: "disabled",
|
||||
config: { source: "integration-test" },
|
||||
metadata: {
|
||||
key: "inquiry",
|
||||
version: "1.0.0",
|
||||
displayName: "通用咨询",
|
||||
description: "接收客户的一对一合作咨询。",
|
||||
impact: "停用后所有通用咨询表单都无法提交。",
|
||||
optional: false,
|
||||
disablePolicy: "allowed",
|
||||
allowedPages: ["inquiry", "success"],
|
||||
requiredModules: ["inquiry", "records", "success-summary"],
|
||||
purposeBindings: ["inquiry"],
|
||||
entryNavigationKey: "inquiry",
|
||||
configFields: [
|
||||
{ key: "entryLabel", label: "入口文案", input: "text", required: false },
|
||||
{ key: "submitHint", label: "提交提示", input: "text", required: false },
|
||||
{ key: "disabledHint", label: "停用提示", input: "text", required: false },
|
||||
],
|
||||
},
|
||||
},
|
||||
]);
|
||||
assert.notEqual(body.capabilities[0].status, "enabled");
|
||||
@@ -1118,21 +1140,38 @@ test("public workspace uses brand-scoped capability installations and preserves
|
||||
test("admin can update declared capability status with authorization and audit", async () => {
|
||||
const unauthorized = await request("/admin/workspace/capabilities/inquiry", {
|
||||
method: "PATCH",
|
||||
payload: { capabilityVersion: "1.0.0", status: "disabled" },
|
||||
payload: { status: "disabled" },
|
||||
});
|
||||
assert.equal(unauthorized.statusCode, 401);
|
||||
const customerForbidden = await request("/admin/workspace/capabilities/inquiry", {
|
||||
method: "PATCH",
|
||||
headers: { authorization: `Bearer ${customerToken}` },
|
||||
payload: { status: "disabled" },
|
||||
});
|
||||
assert.equal(customerForbidden.statusCode, 403);
|
||||
const login = await request("/admin/session/login", {
|
||||
method: "POST",
|
||||
payload: { username: "admin", password: process.env.SEED_ADMIN_PASSWORD },
|
||||
});
|
||||
const token = JSON.parse(login.body).token;
|
||||
const token = JSON.parse(login.body).data?.token ?? JSON.parse(login.body).token;
|
||||
const updated = await request("/admin/workspace/capabilities/inquiry", {
|
||||
method: "PATCH",
|
||||
headers: { authorization: `Bearer ${token}` },
|
||||
payload: { capabilityVersion: "1.0.0", status: "disabled", config: { mode: "manual" } },
|
||||
payload: { status: "disabled", config: { entryLabel: "合作咨询", disabledHint: "咨询已暂停" } },
|
||||
});
|
||||
assert.equal(updated.statusCode, 200);
|
||||
assert.equal(JSON.parse(updated.body).status, "disabled");
|
||||
assert.equal(JSON.parse(updated.body).capabilityVersion, "1.0.0");
|
||||
const invalidConfig = await request("/admin/workspace/capabilities/inquiry", {
|
||||
method: "PATCH",
|
||||
headers: { authorization: `Bearer ${token}` },
|
||||
payload: { status: "disabled", config: { unknown: "字段" } },
|
||||
});
|
||||
assert.equal(invalidConfig.statusCode, 400);
|
||||
const saved = await prisma.capabilityInstallation.findUnique({
|
||||
where: { brandId_capabilityKey: { brandId, capabilityKey: "inquiry" } },
|
||||
});
|
||||
assert.deepEqual(saved?.config, { entryLabel: "合作咨询", disabledHint: "咨询已暂停" });
|
||||
const audit = await prisma.capabilityAuditLog.findFirst({
|
||||
where: { brandId, capabilityKey: "inquiry" },
|
||||
orderBy: { createdAt: "desc" },
|
||||
@@ -1148,7 +1187,7 @@ test("editor membership can manage brand content but cannot change system settin
|
||||
method: "POST",
|
||||
payload: { username: "admin", password: process.env.SEED_ADMIN_PASSWORD },
|
||||
});
|
||||
const token = JSON.parse(login.body).token;
|
||||
const token = JSON.parse(login.body).data?.token ?? JSON.parse(login.body).token;
|
||||
const identity = readIdentity(token);
|
||||
const membership = await prisma.brandMembership.findUnique({
|
||||
where: { adminUserId_brandId: { adminUserId: identity.subject, brandId } },
|
||||
@@ -1187,7 +1226,7 @@ test("owner can manage brand members without removing the final owner", async ()
|
||||
method: "POST",
|
||||
payload: { username: "admin", password: process.env.SEED_ADMIN_PASSWORD },
|
||||
});
|
||||
const token = JSON.parse(login.body).token;
|
||||
const token = JSON.parse(login.body).data?.token ?? JSON.parse(login.body).token;
|
||||
const identity = readIdentity(token);
|
||||
const members = await request("/admin/brands/members", {
|
||||
headers: { authorization: `Bearer ${token}` },
|
||||
@@ -1273,6 +1312,8 @@ test("manually created member must change the initial password before normal use
|
||||
});
|
||||
|
||||
test("admin can install optional quote capability without industry-specific branching", async () => {
|
||||
const quoteListUser = await prisma.adminUser.findUniqueOrThrow({ where: { username: "admin" } });
|
||||
const quoteToken = signIdentity({ subject: quoteListUser.id, brandId, role: "admin" });
|
||||
const login = await request("/admin/session/login", {
|
||||
method: "POST",
|
||||
payload: { username: "admin", password: process.env.SEED_ADMIN_PASSWORD },
|
||||
@@ -1281,13 +1322,25 @@ test("admin can install optional quote capability without industry-specific bran
|
||||
const response = await request("/admin/workspace/capabilities/quote-request", {
|
||||
method: "PATCH",
|
||||
headers: { authorization: `Bearer ${token}` },
|
||||
payload: { capabilityVersion: "1.0.0", status: "enabled", config: { currency: "CNY" } },
|
||||
payload: { status: "enabled", config: { entryLabel: "获取报价", submitHint: "48 小时内回复" } },
|
||||
});
|
||||
assert.equal(response.statusCode, 200);
|
||||
assert.equal(JSON.parse(response.body).capabilityKey, "quote-request");
|
||||
assert.equal(JSON.parse(response.body).capabilityVersion, "1.0.0");
|
||||
const list = await request("/admin/workspace/capabilities", {
|
||||
headers: { authorization: `Bearer ${quoteToken}` },
|
||||
});
|
||||
assert.equal(
|
||||
JSON.parse(list.body).find((item) => item.capabilityKey === "quote-request")?.optional,
|
||||
true,
|
||||
);
|
||||
assert.equal((await publishReleaseForTests()).statusCode, 201);
|
||||
const workspace = await request("/public/workspace");
|
||||
assert.ok(JSON.parse(workspace.body).plugins.some((plugin) => plugin.key === "quote-request"));
|
||||
const quotePlugin = JSON.parse(workspace.body).plugins.find(
|
||||
(plugin) => plugin.key === "quote-request",
|
||||
);
|
||||
assert.ok(quotePlugin);
|
||||
assert.deepEqual(quotePlugin.config, { entryLabel: "获取报价", submitHint: "48 小时内回复" });
|
||||
await prisma.capabilityInstallation.deleteMany({
|
||||
where: { brandId, capabilityKey: "quote-request" },
|
||||
});
|
||||
@@ -1302,14 +1355,21 @@ test("admin capability list includes template defaults and brand overrides", asy
|
||||
method: "POST",
|
||||
payload: { username: "admin", password: process.env.SEED_ADMIN_PASSWORD },
|
||||
});
|
||||
const token = JSON.parse(login.body).token;
|
||||
const token = JSON.parse(login.body).data?.token ?? JSON.parse(login.body).token;
|
||||
const defaults = await request("/admin/workspace/capabilities", {
|
||||
headers: { authorization: `Bearer ${token}` },
|
||||
});
|
||||
assert.equal(defaults.statusCode, 200);
|
||||
const defaultBody = JSON.parse(defaults.body);
|
||||
assert.ok(
|
||||
defaultBody.some((item) => item.capabilityKey === "inquiry" && item.source === "template"),
|
||||
defaultBody.some(
|
||||
(item) =>
|
||||
item.capabilityKey === "inquiry" &&
|
||||
item.source === "template" &&
|
||||
item.optional === false &&
|
||||
item.disablePolicy === "allowed" &&
|
||||
item.configFields?.some((field) => field.key === "entryLabel"),
|
||||
),
|
||||
);
|
||||
await prisma.capabilityInstallation.create({
|
||||
data: {
|
||||
@@ -1317,7 +1377,7 @@ test("admin capability list includes template defaults and brand overrides", asy
|
||||
capabilityKey: "inquiry",
|
||||
capabilityVersion: "1.0.0",
|
||||
status: "disabled",
|
||||
config: { mode: "manual" },
|
||||
config: { entryLabel: "品牌自定义咨询" },
|
||||
},
|
||||
});
|
||||
const overrides = await request("/admin/workspace/capabilities", {
|
||||
@@ -1326,7 +1386,7 @@ test("admin capability list includes template defaults and brand overrides", asy
|
||||
const override = JSON.parse(overrides.body).find((item) => item.capabilityKey === "inquiry");
|
||||
assert.equal(override.source, "brand");
|
||||
assert.equal(override.status, "disabled");
|
||||
assert.deepEqual(override.config, { mode: "manual" });
|
||||
assert.deepEqual(override.config, { entryLabel: "品牌自定义咨询" });
|
||||
await prisma.capabilityInstallation.deleteMany({ where: { brandId } });
|
||||
});
|
||||
|
||||
@@ -1339,7 +1399,7 @@ test("admin can install doors industry template through the shared runtime contr
|
||||
method: "POST",
|
||||
payload: { username: "admin", password: process.env.SEED_ADMIN_PASSWORD },
|
||||
});
|
||||
const token = JSON.parse(login.body).token;
|
||||
const token = JSON.parse(login.body).data?.token ?? JSON.parse(login.body).token;
|
||||
try {
|
||||
const installed = await request("/admin/workspace/install", {
|
||||
method: "POST",
|
||||
@@ -1394,7 +1454,7 @@ test("admin can preview and import sample content idempotently", async () => {
|
||||
method: "POST",
|
||||
payload: { username: "admin", password: process.env.SEED_ADMIN_PASSWORD },
|
||||
});
|
||||
const token = JSON.parse(login.body).token;
|
||||
const token = JSON.parse(login.body).data?.token ?? JSON.parse(login.body).token;
|
||||
const preview = await request("/admin/workspace/sample-content/preview", {
|
||||
headers: { authorization: `Bearer ${token}` },
|
||||
});
|
||||
@@ -1474,7 +1534,7 @@ test("admin can install a template and public workspace exposes enabled configur
|
||||
method: "POST",
|
||||
payload: { username: "admin", password: process.env.SEED_ADMIN_PASSWORD },
|
||||
});
|
||||
const token = JSON.parse(login.body).token;
|
||||
const token = JSON.parse(login.body).data?.token ?? JSON.parse(login.body).token;
|
||||
const before = await request("/admin/workspace");
|
||||
assert.equal(before.statusCode, 401);
|
||||
const customerAccess = await request("/admin/workspace", {
|
||||
@@ -1625,7 +1685,7 @@ test("admin can customize workspace fields with brand isolation", async () => {
|
||||
method: "POST",
|
||||
payload: { username: "admin", password: process.env.SEED_ADMIN_PASSWORD },
|
||||
});
|
||||
const token = JSON.parse(login.body).token;
|
||||
const token = JSON.parse(login.body).data?.token ?? JSON.parse(login.body).token;
|
||||
const install = await request("/admin/workspace/install", {
|
||||
method: "POST",
|
||||
headers: { authorization: `Bearer ${token}` },
|
||||
@@ -1677,7 +1737,7 @@ test("admin visual template selection is reflected in public runtime workspace",
|
||||
method: "POST",
|
||||
payload: { username: "admin", password: process.env.SEED_ADMIN_PASSWORD },
|
||||
});
|
||||
const token = JSON.parse(login.body).token;
|
||||
const token = JSON.parse(login.body).data?.token ?? JSON.parse(login.body).token;
|
||||
const before = await request("/public/workspace");
|
||||
assert.equal(before.statusCode, 200);
|
||||
const updated = await request("/admin/config/brand", {
|
||||
@@ -1935,7 +1995,7 @@ test("admin can create and version an inquiry form", async () => {
|
||||
method: "POST",
|
||||
payload: { username: "admin", password: process.env.SEED_ADMIN_PASSWORD },
|
||||
});
|
||||
const token = JSON.parse(login.body).token;
|
||||
const token = JSON.parse(login.body).data?.token ?? JSON.parse(login.body).token;
|
||||
const offering = await prisma.offering.findFirst({ where: { brandId, isEnabled: true } });
|
||||
assert.ok(offering);
|
||||
const created = await request("/admin/workspace/forms", {
|
||||
@@ -2153,7 +2213,7 @@ test("admin rejects invalid dynamic inquiry field definitions", async () => {
|
||||
method: "POST",
|
||||
payload: { username: "admin", password: process.env.SEED_ADMIN_PASSWORD },
|
||||
});
|
||||
const token = JSON.parse(login.body).token;
|
||||
const token = JSON.parse(login.body).data?.token ?? JSON.parse(login.body).token;
|
||||
const invalid = await request("/admin/workspace/forms", {
|
||||
method: "POST",
|
||||
headers: { authorization: `Bearer ${token}` },
|
||||
@@ -2170,7 +2230,7 @@ test("admin can manage offerings and public endpoint hides disabled offerings",
|
||||
method: "POST",
|
||||
payload: { username: "admin", password: process.env.SEED_ADMIN_PASSWORD },
|
||||
});
|
||||
const token = JSON.parse(login.body).token;
|
||||
const token = JSON.parse(login.body).data?.token ?? JSON.parse(login.body).token;
|
||||
const invalidConfig = await request("/admin/workspace/offerings", {
|
||||
method: "POST",
|
||||
headers: { authorization: `Bearer ${token}` },
|
||||
@@ -2248,7 +2308,7 @@ test("offering with an inquiry form cannot be deleted", async () => {
|
||||
method: "POST",
|
||||
payload: { username: "admin", password: process.env.SEED_ADMIN_PASSWORD },
|
||||
});
|
||||
const token = JSON.parse(login.body).token;
|
||||
const token = JSON.parse(login.body).data?.token ?? JSON.parse(login.body).token;
|
||||
const offering = await prisma.offering.create({
|
||||
data: { brandId, kind: "service", name: `保护测试-${Date.now()}`, description: "测试" },
|
||||
});
|
||||
@@ -2283,7 +2343,7 @@ test("seeded admin can log in and read protected booking resources", async () =>
|
||||
payload: { username: "admin", password: process.env.SEED_ADMIN_PASSWORD },
|
||||
});
|
||||
assert.equal(login.statusCode, 201);
|
||||
const token = JSON.parse(login.body).token;
|
||||
const token = JSON.parse(login.body).data?.token ?? JSON.parse(login.body).token;
|
||||
assert.ok(token);
|
||||
|
||||
const count = await request("/admin/bookings/unread-count", {
|
||||
@@ -2312,7 +2372,7 @@ test("admin can list and switch only enabled brand memberships", async () => {
|
||||
method: "POST",
|
||||
payload: { username: "admin", password: process.env.SEED_ADMIN_PASSWORD },
|
||||
});
|
||||
const token = JSON.parse(login.body).token;
|
||||
const token = JSON.parse(login.body).data?.token ?? JSON.parse(login.body).token;
|
||||
const brands = await request("/admin/brands", {
|
||||
headers: { authorization: `Bearer ${token}` },
|
||||
});
|
||||
@@ -2405,7 +2465,7 @@ test("disabled brand membership blocks existing admin token", async () => {
|
||||
method: "POST",
|
||||
payload: { username: "admin", password: process.env.SEED_ADMIN_PASSWORD },
|
||||
});
|
||||
const token = JSON.parse(login.body).token;
|
||||
const token = JSON.parse(login.body).data?.token ?? JSON.parse(login.body).token;
|
||||
const admin = await prisma.adminUser.findUnique({ where: { username: "admin" } });
|
||||
assert.ok(admin);
|
||||
const membership = await prisma.brandMembership.findUnique({
|
||||
@@ -2547,7 +2607,7 @@ test("admin can update user-facing brand presentation without replacing other co
|
||||
method: "POST",
|
||||
payload: { username: "admin", password: process.env.SEED_ADMIN_PASSWORD },
|
||||
});
|
||||
const token = JSON.parse(login.body).token;
|
||||
const token = JSON.parse(login.body).data?.token ?? JSON.parse(login.body).token;
|
||||
const brand = await prisma.brandProfile.findUnique({ where: { id: brandId } });
|
||||
assert.ok(brand);
|
||||
const originalConfig = brand.config;
|
||||
@@ -2583,7 +2643,7 @@ test("admin can manage trust content", async () => {
|
||||
method: "POST",
|
||||
payload: { username: "admin", password: process.env.SEED_ADMIN_PASSWORD },
|
||||
});
|
||||
const token = JSON.parse(login.body).token;
|
||||
const token = JSON.parse(login.body).data?.token ?? JSON.parse(login.body).token;
|
||||
assert.equal((await request("/admin/config/trust-content")).statusCode, 401);
|
||||
assert.equal(
|
||||
(
|
||||
|
||||
Reference in new issue
Block a user