11import { expect } from 'chai' ;
22import { describe , it } from 'mocha' ;
3+ import proxyquire from 'proxyquire' ;
34
45import { AppContactsConverter } from '../../../../../app/apps/server/converters/contacts' ;
56import { AppDepartmentsConverter } from '../../../../../app/apps/server/converters/departments' ;
@@ -8,7 +9,6 @@ import { AppRolesConverter } from '../../../../../app/apps/server/converters/rol
89import { AppRoomsConverter } from '../../../../../app/apps/server/converters/rooms' ;
910import { AppSettingsConverter } from '../../../../../app/apps/server/converters/settings' ;
1011import { AppThreadsConverter } from '../../../../../app/apps/server/converters/threads' ;
11- import { AppUploadsConverter } from '../../../../../app/apps/server/converters/uploads' ;
1212import { AppUsersConverter } from '../../../../../app/apps/server/converters/users' ;
1313import { AppVideoConferencesConverter } from '../../../../../app/apps/server/converters/videoConferences' ;
1414import { AppVisitorsConverter } from '../../../../../app/apps/server/converters/visitors' ;
@@ -478,6 +478,14 @@ describe('apps converters — golden snapshots (pre-codec behaviour)', () => {
478478 } ) ;
479479
480480 describe ( 'AppUploadsConverter' , ( ) => {
481+ // The uploads codec derives `url` via the server-side `getURL`, which transitively imports
482+ // `server/settings` — a module with a top-level await that esbuild cannot emit as CJS. `@global`
483+ // reaches it through the codec; its key resolves from the converter's directory, hence one level
484+ // less than the codec's own import path.
485+ const { AppUploadsConverter } = proxyquire . noCallThru ( ) . load ( '../../../../../app/apps/server/converters/uploads' , {
486+ '../../../../server/lib/utils/getURL' : { 'getURL' : ( path : string ) => `http://siteurl.test${ path } ` , '@global' : true } ,
487+ } ) ;
488+
481489 const converter = new AppUploadsConverter ( stubOrch ) ;
482490
483491 it ( 'convertToApp maps an upload and resolves room/user/visitor via converters' , async ( ) => {
@@ -515,9 +523,9 @@ describe('apps converters — golden snapshots (pre-codec behaviour)', () => {
515523 extension : 'png' ,
516524 progress : 1 ,
517525 etag : 'etag-1' ,
518- path : '/path ' ,
526+ path : '/file-upload/up-1/file.png ' ,
519527 token : 'up-tok' ,
520- url : 'http://example /file.png' ,
528+ url : 'http://siteurl.test/file-upload/up-1 /file.png' ,
521529 updatedAt : '2024-02-02T00:00:00.000Z' ,
522530 uploadedAt : '2024-01-01T00:00:00.000Z' ,
523531 room : { __converted : 'rooms' , id : 'room-1' } ,
0 commit comments