feat: 收口模板升级与阶段七持续回归
This commit is contained in:
1 parent
ec16fff70e
commit
71c528de34
29 files changed
+1962
-304
No files matched your search
@@ -287,6 +287,9 @@ export class ApiClient
|
||||
this.resources.template.upgradeAdminTemplate(...arguments_);
|
||||
rollbackAdminTemplate = (...arguments_: Parameters<TemplateMethods["rollbackAdminTemplate"]>) =>
|
||||
this.resources.template.rollbackAdminTemplate(...arguments_);
|
||||
getAdminTemplateOperationFailures = (
|
||||
...arguments_: Parameters<TemplateMethods["getAdminTemplateOperationFailures"]>
|
||||
) => this.resources.template.getAdminTemplateOperationFailures(...arguments_);
|
||||
getPublicOffering = (...arguments_: Parameters<OfferingMethods["getPublicOffering"]>) =>
|
||||
this.resources.offering.getPublicOffering(...arguments_);
|
||||
listPublicOfferings = (...arguments_: Parameters<OfferingMethods["listPublicOfferings"]>) =>
|
||||
|
||||
@@ -138,10 +138,61 @@ export interface TemplateMethods {
|
||||
latestVersion: string;
|
||||
canUpgrade: boolean;
|
||||
canRollback: boolean;
|
||||
missingFields: unknown[];
|
||||
currentPackageVersionId: string | null;
|
||||
currentContentChecksum: string | null;
|
||||
targetPackageVersionId: string | null;
|
||||
targetContentChecksum: string | null;
|
||||
changes: {
|
||||
brandFields: { available: false; reason: string };
|
||||
templateBindings: { added: unknown[]; changed: unknown[]; removed: unknown[] };
|
||||
pages: { added: unknown[]; changed: unknown[]; removed: unknown[] };
|
||||
modules: {
|
||||
available: boolean;
|
||||
source: "platform_visual_manifest";
|
||||
packageUpgradeChangesRenderer: false;
|
||||
pages: Array<{ key: string; renderer: string | null; modules?: unknown[] }>;
|
||||
};
|
||||
assets: {
|
||||
slots: { added: unknown[]; changed: unknown[]; removed: unknown[] };
|
||||
files: {
|
||||
available: boolean;
|
||||
added?: unknown[];
|
||||
changed?: unknown[];
|
||||
removed?: unknown[];
|
||||
reason?: string;
|
||||
};
|
||||
};
|
||||
capabilities: { added: string[]; removed: string[] };
|
||||
renderer: {
|
||||
available: boolean;
|
||||
source: "platform_visual_manifest";
|
||||
packageUpgradeChangesRenderer: false;
|
||||
pages: Array<{ key: string; renderer: string | null }>;
|
||||
};
|
||||
package: {
|
||||
currentContentChecksum: string | null;
|
||||
targetContentChecksum: string | null;
|
||||
runtimeContract: { current: unknown; target: unknown };
|
||||
};
|
||||
};
|
||||
conflicts: Array<{ key: string; binding: string; reason: string }>;
|
||||
}>;
|
||||
upgradeAdminTemplate(input: {
|
||||
templatePackageVersionId: string;
|
||||
expectedContentChecksum: string;
|
||||
expectedCurrentVersion: string;
|
||||
expectedCurrentPackageVersionId: string | null;
|
||||
confirm: true;
|
||||
preservedBindings: Array<{ key: string; binding: string; action: "preserve" }>;
|
||||
}): Promise<unknown>;
|
||||
rollbackAdminTemplate(input: { expectedCurrentVersion: string; confirm: true }): Promise<unknown>;
|
||||
getAdminTemplateOperationFailures(params?: { days?: number }): Promise<{
|
||||
since: string;
|
||||
until: string;
|
||||
days: number;
|
||||
backfilled: false;
|
||||
failures: Array<{ action: string; count: number }>;
|
||||
}>;
|
||||
upgradeAdminTemplate(): Promise<unknown>;
|
||||
rollbackAdminTemplate(): Promise<unknown>;
|
||||
}
|
||||
|
||||
export interface TemplatePackageVersion {
|
||||
@@ -345,7 +396,13 @@ export function templateMethods({ request }: { request: RequestFn }): TemplateMe
|
||||
importAdminSampleContent: (body) =>
|
||||
request("/admin/workspace/sample-content/import", { method: "POST", body }),
|
||||
getAdminTemplateUpgradePreview: () => request("/admin/workspace/template/preview"),
|
||||
upgradeAdminTemplate: () => request("/admin/workspace/template/upgrade", { method: "POST" }),
|
||||
rollbackAdminTemplate: () => request("/admin/workspace/template/rollback", { method: "POST" }),
|
||||
upgradeAdminTemplate: (input) =>
|
||||
request("/admin/workspace/template/upgrade", { method: "POST", body: input }),
|
||||
rollbackAdminTemplate: (input) =>
|
||||
request("/admin/workspace/template/rollback", { method: "POST", body: input }),
|
||||
getAdminTemplateOperationFailures: (params = {}) =>
|
||||
request(
|
||||
`/admin/template-operations/failures${params.days === undefined ? "" : `?days=${encodeURIComponent(String(params.days))}`}`,
|
||||
),
|
||||
};
|
||||
}
|
||||
@@ -131,3 +131,67 @@ test("模板目录客户端发送分页并支持版本发布和审计", async ()
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
test("模板升级和回滚提交预览版本、checksum 与逐项保留确认", async () => {
|
||||
const calls: Array<{ url: string; method?: string; body?: string }> = [];
|
||||
const client = new ApiClient({
|
||||
baseUrl: "http://api.test",
|
||||
token: "brand-token",
|
||||
fetcher: async (url, init) => {
|
||||
calls.push({ url, method: init?.method, body: init?.body });
|
||||
return response({ installation: { templateVersion: "2.0.0" } });
|
||||
},
|
||||
});
|
||||
await client.upgradeAdminTemplate({
|
||||
templatePackageVersionId: "target-version",
|
||||
expectedContentChecksum: "target-checksum",
|
||||
expectedCurrentVersion: "1.0.0",
|
||||
expectedCurrentPackageVersionId: "source-version",
|
||||
confirm: true,
|
||||
preservedBindings: [{ key: "founder", binding: "brand.config.founder", action: "preserve" }],
|
||||
});
|
||||
await client.rollbackAdminTemplate({ expectedCurrentVersion: "2.0.0", confirm: true });
|
||||
assert.deepEqual(calls, [
|
||||
{
|
||||
url: "http://api.test/admin/workspace/template/upgrade",
|
||||
method: "POST",
|
||||
body: JSON.stringify({
|
||||
templatePackageVersionId: "target-version",
|
||||
expectedContentChecksum: "target-checksum",
|
||||
expectedCurrentVersion: "1.0.0",
|
||||
expectedCurrentPackageVersionId: "source-version",
|
||||
confirm: true,
|
||||
preservedBindings: [
|
||||
{ key: "founder", binding: "brand.config.founder", action: "preserve" },
|
||||
],
|
||||
}),
|
||||
},
|
||||
{
|
||||
url: "http://api.test/admin/workspace/template/rollback",
|
||||
method: "POST",
|
||||
body: JSON.stringify({ expectedCurrentVersion: "2.0.0", confirm: true }),
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
test("模板运营失败指标客户端发送查询窗口", async () => {
|
||||
const calls: Array<{ url: string; method?: string }> = [];
|
||||
const client = new ApiClient({
|
||||
baseUrl: "http://api.test",
|
||||
token: "template-admin-token",
|
||||
fetcher: async (url, init) => {
|
||||
calls.push({ url, method: init?.method });
|
||||
return response({
|
||||
since: "2026-10-01",
|
||||
until: "2026-10-17",
|
||||
days: 14,
|
||||
backfilled: false,
|
||||
failures: [],
|
||||
});
|
||||
},
|
||||
});
|
||||
await client.getAdminTemplateOperationFailures({ days: 14 });
|
||||
assert.deepEqual(calls, [
|
||||
{ url: "http://api.test/admin/template-operations/failures?days=14", method: "GET" },
|
||||
]);
|
||||
});
|
||||
Reference in new issue
Block a user