Skip to content

Commit

Permalink
Merge branch 'develop' into feature/iwtf-4249-rcp-job-fails-locally-n…
Browse files Browse the repository at this point in the history
…ode-modules
  • Loading branch information
Scott Dormand authored and Scott Dormand committed Nov 21, 2024
2 parents 715cbe3 + 93ee935 commit 5959829
Show file tree
Hide file tree
Showing 31 changed files with 342 additions and 83 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:
run: npm ci
- name: Extract branch name
shell: bash
run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
run: echo "branch=$(echo ${GITHUB_REF#refs/heads/})" >> $GITHUB_OUTPUT
id: extract_branch
- name: Run versioning script
run: . ./scripts/github/deploy.sh
Expand Down
39 changes: 39 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,43 @@

## v1.55.0-rc.3 (2024-11-21)

#### :rocket: Enhancement
* [#2078](https://github.com/DEFRA/rod-licensing/pull/2078) Set-output removed from versioning script ([@ScottDormand96](https://github.com/ScottDormand96))

#### Committers: 1
- Scott Dormand ([@ScottDormand96](https://github.com/ScottDormand96))

## v1.55.0-rc.2 (2024-11-19)

#### :rocket: Enhancement
* `gafl-webapp-service`
* [#2077](https://github.com/DEFRA/rod-licensing/pull/2077) Change links for three rod licence ([@ScottDormand96](https://github.com/ScottDormand96))

#### Committers: 1
- Scott Dormand ([@ScottDormand96](https://github.com/ScottDormand96))

## v1.55.0-rc.1 (2024-11-19)

#### :rocket: Enhancement
* `gafl-webapp-service`
* [#2079](https://github.com/DEFRA/rod-licensing/pull/2079) Licence summary licence type capitals ([@ScottDormand96](https://github.com/ScottDormand96))

#### Committers: 1
- Scott Dormand ([@ScottDormand96](https://github.com/ScottDormand96))

## v1.55.0-rc.0 (2024-11-13)

#### :rocket: Enhancement
* `dynamics-lib`
* [#2072](https://github.com/DEFRA/rod-licensing/pull/2072) Create activity in CRM ([@nabeelamir-defra](https://github.com/nabeelamir-defra))

#### Committers: 1
- Nabeel Amir ([@nabeelamir-defra](https://github.com/nabeelamir-defra))





## v1.51.0-rc.5 (2024-11-11)

#### :rocket: Enhancement
Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"packages": [
"packages/*"
],
"version": "1.51.0-rc.5",
"version": "1.55.0-rc.3",
"npmClient": "npm",
"publishConfig": {
"registry": "http://registry.npmjs.org/"
Expand Down
4 changes: 2 additions & 2 deletions packages/business-rules-lib/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/business-rules-lib/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@defra-fish/business-rules-lib",
"version": "1.51.0-rc.5",
"version": "1.55.0-rc.3",
"description": "Shared business rules for the rod licensing digital services",
"type": "module",
"engines": {
Expand Down
4 changes: 2 additions & 2 deletions packages/connectors-lib/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/connectors-lib/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@defra-fish/connectors-lib",
"version": "1.51.0-rc.5",
"version": "1.55.0-rc.3",
"description": "Shared connectors",
"type": "module",
"engines": {
Expand Down
4 changes: 2 additions & 2 deletions packages/dynamics-lib/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/dynamics-lib/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@defra-fish/dynamics-lib",
"version": "1.51.0-rc.5",
"version": "1.55.0-rc.3",
"description": "Framework to support integration with dynamics",
"type": "module",
"engines": {
Expand Down
1 change: 1 addition & 0 deletions packages/dynamics-lib/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export * from './queries/concession-proof.queries.js'
export * from './queries/pocl-validation-error.queries.js'
export * from './queries/recurring-payments.queries.js'
export * from './queries/contact.queries.js'
export * from './queries/activity.queries.js'

// Framework functionality
export * from './client/util.js'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import { createActivity } from '../activity.queries.js'
import { dynamicsClient } from '../../client/dynamics-client.js'

jest.mock('dynamics-web-api', () => {
return jest.fn().mockImplementation(() => {
return {
executeUnboundAction: jest.fn()
}
})
})

describe('Activity Service', () => {
describe('createActivity', () => {
const mockResponse = {
'@odata.context': 'https://dynamics.com/api/data/v9.1/defra_CreateRCRActivityResponse',
RCRActivityId: 'abc123',
ReturnStatus: 'success',
SuccessMessage: 'RCR Activity - created successfully',
ErrorMessage: null,
oDataContext: 'https://dynamics.com/api/data/v9.1/defra_CreateRCRActivityResponse'
}

const errorResponse = {
'@odata.context': 'https://dynamics.com/api/data/v9.1/.defra_CreateRCRActivityResponse',
RCRActivityId: null,
ReturnStatus: 'error',
SuccessMessage: '',
ErrorMessage: 'Failed to create activity',
oDataContext: 'https://dynamics.com/api/data/v9.1/$metadata#Microsoft.Dynamics.CRM.defra_CreateRCRActivityResponse'
}

it('should call dynamicsClient with correct parameters', async () => {
dynamicsClient.executeUnboundAction.mockResolvedValue(mockResponse)

await createActivity('contact-identifier-123', 2023)

expect(dynamicsClient.executeUnboundAction).toHaveBeenCalledWith('defra_CreateRCRActivity', {
ContactId: 'contact-identifier-123',
ActivityStatus: 'STARTED',
Season: 2023
})
})

it('should return the CRM response correctly', async () => {
dynamicsClient.executeUnboundAction.mockResolvedValue(mockResponse)

const result = await createActivity('contact-identifier-123', 2024)

expect(result).toEqual(mockResponse)
})

it('should handle error in dynamicsClient response', async () => {
const error = new Error('Failed to create activity')
dynamicsClient.executeUnboundAction.mockRejectedValue(error)

await expect(createActivity('contact-identifier-123', 2024)).rejects.toThrow('Failed to create activity')
})

it('should handle the case where activity creation fails', async () => {
dynamicsClient.executeUnboundAction.mockResolvedValue(errorResponse)

const result = await createActivity('invalid-contact-id', 2024)

expect(result).toMatchObject({
RCRActivityId: null,
ReturnStatus: 'error',
SuccessMessage: '',
ErrorMessage: 'Failed to create activity'
})
})
})
})
24 changes: 24 additions & 0 deletions packages/dynamics-lib/src/queries/activity.queries.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { dynamicsClient } from '../client/dynamics-client.js'

/**
* Creates an RCR Activity in Microsoft Dynamics CRM.
*
* @param {string} contactId - The ID of the contact associated with the activity.
* @param {number} season - The season year for which the activity is being created.
* @returns {Promise<Object>} - A promise that resolves to the response from Dynamics CRM.
* @property {string} [email protected] - The OData context URL of the response.
* @property {string} response.RCRActivityId - The unique identifier of the created RCR activity.
* @property {string} response.ReturnStatus - The status of the activity creation operation (e.g., 'success').
* @property {string} response.SuccessMessage - A message indicating successful creation of the activity.
* @property {string|null} response.ErrorMessage - An error message if the activity creation failed, otherwise null.
* @property {string} response.oDataContext - The OData context URL of the response.
*/
export const createActivity = (contactId, season) => {
const request = {
ContactId: contactId,
ActivityStatus: 'STARTED',
Season: season
}

return dynamicsClient.executeUnboundAction('defra_CreateRCRActivity', request)
}
8 changes: 4 additions & 4 deletions packages/fulfilment-job/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions packages/fulfilment-job/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@defra-fish/fulfilment-job",
"version": "1.51.0-rc.5",
"version": "1.55.0-rc.3",
"description": "Rod Licensing Sales Fulfilment Job",
"type": "module",
"engines": {
Expand Down Expand Up @@ -35,8 +35,8 @@
"test": "echo \"Error: run tests from root\" && exit 1"
},
"dependencies": {
"@defra-fish/connectors-lib": "1.51.0-rc.5",
"@defra-fish/dynamics-lib": "1.51.0-rc.5",
"@defra-fish/connectors-lib": "1.55.0-rc.3",
"@defra-fish/dynamics-lib": "1.55.0-rc.3",
"commander": "^7.2.0",
"debug": "^4.3.3",
"merge2": "^1.4.1",
Expand Down
8 changes: 4 additions & 4 deletions packages/gafl-webapp-service/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions packages/gafl-webapp-service/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@defra-fish/gafl-webapp-service",
"version": "1.51.0-rc.5",
"version": "1.55.0-rc.3",
"description": "The websales frontend for the GAFL service",
"type": "module",
"engines": {
Expand Down Expand Up @@ -36,8 +36,8 @@
"prepare": "gulp --gulpfile build/gulpfile.cjs"
},
"dependencies": {
"@defra-fish/business-rules-lib": "1.51.0-rc.5",
"@defra-fish/connectors-lib": "1.51.0-rc.5",
"@defra-fish/business-rules-lib": "1.55.0-rc.3",
"@defra-fish/connectors-lib": "1.55.0-rc.3",
"@defra/hapi-gapi": "^2.0.0",
"@hapi/boom": "^9.1.2",
"@hapi/catbox-redis": "^6.0.2",
Expand Down
6 changes: 3 additions & 3 deletions packages/gafl-webapp-service/src/locales/cy.json
Original file line number Diff line number Diff line change
Expand Up @@ -466,11 +466,11 @@
"licence_type_payment_edge_case": "Mae’n rhaid i chi gwblhau eich taliad cyn 11:30pm ar 31 Mawrth 2024 i dalu’r pris a ddangosir",
"licence_type_radio_salmon_hint": "Mae'n cynnwys brithyllod a physgod bras (hyd at 3 gwialen)",
"licence_type_radio_salmon": "Eogiaid a brithyllod y môr",
"licence_type_radio_salmon_payment_summary": "eogiaid a brithyllod y môr",
"licence_type_radio_salmon_payment_summary": "Eogiaid a brithyllod y môr",
"licence_type_radio_trout_three_rod": "Brithyllod a physgod bras (hyd at 3 gwialen)",
"licence_type_radio_trout_three_rod_payment_summary": "brithyllod a physgod bras (hyd at 3 gwialen)",
"licence_type_radio_trout_three_rod_payment_summary": "Brithyllod a physgod bras (hyd at 3 gwialen)",
"licence_type_radio_trout_two_rod": "Brithyllod a physgod bras (hyd at 2 wialen)",
"licence_type_radio_trout_two_rod_payment_summary": "brithyllod a physgod bras (hyd at 2 wialen)",
"licence_type_radio_trout_two_rod_payment_summary": "Brithyllod a physgod bras (hyd at 2 wialen)",
"licence_type_rules": "rheolau pysgota â gwialen (yn agor ar dudalen newydd)",
"licence_type_salmon_acr_note_1": "Yn ôl y gyfraith, mae'n rhaid i chi roi gwybod am ",
"licence_type_salmon_acr_note_2": " ffurflen daliadau (yn agor ar dudalen newydd)",
Expand Down
6 changes: 3 additions & 3 deletions packages/gafl-webapp-service/src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -466,11 +466,11 @@
"licence_type_payment_edge_case": "You must complete payment before 11:30pm on 31 March 2024 to get the price shown",
"licence_type_radio_salmon_hint": "Includes trout and coarse (up to 3 rods)",
"licence_type_radio_salmon": "Salmon and sea trout",
"licence_type_radio_salmon_payment_summary": "salmon and sea trout",
"licence_type_radio_salmon_payment_summary": "Salmon and sea trout",
"licence_type_radio_trout_three_rod": "Trout and coarse (up to 3 rods)",
"licence_type_radio_trout_three_rod_payment_summary": "trout and coarse (up to 3 rods)",
"licence_type_radio_trout_three_rod_payment_summary": "Trout and coarse (up to 3 rods)",
"licence_type_radio_trout_two_rod": "Trout and coarse (up to 2 rods)",
"licence_type_radio_trout_two_rod_payment_summary": "trout and coarse (up to 2 rods)",
"licence_type_radio_trout_two_rod_payment_summary": "Trout and coarse (up to 2 rods)",
"licence_type_rules": "rod fishing rules (opens in new tab)",
"licence_type_salmon_acr_note_1": "Licence holders must by law ",
"licence_type_salmon_acr_note_2": " report a catch return (opens in new tab)",
Expand Down
Loading

0 comments on commit 5959829

Please sign in to comment.