test: 补齐模板回滚授权与成功测试

This commit is contained in:
que01 committed 2026-09-20 22:55:47 +08:00
1 parent 4191ba8df5
commit 84a21b0012
3 files changed
+22 -2

No files matched your search

@@ -172,7 +172,7 @@ export function WorkspacePage() {
)}
{templatePreview.data?.canRollback && (
<Button danger onClick={() => rollback.mutate()} loading={rollback.isPending}>
回滚到上一版本
恢复上一版配置基线
</Button>
)}
<MutationError error={templatePreview.error} />
+1 -1
View File
@@ -517,7 +517,7 @@ export class AdminWorkspaceController {
});
return {
installation: updated,
note: "已回滚模板版本,现有模块、字段和业务内容未删除。",
note: "已恢复上一版模板配置基线,现有模块、字段和业务内容未删除。",
};
}
+20
View File
@@ -74,6 +74,26 @@ test("admin can install a template and public workspace exposes enabled configur
});
assert.equal(preview.statusCode, 200);
assert.equal(JSON.parse(preview.body).canUpgrade, false);
const rollbackUnauthorized = await request("/admin/workspace/template/rollback", {
method: "POST",
});
assert.equal(rollbackUnauthorized.statusCode, 401);
const installedRecord = JSON.parse(installed.body).installation;
await prisma.brandTemplateInstallation.update({
where: { id: installedRecord.id },
data: {
templateVersion: "2.0.0",
previousSnapshots: [installedRecord.configSnapshot],
},
});
const rollback = await request("/admin/workspace/template/rollback", {
method: "POST",
headers: { authorization: `Bearer ${token}` },
});
assert.equal(rollback.statusCode, 201);
assert.equal(JSON.parse(rollback.body).installation.templateVersion, "1.0.0");
assert.equal(JSON.parse(rollback.body).installation.previousSnapshots.length, 0);
assert.match(JSON.parse(rollback.body).note, /配置基线/);
const workspace = await request("/admin/workspace", {
headers: { authorization: `Bearer ${token}` },
});