fix(FN-2159): hide manual PR controls for auto-merge tasks
- Add an autoMerge prop to PrSection and show an auto-merge hint instead of manual PR actions - Pass project autoMerge settings from TaskDetailModal into PrSection - Preserve active automation messaging when PR creation is already in progress - Expand PrSection tests to cover auto-merge enabled and disabled behavior - Increase core RunMutationContext log entry bounds test timeout to reduce flakiness
This commit is contained in:
@@ -8598,7 +8598,7 @@ describe("RunMutationContext", () => {
|
||||
await rm(localRoot, { recursive: true, force: true });
|
||||
await rm(localGlobal, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
}, 20_000);
|
||||
|
||||
it("addComment() with runContext includes runContext in log entry", async () => {
|
||||
const localRoot = makeTmpDir();
|
||||
|
||||
@@ -9,6 +9,7 @@ interface PrSectionProps {
|
||||
projectId?: string;
|
||||
prInfo?: PrInfo;
|
||||
automationStatus?: string | null;
|
||||
autoMerge?: boolean;
|
||||
hasGitHubToken: boolean;
|
||||
onPrCreated: (prInfo: PrInfo) => void;
|
||||
onPrUpdated: (prInfo: PrInfo) => void;
|
||||
@@ -26,6 +27,7 @@ export function PrSection({
|
||||
projectId,
|
||||
prInfo,
|
||||
automationStatus,
|
||||
autoMerge = false,
|
||||
hasGitHubToken,
|
||||
onPrCreated,
|
||||
onPrUpdated,
|
||||
@@ -91,6 +93,20 @@ export function PrSection({
|
||||
);
|
||||
}
|
||||
|
||||
if (autoMerge) {
|
||||
return (
|
||||
<div className="pr-section">
|
||||
<h4>
|
||||
<GitPullRequest size={16} className="pr-section-icon" />
|
||||
Pull Request
|
||||
</h4>
|
||||
<div className="pr-hint pr-hint--muted">
|
||||
Auto-merge will handle this task automatically.
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
if (showCreateForm) {
|
||||
return (
|
||||
<div className="pr-section">
|
||||
|
||||
@@ -1655,6 +1655,7 @@ export function TaskDetailModal({
|
||||
projectId={projectId}
|
||||
prInfo={task.prInfo}
|
||||
automationStatus={task.status ?? null}
|
||||
autoMerge={settings?.autoMerge ?? false}
|
||||
hasGitHubToken={githubTokenConfigured ?? false}
|
||||
onPrCreated={(prInfo) => {
|
||||
// Update task locally to show new PR
|
||||
|
||||
@@ -151,6 +151,76 @@ describe("PrSection", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("when autoMerge is enabled", () => {
|
||||
it("hides manual PR controls and shows auto-merge messaging when no PR exists", () => {
|
||||
render(
|
||||
<PrSection
|
||||
taskId="FN-001"
|
||||
autoMerge={true}
|
||||
hasGitHubToken={true}
|
||||
onPrCreated={mockOnPrCreated}
|
||||
onPrUpdated={mockOnPrUpdated}
|
||||
addToast={mockAddToast}
|
||||
/>
|
||||
);
|
||||
|
||||
expect(screen.queryByRole("button", { name: "Create PR" })).toBeNull();
|
||||
expect(screen.queryByText(/GITHUB_TOKEN env var/i)).toBeNull();
|
||||
expect(screen.getByText("Auto-merge will handle this task automatically.")).toBeDefined();
|
||||
});
|
||||
|
||||
it("does not show GitHub token hint when auto-merge is enabled and token is missing", () => {
|
||||
render(
|
||||
<PrSection
|
||||
taskId="FN-001"
|
||||
autoMerge={true}
|
||||
hasGitHubToken={false}
|
||||
onPrCreated={mockOnPrCreated}
|
||||
onPrUpdated={mockOnPrUpdated}
|
||||
addToast={mockAddToast}
|
||||
/>
|
||||
);
|
||||
|
||||
expect(screen.queryByText(/GITHUB_TOKEN env var/i)).toBeNull();
|
||||
expect(screen.getByText("Auto-merge will handle this task automatically.")).toBeDefined();
|
||||
});
|
||||
|
||||
it("still shows the creating-pr automation message when automation is active", () => {
|
||||
render(
|
||||
<PrSection
|
||||
taskId="FN-001"
|
||||
autoMerge={true}
|
||||
automationStatus="creating-pr"
|
||||
hasGitHubToken={false}
|
||||
onPrCreated={mockOnPrCreated}
|
||||
onPrUpdated={mockOnPrUpdated}
|
||||
addToast={mockAddToast}
|
||||
/>
|
||||
);
|
||||
|
||||
expect(screen.getByText(/creating a pull request automatically/i)).toBeDefined();
|
||||
expect(screen.queryByText("Auto-merge will handle this task automatically.")).toBeNull();
|
||||
expect(screen.queryByRole("button", { name: "Create PR" })).toBeNull();
|
||||
});
|
||||
|
||||
it("preserves manual PR creation behavior when auto-merge is disabled", () => {
|
||||
render(
|
||||
<PrSection
|
||||
taskId="FN-001"
|
||||
autoMerge={false}
|
||||
hasGitHubToken={false}
|
||||
onPrCreated={mockOnPrCreated}
|
||||
onPrUpdated={mockOnPrUpdated}
|
||||
addToast={mockAddToast}
|
||||
/>
|
||||
);
|
||||
|
||||
expect(screen.getByRole("button", { name: "Create PR" })).toBeDefined();
|
||||
expect(screen.getByText(/GITHUB_TOKEN env var/i)).toBeDefined();
|
||||
expect(screen.queryByText("Auto-merge will handle this task automatically.")).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe("when task has a PR", () => {
|
||||
it("displays PR info for open PR", () => {
|
||||
render(
|
||||
|
||||
Reference in New Issue
Block a user