完善 readiness、发布追溯与敏感治理(07-15-production-trust-closeout-cleanup)
这个提交包含在:
@@ -1,32 +1,23 @@
|
||||
const fs = require("node:fs/promises");
|
||||
const os = require("node:os");
|
||||
const path = require("node:path");
|
||||
|
||||
const createPrismaClient = vi.fn(() => ({
|
||||
prisma: {
|
||||
$connect: vi.fn().mockResolvedValue(undefined),
|
||||
$disconnect: vi.fn().mockResolvedValue(undefined),
|
||||
employee: {
|
||||
findUnique: vi.fn(),
|
||||
},
|
||||
},
|
||||
pool: {
|
||||
end: vi.fn().mockResolvedValue(undefined),
|
||||
},
|
||||
}));
|
||||
const fp = require("fastify-plugin");
|
||||
|
||||
const startJobs = vi.fn(async () => ({ driver: "disabled" }));
|
||||
|
||||
vi.mock("../../src/prismaClient", () => ({
|
||||
createPrismaClient,
|
||||
}));
|
||||
|
||||
vi.mock("../../src/jobs/jobSystem", () => ({
|
||||
startJobs,
|
||||
}));
|
||||
|
||||
const { buildApp } = require("../../src/app");
|
||||
|
||||
function createPrismaPlugin() {
|
||||
return fp(async (app) => {
|
||||
app.decorate("prisma", {
|
||||
$queryRaw: vi.fn().mockResolvedValue([{ ok: 1 }]),
|
||||
employee: {
|
||||
findUnique: vi.fn(),
|
||||
},
|
||||
});
|
||||
}, { name: "test-prisma" });
|
||||
}
|
||||
|
||||
async function createClientDistFixture() {
|
||||
const tempDir = await fs.mkdtemp(path.join(os.tmpdir(), "hyb-oa-static-cache-"));
|
||||
await fs.mkdir(path.join(tempDir, "assets"), { recursive: true });
|
||||
@@ -46,8 +37,12 @@ async function buildStaticApp(clientDistDir) {
|
||||
vi.stubEnv("CLIENT_DIST_DIR", clientDistDir);
|
||||
vi.stubEnv("STORAGE_DIR", path.join(clientDistDir, "..", "storage"));
|
||||
vi.stubEnv("JOBS_ENABLED", "false");
|
||||
vi.stubEnv("DATABASE_URL", "");
|
||||
|
||||
return buildApp();
|
||||
return buildApp({
|
||||
prismaPlugin: createPrismaPlugin(),
|
||||
startJobs,
|
||||
});
|
||||
}
|
||||
|
||||
describe("app static cache headers", () => {
|
||||
|
||||
在新工单中引用
屏蔽一个用户