@@ -424,6 +424,45 @@ describe("AssetAccess", () => {
424424 } ) . pipe ( Effect . provide ( layerTest ) ) ,
425425 ) ;
426426
427+ it . effect . skipIf ( ! symlinksSupported ) (
428+ "rejects a draft media path swapped after workspace containment validation" ,
429+ ( ) =>
430+ Effect . gen ( function * ( ) {
431+ const fs = yield * FileSystem . FileSystem ;
432+ const path = yield * Path . Path ;
433+ const directory = yield * fs . makeTempDirectoryScoped ( { prefix : "t3-draft-swap-" } ) ;
434+ const root = path . join ( directory , "workspace" ) ;
435+ yield * fs . makeDirectory ( root ) ;
436+ const filePath = path . join ( root , "video.mp4" ) ;
437+ const outside = path . join ( directory , "outside.mp4" ) ;
438+ yield * fs . writeFileString ( filePath , "workspace video" ) ;
439+ yield * fs . writeFileString ( outside , "outside video" ) ;
440+ const canonicalFile = yield * fs . realPath ( filePath ) ;
441+ let swapped = false ;
442+ const swappingFileSystem = FileSystem . FileSystem . of ( {
443+ ...fs ,
444+ stat : Effect . fn ( function * ( requestedPath ) {
445+ const info = yield * fs . stat ( requestedPath ) ;
446+ if ( requestedPath === canonicalFile && ! swapped ) {
447+ swapped = true ;
448+ yield * fs . remove ( filePath ) ;
449+ yield * fs . symlink ( outside , filePath ) ;
450+ }
451+ return info ;
452+ } ) ,
453+ } ) ;
454+ const result = yield * issueAssetUrl ( {
455+ resource : { _tag : "draft-workspace-file" , cwd : root , path : "video.mp4" } ,
456+ workspaceRoot : root ,
457+ } ) . pipe ( Effect . result , Effect . provideService ( FileSystem . FileSystem , swappingFileSystem ) ) ;
458+ expect ( swapped ) . toBe ( true ) ;
459+ expect ( result ) . toMatchObject ( {
460+ _tag : "Failure" ,
461+ failure : { _tag : "AssetWorkspaceAssetNotFoundError" } ,
462+ } ) ;
463+ } ) . pipe ( Effect . provide ( layerTest ) ) ,
464+ ) ;
465+
427466 it . effect ( "resolves home-relative media paths independently of the workspace" , ( ) =>
428467 Effect . gen ( function * ( ) {
429468 const fs = yield * FileSystem . FileSystem ;
0 commit comments