diff --git a/backend/test/services/model.spec.ts b/backend/test/services/model.spec.ts index 496776d18..c003c5a79 100644 --- a/backend/test/services/model.spec.ts +++ b/backend/test/services/model.spec.ts @@ -120,6 +120,15 @@ describe('services > model', () => { expect(modelMocks.save).not.toBeCalled() }) + test('createModel > should throw an internal error if getUserInformation fails due to invalid user', async () => { + authenticationMocks.getUserInformation.mockImplementation(() => { + throw new Error('Unable to find user user:unknown_user') + }) + expect(() => + createModel({} as any, { collaborators: [{ entity: 'user:unknown_user', roles: [] }] } as any), + ).rejects.toThrowError(/^Unable to find user user:unknown_user/) + }) + test('getModelById > good', async () => { modelMocks.findOne.mockResolvedValueOnce('mocked') @@ -327,6 +336,15 @@ describe('services > model', () => { ).rejects.toThrowError(/^You cannot select both mirror settings simultaneously./) }) + test('updateModel > should throw an internal error if getUserInformation fails due to invalid user', async () => { + authenticationMocks.getUserInformation.mockImplementation(() => { + throw new Error('Unable to find user user:unknown_user') + }) + expect(() => + updateModel({} as any, '123', { collaborators: [{ entity: 'user:unknown_user', roles: [] }] }), + ).rejects.toThrowError(/^Unable to find user user:unknown_user/) + }) + test('createModelcardFromSchema > should throw an error when attempting to change a model from mirrored to standard', async () => { vi.mocked(authorisation.model).mockResolvedValue({ info: 'Cannot alter a mirrored model.',