| 1 | import { vi } from 'vitest'
|
| 2 |
|
| 3 | // Mock the barrel export used by controllers and most services. `getQueue`
|
| 4 | // returns a stable per-name mock so specs can assert on scheduled jobs via
|
| 5 | // `recordedJobs` from ./mocks/queue
|
| 6 | vi.mock('@app/lib/queue', async () => {
|
| 7 | const { getQueueMock } = await import('./mocks/queue')
|
| 8 |
|
| 9 | return {
|
| 10 | bootWorkers: vi.fn(),
|
| 11 | closeAllWorkers: vi.fn(),
|
| 12 | closeAllQueues: vi.fn(),
|
| 13 | scheduleInsights: vi.fn(),
|
| 14 | getQueue: (name: string) => getQueueMock(name),
|
| 15 | MailJobName: {
|
| 16 | WelcomeEmail: 'mail:welcome',
|
| 17 | PasswordReset: 'mail:password-reset',
|
| 18 | ActivateAccountEmail: 'mail:activate-account',
|
| 19 | },
|
| 20 | }
|
| 21 | })
|
| 22 |
|
| 23 | // syncMedicineReminderJobs imports getQueue directly from QueueRegistry
|
| 24 | vi.mock('@app/lib/queue/QueueRegistry', async () => {
|
| 25 | const { getQueueMock } = await import('./mocks/queue')
|
| 26 |
|
| 27 | return {
|
| 28 | getQueue: (name: string) => getQueueMock(name),
|
| 29 | closeAllQueues: vi.fn(),
|
| 30 | }
|
| 31 | })
|
| 32 |
|
| 33 | // avatar.ts constructs multer-s3 at import time and requires S3_BUCKET env var.
|
| 34 | // The replacement is a no-op middleware unless a spec stages a file through
|
| 35 | // setUploadedFile (see ./mocks/avatar)
|
| 36 | vi.mock('@app/services/avatar', async () => {
|
| 37 | const { avatarMulterMock } = await import('./mocks/avatar')
|
| 38 |
|
| 39 | return { default: avatarMulterMock }
|
| 40 | })
|
| 41 |
|
| 42 | // The avatar controller deletes the previous object through the S3 client
|
| 43 | vi.mock('@app/lib/s3', () => ({
|
| 44 | default: { send: vi.fn().mockResolvedValue({}) },
|
| 45 | }))
|