Initial curated projectbrain source from 8a7b1e0651dbdab97d744cbd2e653ab3970ac6c5
This commit is contained in:
commit
5aa3e8d685
700 files changed
+132801
No files matched your search
@@ -0,0 +1,20 @@
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import { assertDeliveryWriteAllowed, canRepairFeatureDelivery } from "../src/services/featureDeliveryFlow.js";
|
||||
import type { FeatureDeliveryDto } from "../src/repositories/featureDeliveryRepository.js";
|
||||
import type { GiteaClient } from "../src/integrations/gitea/client.js";
|
||||
|
||||
describe("repairing a delivery after PR validation fails", () => {
|
||||
const repository = { owner: "owner", repository: "repo", defaultBranch: "main" };
|
||||
const delivery = { approvalState: "approved", spec: { status: "pull_request_open", branch: "chatgpt/existing", pullRequest: { number: 12 } } } as FeatureDeliveryDto;
|
||||
it("allows repair on the existing open PR, while terminal deliveries stay immutable", async () => {
|
||||
const getPullRequest = vi.fn().mockResolvedValue({ state: "open", merged: false, head: { ref: "chatgpt/existing" }, base: { ref: "main" } });
|
||||
await expect(assertDeliveryWriteAllowed(delivery, "chatgpt/existing", { getPullRequest } as unknown as GiteaClient, repository)).resolves.toBeUndefined();
|
||||
expect(getPullRequest).toHaveBeenCalledWith("owner", "repo", 12);
|
||||
expect(canRepairFeatureDelivery("merged")).toBe(false);
|
||||
expect(canRepairFeatureDelivery("failed")).toBe(false);
|
||||
});
|
||||
it("refuses writes if Gitea merged the PR before ProjectBrain saw its webhook", async () => {
|
||||
const getPullRequest = vi.fn().mockResolvedValue({ state: "closed", merged: true });
|
||||
await expect(assertDeliveryWriteAllowed(delivery, "chatgpt/existing", { getPullRequest } as unknown as GiteaClient, repository)).rejects.toThrow("FEATURE_DELIVERY_PULL_REQUEST_NOT_WRITABLE");
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user