generated from ministryofjustice/hmpps-template-typescript
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add tests for list base clients page * add view base client page * Fix errors in template * basic view for create new base client screen * post new base client with error loop * added controller tests * add tests for presenter * add test for expiry today * correct test comments and refactor time functions * display edit base clients details page * Add post update functionality * update test comments * update comments * display edit base clients deployment details page * add update deployment flow
- Loading branch information
1 parent
4965898
commit fb650aa
Showing
18 changed files
with
923 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
server/mappers/forms/mapEditBaseClientDeploymentForm.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import type { Request } from 'express' | ||
import { createMock } from '@golevelup/ts-jest' | ||
import { baseClientFactory } from '../../testutils/factories' | ||
import { mapEditBaseClientDeploymentForm } from '../index' | ||
|
||
const formRequest = (form: Record<string, unknown>) => { | ||
return createMock<Request>({ body: form }) | ||
} | ||
|
||
describe('mapEditBaseClientDeploymentForm', () => { | ||
describe('updates deployment details only', () => { | ||
it('updates details only', () => { | ||
// Given a base client with fields populated | ||
const detailedBaseClient = baseClientFactory.build({ | ||
accessTokenValidity: 3600, | ||
deployment: { | ||
team: 'deployment team', | ||
}, | ||
service: { | ||
serviceName: 'service serviceName', | ||
}, | ||
}) | ||
|
||
// and given an edit deployment request with all fields populated | ||
const request = formRequest({ | ||
team: 'team', | ||
teamContact: 'contact', | ||
teamSlack: 'slack', | ||
hosting: 'CLOUDPLATFORM', | ||
namespace: 'b', | ||
deployment: 'c', | ||
secretName: 'd', | ||
clientIdKey: 'e', | ||
secretKey: 'f', | ||
deploymentInfo: 'g', | ||
}) | ||
|
||
// when the form is mapped | ||
const update = mapEditBaseClientDeploymentForm(detailedBaseClient, request) | ||
|
||
// then the deployment details are updated | ||
expect(update.deployment.team).toEqual('team') | ||
expect(update.deployment.teamContact).toEqual('contact') | ||
expect(update.deployment.teamSlack).toEqual('slack') | ||
expect(update.deployment.hosting).toEqual('CLOUDPLATFORM') | ||
expect(update.deployment.namespace).toEqual('b') | ||
expect(update.deployment.deployment).toEqual('c') | ||
expect(update.deployment.secretName).toEqual('d') | ||
expect(update.deployment.clientIdKey).toEqual('e') | ||
expect(update.deployment.secretKey).toEqual('f') | ||
expect(update.deployment.deploymentInfo).toEqual('g') | ||
|
||
// but regular client details and service details are not updated | ||
expect(update.accessTokenValidity).toEqual(3600) | ||
expect(update.service.serviceName).toEqual(detailedBaseClient.service.serviceName) | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import type { Request } from 'express' | ||
import { BaseClient } from '../../interfaces/baseClientApi/baseClient' | ||
|
||
export default (baseClient: BaseClient, request: Request): BaseClient => { | ||
const data = request.body | ||
return { | ||
...baseClient, | ||
deployment: { | ||
team: data.team, | ||
teamContact: data.teamContact, | ||
teamSlack: data.teamSlack, | ||
hosting: data.hosting, | ||
namespace: data.namespace, | ||
deployment: data.deployment, | ||
secretName: data.secretName, | ||
clientIdKey: data.clientIdKey, | ||
secretKey: data.secretKey, | ||
deploymentInfo: data.deploymentInfo, | ||
}, | ||
} | ||
} |
Oops, something went wrong.