Skip to content

Commit

Permalink
test: add test cases for mrf webhook blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
KenLSM committed Apr 5, 2024
1 parent efdb9a3 commit cad8d9c
Showing 1 changed file with 42 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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', () => {
Expand Down

0 comments on commit cad8d9c

Please sign in to comment.