Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 0 additions & 15 deletions src/modes/detector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,19 +96,4 @@ function validateTrackProgressEvent(context: GitHubContext): void {
);
}

// Additionally validate PR actions
if (context.eventName === "pull_request" && context.eventAction) {
const validActions = [
"opened",
"synchronize",
"ready_for_review",
"reopened",
];
if (!validActions.includes(context.eventAction)) {
throw new Error(
`track_progress for pull_request events is only supported for actions: ` +
`${validActions.join(", ")}. Current action: ${context.eventAction}`,
);
}
}
}
20 changes: 16 additions & 4 deletions test/modes/detector.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,21 @@ describe("detectMode with enhanced routing", () => {
expect(detectMode(context)).toBe("agent");
});

it("should throw error when track_progress is used with unsupported PR action", () => {
it("should use tag mode when track_progress is true for pull_request.labeled", () => {
const context: GitHubContext = {
...baseContext,
eventName: "pull_request",
eventAction: "labeled",
payload: { pull_request: { number: 1 } } as any,
entityNumber: 1,
isPR: true,
inputs: { ...baseContext.inputs, trackProgress: true },
};

expect(detectMode(context)).toBe("tag");
});

it("should use tag mode when track_progress is true for pull_request.closed", () => {
const context: GitHubContext = {
...baseContext,
eventName: "pull_request",
Expand All @@ -87,9 +101,7 @@ describe("detectMode with enhanced routing", () => {
inputs: { ...baseContext.inputs, trackProgress: true },
};

expect(() => detectMode(context)).toThrow(
/track_progress for pull_request events is only supported for actions/,
);
expect(detectMode(context)).toBe("tag");
});
});

Expand Down