Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
// @vitest-environment node
import { describe, expect, test } from "vitest";
import type { Project } from "@/types/proto-es/v1/project_service_pb";
import { getApprovalEligibility } from "./approvalEligibility";
const project = (
allowSelfApproval: boolean,
allowLastPlanEditorApproval: boolean
) =>
({
allowLastPlanEditorApproval,
allowSelfApproval,
}) as Pick<Project, "allowLastPlanEditorApproval" | "allowSelfApproval">;
describe("getApprovalEligibility", () => {
test("keeps the last plan editor in the role while denying approval", () => {
expect(
getApprovalEligibility({
actor: "users/[email protected]",
issueCreator: "users/[email protected]",
lastPlanEditor: "users/[email protected]",
project: project(false, false),
})
).toEqual({
canApprove: false,
canReview: true,
ineligibilities: ["last-plan-editor"],
});
});
test("combines self-approval and last-editor restrictions", () => {
expect(
getApprovalEligibility({
actor: "users/[email protected]",
issueCreator: "users/[email protected]",
lastPlanEditor: "users/[email protected]",
project: project(false, false),
})
).toEqual({
canApprove: false,
canReview: false,
ineligibilities: ["self-approval", "last-plan-editor"],
});
});
test("allows the last editor when the project policy opts in", () => {
expect(
getApprovalEligibility({
actor: "users/[email protected]",
issueCreator: "users/[email protected]",
lastPlanEditor: "users/[email protected]",
project: project(false, true),
})
).toEqual({
canApprove: true,
canReview: true,
ineligibilities: [],
});
});
});