mirror of
https://github.com/alkimake/paperclip.git
synced 2026-06-16 10:50:38 +09:00
Fix execution policy edits on in-review issues
This commit is contained in:
parent
26d4cabb2e
commit
27ec1e0c8b
3 changed files with 313 additions and 2 deletions
|
|
@ -778,6 +778,25 @@ describe("issue execution policy transitions", () => {
|
|||
|
||||
expect(result.patch).toEqual({});
|
||||
});
|
||||
|
||||
it("does not auto-start workflow when policy is added to an already in_review issue", () => {
|
||||
const reviewOnly = reviewOnlyPolicy();
|
||||
const result = applyIssueExecutionPolicyTransition({
|
||||
issue: {
|
||||
status: "in_review",
|
||||
assigneeAgentId: null,
|
||||
assigneeUserId: boardUserId,
|
||||
executionPolicy: null,
|
||||
executionState: null,
|
||||
},
|
||||
policy: reviewOnly,
|
||||
requestedStatus: undefined,
|
||||
requestedAssigneePatch: {},
|
||||
actor: { userId: boardUserId },
|
||||
});
|
||||
|
||||
expect(result.patch).toEqual({});
|
||||
});
|
||||
});
|
||||
|
||||
describe("multi-participant stages", () => {
|
||||
|
|
@ -974,4 +993,100 @@ describe("issue execution policy transitions", () => {
|
|||
expect(result.patch.assigneeUserId).toBe(boardUserId);
|
||||
});
|
||||
});
|
||||
|
||||
describe("policy edits while a stage is active", () => {
|
||||
it("clears the active execution state when its stage is removed from the policy", () => {
|
||||
const reviewAndApproval = twoStagePolicy();
|
||||
const approvalOnly = approvalOnlyPolicy();
|
||||
|
||||
const result = applyIssueExecutionPolicyTransition({
|
||||
issue: {
|
||||
status: "in_review",
|
||||
assigneeAgentId: qaAgentId,
|
||||
assigneeUserId: null,
|
||||
executionPolicy: reviewAndApproval,
|
||||
executionState: {
|
||||
status: "pending",
|
||||
currentStageId: reviewAndApproval.stages[0].id,
|
||||
currentStageIndex: 0,
|
||||
currentStageType: "review",
|
||||
currentParticipant: { type: "agent", agentId: qaAgentId },
|
||||
returnAssignee: { type: "agent", agentId: coderAgentId },
|
||||
completedStageIds: [],
|
||||
lastDecisionId: null,
|
||||
lastDecisionOutcome: null,
|
||||
},
|
||||
},
|
||||
policy: approvalOnly,
|
||||
requestedStatus: undefined,
|
||||
requestedAssigneePatch: {},
|
||||
actor: { userId: boardUserId },
|
||||
});
|
||||
|
||||
expect(result.patch).toMatchObject({
|
||||
status: "in_progress",
|
||||
assigneeAgentId: coderAgentId,
|
||||
assigneeUserId: null,
|
||||
executionState: null,
|
||||
});
|
||||
});
|
||||
|
||||
it("reassigns the active stage when the current participant is removed", () => {
|
||||
const policy = makePolicy([
|
||||
{
|
||||
type: "review",
|
||||
participants: [
|
||||
{ type: "agent", agentId: qaAgentId },
|
||||
{ type: "agent", agentId: ctoAgentId },
|
||||
],
|
||||
},
|
||||
]);
|
||||
const updatedPolicy = makePolicy([
|
||||
{
|
||||
type: "review",
|
||||
participants: [{ type: "agent", agentId: ctoAgentId }],
|
||||
},
|
||||
]);
|
||||
|
||||
const result = applyIssueExecutionPolicyTransition({
|
||||
issue: {
|
||||
status: "in_review",
|
||||
assigneeAgentId: qaAgentId,
|
||||
assigneeUserId: null,
|
||||
executionPolicy: policy,
|
||||
executionState: {
|
||||
status: "pending",
|
||||
currentStageId: policy.stages[0].id,
|
||||
currentStageIndex: 0,
|
||||
currentStageType: "review",
|
||||
currentParticipant: { type: "agent", agentId: qaAgentId },
|
||||
returnAssignee: { type: "agent", agentId: coderAgentId },
|
||||
completedStageIds: [],
|
||||
lastDecisionId: null,
|
||||
lastDecisionOutcome: null,
|
||||
},
|
||||
},
|
||||
policy: {
|
||||
...updatedPolicy,
|
||||
stages: [{ ...updatedPolicy.stages[0], id: policy.stages[0].id }],
|
||||
},
|
||||
requestedStatus: undefined,
|
||||
requestedAssigneePatch: {},
|
||||
actor: { userId: boardUserId },
|
||||
});
|
||||
|
||||
expect(result.patch).toMatchObject({
|
||||
status: "in_review",
|
||||
assigneeAgentId: ctoAgentId,
|
||||
assigneeUserId: null,
|
||||
executionState: {
|
||||
status: "pending",
|
||||
currentStageId: policy.stages[0].id,
|
||||
currentStageType: "review",
|
||||
currentParticipant: { type: "agent", agentId: ctoAgentId },
|
||||
returnAssignee: { type: "agent", agentId: coderAgentId },
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue