refactor: 拆分品牌业务类型与页面方案
CI / Static checks (push) Has been cancelled
CI / Production build (push) Has been cancelled
CI / API integration (push) Has been cancelled
CI / Taro builds (acheng-campus-food) (push) Has been cancelled
CI / Taro builds (atelier-solopreneur) (push) Has been cancelled
CI / Taro builds (linjing-editorial) (push) Has been cancelled
CI / Browser regression (push) Has been cancelled
CI / Static checks (push) Has been cancelled
CI / Production build (push) Has been cancelled
CI / API integration (push) Has been cancelled
CI / Taro builds (acheng-campus-food) (push) Has been cancelled
CI / Taro builds (atelier-solopreneur) (push) Has been cancelled
CI / Taro builds (linjing-editorial) (push) Has been cancelled
CI / Browser regression (push) Has been cancelled
This commit is contained in:
1 parent
f02e2cafbb
commit
0d9f4a7d6f
86 files changed
+4111
-1543
No files matched your search
@@ -1,5 +1,7 @@
|
||||
const assert = require("node:assert/strict");
|
||||
const { randomBytes } = require("node:crypto");
|
||||
const { existsSync } = require("node:fs");
|
||||
const path = require("node:path");
|
||||
const { spawnSync } = require("node:child_process");
|
||||
const { PrismaClient } = require("@prisma/client");
|
||||
|
||||
@@ -32,7 +34,47 @@ async function main() {
|
||||
const initialTrustCount = await fixtureDatabase.trustContent.count();
|
||||
const initialFormCount = await fixtureDatabase.inquiryForm.count();
|
||||
const initialReleases = await fixtureDatabase.brandRelease.findMany({ orderBy: { id: "asc" } });
|
||||
// 模拟旧模板遗留数据:数组 config、失效封面和媒体引用。重复 seed 必须修复结构,
|
||||
// 同时保留记录本身和停用状态。
|
||||
const doorsBrand = await fixtureDatabase.brandProfile.findUniqueOrThrow({
|
||||
where: { slug: "linjing-doors" },
|
||||
});
|
||||
const legacyOfferingName = "legacy-offering-repair-fixture";
|
||||
await fixtureDatabase.offering.create({
|
||||
data: {
|
||||
brandId: doorsBrand.id,
|
||||
kind: "service",
|
||||
name: legacyOfferingName,
|
||||
coverUrl: "/media/seed/seed-02.jpg",
|
||||
isEnabled: false,
|
||||
config: [{ url: "/media/seed/seed-02.jpg" }],
|
||||
},
|
||||
});
|
||||
if (run("pnpm", ["db:seed"]) !== 0) return status;
|
||||
const repairedLegacyOffering = await fixtureDatabase.offering.findUniqueOrThrow({
|
||||
where: { brandId_name: { brandId: doorsBrand.id, name: legacyOfferingName } },
|
||||
});
|
||||
assert.equal(
|
||||
Array.isArray(repairedLegacyOffering.config),
|
||||
false,
|
||||
"Repeated seed must repair legacy array config",
|
||||
);
|
||||
assert.ok(
|
||||
repairedLegacyOffering.config &&
|
||||
typeof repairedLegacyOffering.config === "object" &&
|
||||
Array.isArray(repairedLegacyOffering.config.media),
|
||||
"Repeated seed must rebuild legacy media config",
|
||||
);
|
||||
assert.notEqual(
|
||||
repairedLegacyOffering.coverUrl,
|
||||
"/media/seed/seed-02.jpg",
|
||||
"Repeated seed must replace a missing local cover",
|
||||
);
|
||||
assert.equal(
|
||||
repairedLegacyOffering.isEnabled,
|
||||
false,
|
||||
"Repeated seed must preserve disabled offering state",
|
||||
);
|
||||
assert.equal(
|
||||
await fixtureDatabase.trustContent.count(),
|
||||
initialTrustCount,
|
||||
@@ -48,6 +90,32 @@ async function main() {
|
||||
initialReleases,
|
||||
"Repeated seed must preserve release history and snapshots",
|
||||
);
|
||||
const seededOfferings = await fixtureDatabase.offering.findMany({
|
||||
select: { name: true, coverUrl: true, config: true },
|
||||
});
|
||||
assert.ok(seededOfferings.length > 0, "Seed must create offering fixtures");
|
||||
for (const offering of seededOfferings) {
|
||||
assert.ok(
|
||||
offering.config && typeof offering.config === "object" && !Array.isArray(offering.config),
|
||||
`Seed offering config must be an object: ${offering.name}`,
|
||||
);
|
||||
const config = offering.config;
|
||||
const mediaUrls = Array.isArray(config.media)
|
||||
? config.media.flatMap((item) =>
|
||||
item && typeof item === "object" && typeof item.url === "string" ? [item.url] : [],
|
||||
)
|
||||
: [];
|
||||
const localMedia = [offering.coverUrl, ...mediaUrls].filter(
|
||||
(url) => typeof url === "string" && url.startsWith("/media/seed/"),
|
||||
);
|
||||
for (const mediaPath of new Set(localMedia)) {
|
||||
assert.equal(
|
||||
existsSync(path.join(__dirname, "prisma/assets", path.basename(mediaPath))),
|
||||
true,
|
||||
`Seed offering references missing media: ${offering.name} -> ${mediaPath}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
await fixtureDatabase.adminUser.updateMany({
|
||||
where: { username: "admin" },
|
||||
data: { mustChangePassword: false },
|
||||
|
||||
Reference in new issue
Block a user