55 CheckpointRef ,
66 EnvironmentId ,
77 MessageId ,
8+ ProjectId ,
89 RunId ,
910 ThreadId ,
1011} from "@t3tools/contracts" ;
@@ -275,7 +276,13 @@ describe("timeline tooltip scroll dismissal", () => {
275276 "hover then focus" ,
276277 "outside timeline" ,
277278 "wheel without scroll" ,
278- ] ) ( "handles %s through the real tooltip interactions" , async ( interaction ) => {
279+ "pr hover" ,
280+ "pr delayed hover" ,
281+ "pr focus" ,
282+ "pr hover then focus" ,
283+ ] ) ( "handles %s through the real tooltip interactions" , async ( scenario ) => {
284+ const isPullRequest = scenario . startsWith ( "pr " ) ;
285+ const interaction = isPullRequest ? scenario . slice ( 3 ) : scenario ;
279286 vi . unstubAllGlobals ( ) ;
280287 vi . stubGlobal ( "IS_REACT_ACT_ENVIRONMENT" , true ) ;
281288 vi . useFakeTimers ( ) ;
@@ -285,7 +292,33 @@ describe("timeline tooltip scroll dismissal", () => {
285292 document . body . append ( container ) ;
286293 const root = createRoot ( container ) ;
287294 const onMouseEnter = vi . fn ( ) ;
288- const tooltip = (
295+ const query = await import ( "~/state/query" ) ;
296+ const querySpy = isPullRequest
297+ ? vi . spyOn ( query , "useEnvironmentQuery" ) . mockReturnValue ( {
298+ data : null ,
299+ dataUpdatedAt : 0 ,
300+ error : "Pull request not found" ,
301+ failure : null ,
302+ isPending : false ,
303+ isSuccess : false ,
304+ refresh : vi . fn ( ) ,
305+ } )
306+ : null ;
307+ const { PullRequestLinkPreview } = await import ( "../pullRequest/PullRequestLinkPreview" ) ;
308+ const tooltip = isPullRequest ? (
309+ < PullRequestLinkPreview
310+ link = { < button onMouseEnter = { onMouseEnter } > message link</ button > }
311+ originalUrl = "https://example.com"
312+ target = { {
313+ environmentId : ACTIVE_THREAD_ENVIRONMENT_ID ,
314+ input : {
315+ projectId : ProjectId . make ( "project-1" ) ,
316+ repository : "pingdotgg/t3code" ,
317+ number : 1 ,
318+ } ,
319+ } }
320+ />
321+ ) : (
289322 < Tooltip >
290323 < TooltipTrigger delay = { 50 } onMouseEnter = { onMouseEnter } >
291324 message link
@@ -318,7 +351,9 @@ describe("timeline tooltip scroll dismissal", () => {
318351 document . dispatchEvent ( new KeyboardEvent ( "keydown" , { key : "Tab" } ) ) ;
319352 trigger . focus ( ) ;
320353 }
321- if ( interaction !== "delayed hover" ) await vi . advanceTimersByTimeAsync ( 60 ) ;
354+ if ( interaction !== "delayed hover" ) {
355+ await vi . advanceTimersByTimeAsync ( isPullRequest ? 400 : 60 ) ;
356+ }
322357 } ) ;
323358 expect ( onMouseEnter ) . toHaveBeenCalledTimes ( interaction === "focus" ? 0 : 1 ) ;
324359 expect (
@@ -331,7 +366,7 @@ describe("timeline tooltip scroll dismissal", () => {
331366 ? new WheelEvent ( "wheel" , { bubbles : true , deltaY : 100 } )
332367 : new Event ( "scroll" ) ,
333368 ) ;
334- await vi . advanceTimersByTimeAsync ( 100 ) ;
369+ await vi . advanceTimersByTimeAsync ( isPullRequest ? 1000 : 100 ) ;
335370 } ) ;
336371 expect (
337372 document . querySelector ( '[data-slot="tooltip-popup"][data-open]' ) ?. textContent ?? null ,
@@ -343,6 +378,7 @@ describe("timeline tooltip scroll dismissal", () => {
343378 }
344379 } finally {
345380 await act ( async ( ) => root . unmount ( ) ) ;
381+ querySpy ?. mockRestore ( ) ;
346382 container . remove ( ) ;
347383 vi . useRealTimers ( ) ;
348384 vi . unstubAllGlobals ( ) ;
0 commit comments