@@ -42,7 +42,9 @@ import {
4242 type PendingApproval ,
4343 deriveTimelineEntriesFromVisibleTurnItems ,
4444} from "../../session-logic" ;
45+ import { ViewedImagesTimelineRow } from "./TimelineWorkEntryRow" ;
4546import { remarkThoughtPreview } from "./TimelineWorkEntryRow.logic" ;
47+ import { TimelineRowCtx } from "./timelineRowContext" ;
4648import { parseMarkdownWithMath } from "@t3tools/shared/markdownMath" ;
4749import { collectThreadFindRanges } from "./threadFindHighlights" ;
4850import { toastManager } from "../ui/toast" ;
@@ -72,14 +74,14 @@ vi.mock(import("~/state/query"), async (original) => ({
7274 } ) ) as never ,
7375} ) ) ;
7476
75- const audioAsset = vi . hoisted ( ( ) => ( { url : "" } ) ) ;
77+ const stubbedAsset = vi . hoisted ( ( ) => ( { url : "" } ) ) ;
7678vi . mock ( import ( "~/assets/assetUrls" ) , async ( original ) => {
7779 const actual = await original ( ) ;
7880 return {
7981 ...actual ,
8082 useAssetUrlState : ( ( ...args : Parameters < typeof actual . useAssetUrlState > ) =>
81- audioAsset . url
82- ? { _tag : "Success" , url : audioAsset . url }
83+ stubbedAsset . url
84+ ? { _tag : "Success" , url : stubbedAsset . url }
8385 : actual . useAssetUrlState ( ...args ) ) as typeof actual . useAssetUrlState ,
8486 } ;
8587} ) ;
@@ -1240,9 +1242,9 @@ describe("MessagesTimeline attachments", () => {
12401242 ) ;
12411243 const src =
12421244 "data:audio/wav;base64,UklGRiUAAABXQVZFZm10IBAAAAABAAEAQB8AAEAfAAABAAgAZGF0YQEAAACA" ;
1243- audioAsset . url = src ;
1245+ stubbedAsset . url = src ;
12441246 onTestFinished ( ( ) => {
1245- audioAsset . url = "" ;
1247+ stubbedAsset . url = "" ;
12461248 } ) ;
12471249 const props = baseProps ( ) ;
12481250 await using screen = await renderTimeline (
@@ -1310,6 +1312,44 @@ describe("MessagesTimeline attachments", () => {
13101312 } ) ;
13111313 await vi . waitFor ( ( ) => expect ( one ! . isConnected ) . toBe ( false ) ) ;
13121314 } ) ;
1315+
1316+ it ( "opens a viewed image as a gallery of the images beside it" , async ( ) => {
1317+ stubbedAsset . url =
1318+ "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=" ;
1319+ onTestFinished ( ( ) => {
1320+ stubbedAsset . url = "" ;
1321+ } ) ;
1322+ const onImageExpand = vi . fn < ComponentProps < typeof MessagesTimeline > [ "onImageExpand" ] > ( ) ;
1323+ await using screen = await renderElement (
1324+ < TimelineRowCtx
1325+ value = {
1326+ {
1327+ threadRef : { environmentId : ENVIRONMENT_ID , threadId : ThreadId . make ( "thread-1" ) } ,
1328+ workspaceRoot : "/repo" ,
1329+ onImageExpand,
1330+ } as never
1331+ }
1332+ >
1333+ < ViewedImagesTimelineRow
1334+ row = { {
1335+ kind : "viewed-images" ,
1336+ id : "viewed" ,
1337+ createdAt : CREATED_AT ,
1338+ paths : [ "/repo/first.png" , "/repo/second.png" , "/repo/third.png" ] ,
1339+ } }
1340+ />
1341+ </ TimelineRowCtx > ,
1342+ ) ;
1343+ await screen . getByRole ( "button" , { name : "Preview second.png" } ) . click ( ) ;
1344+ expect ( onImageExpand ) . toHaveBeenCalledExactlyOnceWith (
1345+ expect . objectContaining ( {
1346+ index : 1 ,
1347+ images : [ "first.png" , "second.png" , "third.png" ] . map ( ( name ) =>
1348+ expect . objectContaining ( { name } ) ,
1349+ ) ,
1350+ } ) ,
1351+ ) ;
1352+ } ) ;
13131353} ) ;
13141354
13151355describe ( "MessagesTimeline thread find" , ( ) => {
0 commit comments