Skip to content

Commit eb5b34f

Browse files
committed
test(web): late-mounted citation source anchors the comment popup
Co-Authored-By: GPT-6.1 Terra via T3 Code
1 parent 4c9706c commit eb5b34f

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

‎apps/web/src/components/ComposerPromptEditorTiptap.citationDraft.browser.test.tsx‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,9 @@ it("reanchors the comment when the cited source mounts after activation", async
175175
const viewport = document.createElement("div");
176176
viewport.dataset.assistantCitationViewport = "";
177177
const source = document.createElement("p");
178+
source.style.position = "fixed";
179+
source.style.left = "500px";
180+
source.style.top = "300px";
178181
source.dataset.assistantCitationSource = citation.messageId;
179182
source.dataset.assistantCitationEnvironment = citation.environmentId;
180183
source.dataset.assistantCitationThread = citation.threadId;
@@ -187,6 +190,14 @@ it("reanchors the comment when the cited source mounts after activation", async
187190
const highlight = CSS.highlights.get("t3-assistant-citation-comment");
188191
expect(highlight?.size).toBe(1);
189192
expect(highlight && [...highlight][0]?.startContainer.parentElement).toBe(source);
193+
const popup = page.getByRole("dialog").element().getBoundingClientRect();
194+
const sourceRect = source.getBoundingClientRect();
195+
const chipRect = screen
196+
.getByRole("link", { name: "View cited assistant text: hello" })
197+
.element()
198+
.getBoundingClientRect();
199+
const distance = (rect: DOMRect) => Math.hypot(popup.left - rect.left, popup.top - rect.bottom);
200+
expect(distance(sourceRect)).toBeLessThan(distance(chipRect));
190201
});
191202
});
192203

0 commit comments

Comments
 (0)