diff --git a/backend/src/__tests__/customerAccountsService.test.js b/backend/src/__tests__/customerAccountsService.test.js index 4a236c4d..4963e136 100644 --- a/backend/src/__tests__/customerAccountsService.test.js +++ b/backend/src/__tests__/customerAccountsService.test.js @@ -66,7 +66,11 @@ beforeEach(() => { describe('createInvitation', () => { it('rejects when a customer with the email already exists', async () => { const svc = require('../services/customerAccountsService'); - db.mockImplementationOnce(() => chain({ first: { id: 1, email: 'taken@example.com' } })); + // Service only rejects when the existing row has a password_hash — + // a passive (password_hash = null) row is the "promote to portal" + // path and is allowed through. Pin the rejection contract by mocking + // an active row. + db.mockImplementationOnce(() => chain({ first: { id: 1, email: 'taken@example.com', password_hash: 'hash' } })); await expect( svc.createInvitation({ email: 'taken@example.com', invitedById: 9 }) ).rejects.toThrow(/already exists/i); diff --git a/backend/src/__tests__/galleryOgService.shareImage.test.js b/backend/src/__tests__/galleryOgService.shareImage.test.js index c6c8b60e..8b2d04fa 100644 --- a/backend/src/__tests__/galleryOgService.shareImage.test.js +++ b/backend/src/__tests__/galleryOgService.shareImage.test.js @@ -29,6 +29,14 @@ jest.mock('../services/storage', () => ({ getStorage: jest.fn(), })); +// dateFormatter.formatDate queries `app_settings` for general_date_format, +// which would add a third unmocked db() call to every buildOgMetadata path. +// The format itself is irrelevant to the cover-vs-logo contract this file +// pins — short-circuit it to a stable string so the tests stay focused. +jest.mock('../utils/dateFormatter', () => ({ + formatDate: jest.fn().mockResolvedValue('12.06.2026'), +})); + const { db } = require('../database/db'); const { ensureThumbnail } = require('../services/imageProcessor'); const { getStorage } = require('../services/storage');