diff --git a/src/app/modules/form/admin-form/__tests__/admin-form.service.spec.ts b/src/app/modules/form/admin-form/__tests__/admin-form.service.spec.ts index 2d78ff912f..2572faad4b 100644 --- a/src/app/modules/form/admin-form/__tests__/admin-form.service.spec.ts +++ b/src/app/modules/form/admin-form/__tests__/admin-form.service.spec.ts @@ -20,6 +20,7 @@ import { DatabaseError, DatabasePayloadSizeError, DatabaseValidationError, + MalformedParametersError, } from 'src/app/modules/core/core.errors' import { MissingUserError } from 'src/app/modules/user/user.errors' import * as UserService from 'src/app/modules/user/user.service' @@ -1419,6 +1420,47 @@ describe('admin-form.service', () => { ) expect(MOCK_UPDATED_FORM.getSettings).toHaveBeenCalledTimes(0) }) + + it('should not allow webhooks updates for MRF', async () => { + const MOCK_MULTIRESPONDENT_FORM = jest.mocked({ + _id: new ObjectId(), + status: FormStatus.Public, + responseMode: FormResponseMode.Multirespondent, + } as unknown as IPopulatedForm) + const settingsToUpdate: SettingsUpdateDto = { + webhook: { + url: 'does not matter', + }, + } + + // Act + const actualResult = await AdminFormService.updateFormSettings( + MOCK_MULTIRESPONDENT_FORM, + settingsToUpdate, + ) + + // Assert + expect(actualResult._unsafeUnwrapErr()).toBeInstanceOf( + MalformedParametersError, + ) + }) + + it('should allow webhooks updates for encrypt form', async () => { + const settingsToUpdate: SettingsUpdateDto = { + webhook: { + url: 'does not matter', + }, + } + + // Act + const actualResult = await AdminFormService.updateFormSettings( + MOCK_ENCRYPT_FORM, + settingsToUpdate, + ) + + // Assert + expect(actualResult.isOk()).toBeTrue() + }) }) describe('updateFormField', () => {