Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(web): keep citation comment when popover is dismissed #10831

Mergedflamboh(GitHub profile, opens in a new tab)merged 8 commits intomain fromrefs/pull/10831/headmerged by shivamhwp(GitHub profile, opens in a new tab) View on GitHub

Showing 5 changed files with 156 additions and 0 deletions (loading 4).

x
0 of 5 viewed, 5 left
156 additions and 0 deletionsapps/web/src/components/chat/AssistantCitationChip.test.tsxAdded
View file
@@ -0,0 +1,156 @@
+import {
+ ASSISTANT_CITATION_MAX_COMMENT_LENGTH,
+ EnvironmentId,
+ MessageId,
+ ThreadId,
+} from "@t3tools/contracts";
+import { act, useState, type ReactNode } from "react";
+import { create, type ReactTestRenderer } from "react-test-renderer";
+import { afterEach, beforeEach, describe, expect, it, vi } from "vite-plus/test";
+​
+import type { AssistantCitationSourceAnchor } from "~/lib/assistantTextSelection";
+​
+const mocks = vi.hoisted(() => ({ observeSource: vi.fn(), dispose: vi.fn() }));
+vi.mock("./AssistantCitationSource", () => ({
+ observeAssistantCitationCommentSource: mocks.observeSource,
+}));
+vi.mock("@tanstack/react-router", () => ({
+ useNavigate: () => vi.fn(),
+ Link: ({ children }: { children: ReactNode }) => <a>{children}</a>,
+}));
+// Keep the real chip/editor lifecycle while replacing DOM positioning and floating layers.
+vi.mock("../ui/tooltip", () => ({
+ Tooltip: ({ children }: { children: ReactNode }) => <>{children}</>,
+ TooltipTrigger: ({ render }: { render: ReactNode }) => render,
+ TooltipPopup: ({ children }: { children: ReactNode }) => <>{children}</>,
+}));
+vi.mock("../ui/popover", () => ({
+ Popover: ({ children }: { children: ReactNode }) => <>{children}</>,
+ PopoverTrigger: ({ children }: { children: ReactNode }) => <button>{children}</button>,
+ PopoverPopup: ({ children }: { children: ReactNode }) => <>{children}</>,