Refactor easy renewals to use new renewals data service#2310
Refactor easy renewals to use new renewals data service#2310
Conversation
https://eaflood.atlassian.net/browse/IWTF-4147 As part of IWTF-4017: GAFL: Dev – RP job provisions new permissions in DynamoDB Done we added a new service to the Sales API that prepares data for renewals. This service will further be enhanced by IWTF-3916: GAFL: Dev – Permissions created by RP job have correct concessions applied Done The new service duplicates a lot of the logic we use for easy renewals in the renewals-write-cache.js processor, so we should be able to replace quite a lot of that with a single call to the Sales API instead.
https://eaflood.atlassian.net/browse/IWTF-4147 As part of IWTF-4017: GAFL: Dev – RP job provisions new permissions in DynamoDB Done we added a new service to the Sales API that prepares data for renewals. This service will further be enhanced by IWTF-3916: GAFL: Dev – Permissions created by RP job have correct concessions applied Done The new service duplicates a lot of the logic we use for easy renewals in the renewals-write-cache.js processor, so we should be able to replace quite a lot of that with a single call to the Sales API instead.
| permit: permission.expanded.permit.entity.toJSON() | ||
| }) | ||
| return h.response(permissionData) | ||
| return h.response({ permission: permissionData }) |
There was a problem hiding this comment.
I'm not 100% certain about this - I can't see modifications for consumers of this endpoint to access the permission of the returned object. Have you checked that works?
irisfaraway
left a comment
There was a problem hiding this comment.
Some minor bits, just to add to Phil's comment.
| }) | ||
|
|
||
| const mockPreparePermissionDataForRenewal = auth => | ||
| salesApi.preparePermissionDataForRenewal.mockResolvedValue({ |
There was a problem hiding this comment.
Could this be a mockResolvedValueOnce?
There was a problem hiding this comment.
in this test file, i tried to use mockResolvedValueOnce, but got a few fails - i expect this is becuase preparePermissionDataForRenewal is called many times in the job and mockResolvedValueOnce only stubs the first call, so later calls are undefinied.
Do you think it is ok to keep it as mockResolvedValue in this instance?
packages/gafl-webapp-service/src/processors/__tests__/renewals-write-cache.spec.js
Outdated
Show resolved
Hide resolved
packages/gafl-webapp-service/src/processors/renewals-write-cache.js
Outdated
Show resolved
Hide resolved
|



https://eaflood.atlassian.net/browse/IWTF-4147
As part of IWTF-4017, we added a new service to the Sales API that prepares data for renewals. This service will further be enhanced by IWTF-3916
The new service duplicates a lot of the logic we use for easy renewals in the renewals-write-cache.js processor, so we should be able to replace quite a lot of that with a single call to the Sales API instead.