修复项目配置草稿原子保存逻辑
This commit is contained in:
@@ -50,15 +50,28 @@ describe("ProjectDetail setup draft publish workflow", () => {
|
||||
expect(source.indexOf("applySetupDraft(createDefaultSetupDraft(siteOptions.value));", functionIndex)).toBe(-1);
|
||||
});
|
||||
|
||||
it("does not let legacy empty projectInfo overwrite project master data", () => {
|
||||
it("applies setup drafts atomically including empty project info", () => {
|
||||
const source = readProjectDetail();
|
||||
const functionIndex = source.indexOf("const applySetupDraft = (draft: SetupConfigDraft) => {");
|
||||
const emptyGuardIndex = source.indexOf("!isProjectPublishSnapshotEmpty(projectInfo) || isSetupDraftEffectivelyEmpty(setupDraft)", functionIndex);
|
||||
const fallbackIndex = source.indexOf("setupDraft.projectInfo = buildProjectPublishSnapshot();", emptyGuardIndex);
|
||||
const nextFunctionIndex = source.indexOf("const loadLocalSetupDraft = ", functionIndex);
|
||||
const body = source.slice(functionIndex, nextFunctionIndex);
|
||||
|
||||
expect(functionIndex).toBeGreaterThan(-1);
|
||||
expect(emptyGuardIndex).toBeGreaterThan(functionIndex);
|
||||
expect(fallbackIndex).toBeGreaterThan(emptyGuardIndex);
|
||||
expect(body).toContain("setupDraft.projectInfo = projectInfo;");
|
||||
expect(body).toContain("applyProjectInfoDraft(projectInfo);");
|
||||
expect(body).not.toContain("shouldApplyProjectInfo");
|
||||
expect(body).not.toContain("isSetupDraftEffectivelyEmpty(setupDraft)");
|
||||
});
|
||||
|
||||
it("requires projectInfo in setup draft shape", () => {
|
||||
const source = readProjectDetail();
|
||||
const functionIndex = source.indexOf("const isSetupDraftShape = (value: unknown): value is SetupConfigDraft => {");
|
||||
const nextFunctionIndex = source.indexOf("const isProjectPublishSnapshotShape = ", functionIndex);
|
||||
const body = source.slice(functionIndex, nextFunctionIndex);
|
||||
|
||||
expect(functionIndex).toBeGreaterThan(-1);
|
||||
expect(body).toContain("isProjectPublishSnapshotShape(data.projectInfo)");
|
||||
expect(body).not.toContain("!Object.prototype.hasOwnProperty.call(data, \"projectInfo\")");
|
||||
});
|
||||
|
||||
it("keeps early termination out of regular visit schedule options", () => {
|
||||
|
||||
Reference in New Issue
Block a user