Skip to content

Commit 91909a7

Browse files
committed
chore: fix apps converters golden spec breaking unit tests
1 parent 416bb8a commit 91909a7

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

apps/meteor/tests/unit/app/apps/server/converters.golden.spec.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { expect } from 'chai';
22
import { describe, it } from 'mocha';
3+
import proxyquire from 'proxyquire';
34

45
import { AppContactsConverter } from '../../../../../app/apps/server/converters/contacts';
56
import { AppDepartmentsConverter } from '../../../../../app/apps/server/converters/departments';
@@ -8,7 +9,6 @@ import { AppRolesConverter } from '../../../../../app/apps/server/converters/rol
89
import { AppRoomsConverter } from '../../../../../app/apps/server/converters/rooms';
910
import { AppSettingsConverter } from '../../../../../app/apps/server/converters/settings';
1011
import { AppThreadsConverter } from '../../../../../app/apps/server/converters/threads';
11-
import { AppUploadsConverter } from '../../../../../app/apps/server/converters/uploads';
1212
import { AppUsersConverter } from '../../../../../app/apps/server/converters/users';
1313
import { AppVideoConferencesConverter } from '../../../../../app/apps/server/converters/videoConferences';
1414
import { 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

Comments
 (0)