Add governed organization template upgrades
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
import process from "node:process";
|
||||
|
||||
const root = process.cwd();
|
||||
const panel = fs.readFileSync(
|
||||
path.join(root, "src/features/organizations/OrganizationTemplateUpgradePanel.tsx"),
|
||||
"utf8"
|
||||
);
|
||||
const api = fs.readFileSync(path.join(root, "src/api/organizations.ts"), "utf8");
|
||||
const moduleSource = fs.readFileSync(path.join(root, "src/module.ts"), "utf8");
|
||||
|
||||
const expectations = [
|
||||
[panel, "previewOrganizationModelUpgrade", "The panel must create a persisted preview."],
|
||||
[panel, "applyOrganizationModelUpgrade", "The panel must explicitly apply a reviewed preview."],
|
||||
[panel, "cancelOrganizationModelUpgrade", "The panel must support cancellation without mutation."],
|
||||
[panel, "<ConfirmDialog open={applyConfirmation}", "Apply must use a separate confirmation step."],
|
||||
[panel, "<DataGrid id={`organization-model-upgrade-diff-", "The comparison must use the shared DataGrid."],
|
||||
[panel, "<DismissibleAlert", "Errors and outcomes must use the shared alert component."],
|
||||
[api, '"/api/v1/organizations/model-upgrades/preview"', "The preview API must be declared."],
|
||||
[api, "/apply`", "The apply API must be declared."],
|
||||
[moduleSource, 'id: "organizations.admin.template-upgrades"', "Views must be able to target the upgrade surface."]
|
||||
];
|
||||
|
||||
for (const [source, marker, message] of expectations) {
|
||||
if (!source.includes(marker)) {
|
||||
throw new Error(message);
|
||||
}
|
||||
}
|
||||
|
||||
if (/useEffect\([^)]*applyOrganizationModelUpgrade/s.test(panel)) {
|
||||
throw new Error("An organization template upgrade must never apply from an effect.");
|
||||
}
|
||||
|
||||
console.log("Organization template upgrade interface contract passed.");
|
||||
Reference in New Issue
Block a user