@@ -48,6 +48,7 @@ import * as storageCleanup from '@/lib/uploads/contexts/workspace/file-storage-c
4848import * as storage from '@/lib/uploads/core/storage-service'
4949import { storeCompiledDoc } from '@/lib/uploads/documents/compiled-store'
5050import * as heic from '@/lib/uploads/server/heic'
51+ import { observeWorkspaceFileDelivery } from '@/lib/workspace-files/application/file-delivery-observer'
5152import * as searchDelivery from '@/lib/workspace-files/search/delivery'
5253import * as searchRepository from '@/lib/workspace-files/search/repository'
5354
@@ -233,6 +234,41 @@ describe('Project delivery admission', () => {
233234 } )
234235 }
235236 }
237+ for ( const kind of [ 'inline' , 'csv' , 'artifact' ] as const ) {
238+ check ( `${ kind } awaits an asynchronous transport observer refusal` , async ( ) => {
239+ const f = await fixture ( )
240+ const created = await createProjectFile . execute ( {
241+ principal : f . principal ,
242+ input : {
243+ ...createInput ( f . projectId , 'name,value\nrow,secret' ) ,
244+ name : 'rows.csv' ,
245+ contentType : 'text/csv' ,
246+ } ,
247+ } )
248+ const error = new Error ( 'Transport observer refused delivery' )
249+ const input = { projectId : f . projectId , fileId : created . file . id , key : created . file . key }
250+ await expect (
251+ observeWorkspaceFileDelivery (
252+ async ( ) => {
253+ throw error
254+ } ,
255+ ( ) =>
256+ kind === 'inline'
257+ ? readProjectInlineFile . execute ( {
258+ principal : f . principal ,
259+ input : { projectId : f . projectId , referenceFileId : created . file . id } ,
260+ } )
261+ : kind === 'csv'
262+ ? readProjectFileCsvPreview . execute ( { principal : f . principal , input } )
263+ : readProjectFileArtifact . execute ( {
264+ principal : f . principal ,
265+ input : { ...input , maxBytes : 1024 } ,
266+ } )
267+ )
268+ ) . rejects . toBe ( error )
269+ } )
270+ }
271+
236272 check ( 'Project search withholds stale previews and removes moved-out results' , async ( ) => {
237273 const f = await fixture ( )
238274 const created = await createProjectFile . execute ( {
0 commit comments