mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-10-28 20:21:50 +01:00
test(ui): cover composer handoff preview spacing
This commit is contained in:
1 parent
8a1038be91
commit
9c6ae5513d
2 files changed
+38
-1
No files matched your search
@@ -0,0 +1,32 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { computeComposerHandoffPreview } from "../lib/interrupt-handoff";
|
||||
import { shouldRenderComposerHandoffPreview } from "./IssueChatThread";
|
||||
|
||||
describe("shouldRenderComposerHandoffPreview", () => {
|
||||
it("skips the spacer wrapper when the preview is empty", () => {
|
||||
const preview = computeComposerHandoffPreview({
|
||||
reassignTarget: "agent:agent-claude",
|
||||
currentAssigneeValue: "agent:agent-claude",
|
||||
hasActiveRun: true,
|
||||
bodyHasAgentMention: false,
|
||||
plainNameCandidate: null,
|
||||
});
|
||||
|
||||
expect(preview.kind).toBe("none");
|
||||
expect(shouldRenderComposerHandoffPreview("Wake Claude", preview)).toBe(false);
|
||||
});
|
||||
|
||||
it("renders the spacer wrapper only when body text and a visible preview are present", () => {
|
||||
const preview = computeComposerHandoffPreview({
|
||||
reassignTarget: "agent:agent-qa",
|
||||
currentAssigneeValue: "agent:agent-claude",
|
||||
hasActiveRun: true,
|
||||
bodyHasAgentMention: false,
|
||||
plainNameCandidate: null,
|
||||
});
|
||||
|
||||
expect(preview.kind).not.toBe("none");
|
||||
expect(shouldRenderComposerHandoffPreview("Wake QA", preview)).toBe(true);
|
||||
expect(shouldRenderComposerHandoffPreview(" ", preview)).toBe(false);
|
||||
});
|
||||
});
|
||||
@@ -120,6 +120,7 @@ import {
|
||||
computeComposerHandoffPreview,
|
||||
extractAgentMentionIds,
|
||||
findPlainAgentNameCandidate,
|
||||
type ComposerHandoffPreview,
|
||||
type HandoffAgentMention,
|
||||
} from "../lib/interrupt-handoff";
|
||||
import { restoreSubmittedCommentDraft } from "../lib/comment-submit-draft";
|
||||
@@ -316,6 +317,10 @@ interface CommentReassignment {
|
||||
assigneeUserId: string | null;
|
||||
}
|
||||
|
||||
export function shouldRenderComposerHandoffPreview(body: string, preview: ComposerHandoffPreview): boolean {
|
||||
return Boolean(body.trim()) && preview.kind !== "none";
|
||||
}
|
||||
|
||||
export interface IssueChatComposerHandle {
|
||||
focus: () => void;
|
||||
restoreDraft: (submittedBody: string) => void;
|
||||
@@ -3840,7 +3845,7 @@ const IssueChatComposer = forwardRef<IssueChatComposerHandle, IssueChatComposerP
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
{body.trim() && handoffPreview.kind !== "none" ? (
|
||||
{shouldRenderComposerHandoffPreview(body, handoffPreview) ? (
|
||||
<div className="my-2">
|
||||
<ComposerHandoffPreviewRow preview={handoffPreview} resolvers={handoffResolvers} />
|
||||
</div>
|
||||
|
||||
Reference in new issue
Block a user