Skip to content

Commit

Permalink
feat(webhook-retries): add isRetryEnabled to model (2) (#1939)
Browse files Browse the repository at this point in the history
  • Loading branch information
mantariksh authored May 25, 2021
1 parent d9f2200 commit 663eb75
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 9 deletions.
1 change: 1 addition & 0 deletions src/app/models/__tests__/form.server.model.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ const FORM_DEFAULTS = {
permissionList: [],
webhook: {
url: '',
isRetryEnabled: false,
},
status: 'PRIVATE',
submissionLimit: null,
Expand Down
4 changes: 4 additions & 0 deletions src/app/models/form.server.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,10 @@ const compileFormModel = (db: Mongoose): IFormModel => {
'Webhook must be a valid URL over HTTPS and point to a public IP.',
},
},
isRetryEnabled: {
type: Boolean,
default: false,
},
},

msgSrvcName: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ObjectId } from 'bson-ext'
import { merge } from 'lodash'
import mongoose from 'mongoose'
import { errAsync } from 'neverthrow'
import supertest, { Session } from 'supertest-session'
Expand Down Expand Up @@ -85,11 +86,8 @@ describe('admin-form.settings.routes', () => {

// Assert
const expectedResponse = JSON.parse(
JSON.stringify({
...formToUpdate.getSettings(),
// Should get updated with new settings
...settingsToUpdate,
}),
// Should get updated with new settings
JSON.stringify(merge(formToUpdate.getSettings(), settingsToUpdate)),
)
expect(response.status).toEqual(200)
expect(response.body).toEqual(expectedResponse)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ const updateSettingsValidator = celebrate({
submissionLimit: Joi.number().allow(null),
title: Joi.string(),
webhook: Joi.object({
url: Joi.string().uri().required().allow(''),
}),
url: Joi.string().uri().allow(''),
isRetryEnabled: Joi.boolean(),
}).min(1),
}).min(1),
})

Expand Down
4 changes: 2 additions & 2 deletions src/types/api/form.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { LeanDocument } from 'mongoose'
import { ConditionalPick, Primitive } from 'type-fest'
import { ConditionalPick, PartialDeep, Primitive } from 'type-fest'

import { FormField, FormFieldSchema, FormFieldWithId } from '../field'
import { EndPage, FormSettings, Permission, StartPage } from '../form'

export type SettingsUpdateDto = Partial<FormSettings>
export type SettingsUpdateDto = PartialDeep<FormSettings>

export type FieldUpdateDto = FormFieldWithId

Expand Down
1 change: 1 addition & 0 deletions src/types/form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ export type Permission = {

export type Webhook = {
url: string
isRetryEnabled: boolean
}

/**
Expand Down

0 comments on commit 663eb75

Please sign in to comment.