From 91fec1a100796ff09f771554b185ba8fb49aa01d Mon Sep 17 00:00:00 2001 From: Rebecca Ransome Date: Fri, 12 Jan 2024 09:38:50 +0000 Subject: [PATCH 1/6] Refactor Persist Allocated Licences To Results Service https://eaflood.atlassian.net/browse/WATER-4319 As part of the work we have been doing, we've been hacking away at a branch in a mob to build the two-part-tariff service. We have started refactoring this hacky branch and pulling out the various services into their own PR's. DEFRA/water-abstraction-team#105. Since then we have found a much cleaner, more performant way to right the overall service that we have now added into another separate hacky branch. This PR is updating the PersistAllocatedLicencesToResultsService that has already been pulled out and refactoring it to match our new hacky branch. From 92e8b2c4dd7d2b2e8d9b14e0db0ab49dd8eae263 Mon Sep 17 00:00:00 2001 From: Rebecca Ransome Date: Fri, 12 Jan 2024 09:55:30 +0000 Subject: [PATCH 2/6] Refactor PersistAllocatedLicenceToResultsService to only take 1 licence as param --- ...t-allocated-licence-to-results.service.js} | 48 +++++++++---------- 1 file changed, 23 insertions(+), 25 deletions(-) rename app/services/bill-runs/two-part-tariff/{persist-allocated-licences-to-results.service.js => persist-allocated-licence-to-results.service.js} (84%) diff --git a/app/services/bill-runs/two-part-tariff/persist-allocated-licences-to-results.service.js b/app/services/bill-runs/two-part-tariff/persist-allocated-licence-to-results.service.js similarity index 84% rename from app/services/bill-runs/two-part-tariff/persist-allocated-licences-to-results.service.js rename to app/services/bill-runs/two-part-tariff/persist-allocated-licence-to-results.service.js index d844381c3d..793f613928 100644 --- a/app/services/bill-runs/two-part-tariff/persist-allocated-licences-to-results.service.js +++ b/app/services/bill-runs/two-part-tariff/persist-allocated-licence-to-results.service.js @@ -1,8 +1,8 @@ 'use strict' /** - * Persists the results from the `allocateReturnsToLicenceService` into the DB - * @module PersistAllocatedLicencesToResultsService + * Persists the results from the `allocateReturnsToChargeElementService` into the DB + * @module PersistAllocatedLicenceToResultsService */ const ReviewChargeElementResultModel = require('../../../models/review-charge-element-result.model.js') @@ -21,31 +21,29 @@ const ReviewResultModel = require('../../../models/review-result.model.js') * matching and allocating looks correct or if any issues need resolving first. * * @param {String} billRunId - the ID of the two-part tariff bill run being generated - * @param {Object[]} licences - the two-part tariff licences included in the bill run, along with their match and + * @param {module:LicenceModel} licence - the two-part tariff licence included in the bill run, along with their match and * allocation results */ -async function go (billRunId, licences) { - for (const licence of licences) { - const { chargeVersions, returnLogs } = licence - - const reviewReturnResultIds = await _persistReturnLogs(returnLogs, billRunId, licence) - - for (const chargeVersion of chargeVersions) { - const { chargeReferences } = chargeVersion - - for (const chargeReference of chargeReferences) { - const { chargeElements } = chargeReference - - for (const chargeElement of chargeElements) { - await _persistChargeElement( - billRunId, - licence, - chargeVersion, - chargeReference, - chargeElement, - reviewReturnResultIds - ) - } +async function go (billRunId, licence) { + const { chargeVersions, returnLogs } = licence + + const reviewReturnResultIds = await _persistReturnLogs(returnLogs, billRunId, licence) + + for (const chargeVersion of chargeVersions) { + const { chargeReferences } = chargeVersion + + for (const chargeReference of chargeReferences) { + const { chargeElements } = chargeReference + + for (const chargeElement of chargeElements) { + await _persistChargeElement( + billRunId, + licence, + chargeVersion, + chargeReference, + chargeElement, + reviewReturnResultIds + ) } } } From e06dab65631fc4d47a85041da5915118aa8eae2b Mon Sep 17 00:00:00 2001 From: Rebecca Ransome Date: Mon, 15 Jan 2024 09:32:31 +0000 Subject: [PATCH 3/6] Change test file name --- ...ocated-licence-to-results.service.test.js} | 225 +++++++++--------- 1 file changed, 112 insertions(+), 113 deletions(-) rename test/services/bill-runs/two-part-tariff/{persist-allocated-licences-to-results.service.test.js => persist-allocated-licence-to-results.service.test.js} (54%) diff --git a/test/services/bill-runs/two-part-tariff/persist-allocated-licences-to-results.service.test.js b/test/services/bill-runs/two-part-tariff/persist-allocated-licence-to-results.service.test.js similarity index 54% rename from test/services/bill-runs/two-part-tariff/persist-allocated-licences-to-results.service.test.js rename to test/services/bill-runs/two-part-tariff/persist-allocated-licence-to-results.service.test.js index 8d647df1d1..921153e414 100644 --- a/test/services/bill-runs/two-part-tariff/persist-allocated-licences-to-results.service.test.js +++ b/test/services/bill-runs/two-part-tariff/persist-allocated-licence-to-results.service.test.js @@ -14,9 +14,9 @@ const { generateReturnLogId } = require('../../../support/helpers/return-log.hel const ReviewResultModel = require('../../../../app/models/review-result.model.js') // Thing under test -const PersistAllocatedLicencesToResultsService = require('../../../../app/services/bill-runs/two-part-tariff/persist-allocated-licences-to-results.service.js') +const PersistAllocatedLicenceToResultsService = require('../../../../app/services/bill-runs/two-part-tariff/persist-allocated-licence-to-results.service.js') -describe('Persist Allocated Licences to Results service', () => { +describe('Persist Allocated Licence to Results service', () => { const billRunId = generateUUID() beforeEach(async () => { @@ -24,56 +24,56 @@ describe('Persist Allocated Licences to Results service', () => { }) describe('when there are valid records to be persisted', () => { - let testLicences + let testLicence describe('with a charge element that has been matched to a return', () => { beforeEach(() => { - testLicences = _generateData() + testLicence = _generateData() }) it('persists the data into the results tables', async () => { - await PersistAllocatedLicencesToResultsService.go(billRunId, testLicences) + await PersistAllocatedLicenceToResultsService.go(billRunId, testLicence) const result = await ReviewResultModel.query() - .where('licenceId', testLicences[0].id) + .where('licenceId', testLicence.id) .withGraphFetched('reviewChargeElementResults') .withGraphFetched('reviewReturnResults') expect(result[0].billRunId).to.equal(billRunId) - expect(result[0].licenceId).to.equal(testLicences[0].id) - expect(result[0].chargeVersionId).to.equal(testLicences[0].chargeVersions[0].id) - expect(result[0].chargeReferenceId).to.equal(testLicences[0].chargeVersions[0].chargeReferences[0].id) - expect(result[0].chargePeriodStartDate).to.equal(testLicences[0].chargeVersions[0].chargePeriod.startDate) - expect(result[0].chargePeriodEndDate).to.equal(testLicences[0].chargeVersions[0].chargePeriod.endDate) - expect(result[0].chargeVersionChangeReason).to.equal(testLicences[0].chargeVersions[0].changeReason.description) + expect(result[0].licenceId).to.equal(testLicence.id) + expect(result[0].chargeVersionId).to.equal(testLicence.chargeVersions[0].id) + expect(result[0].chargeReferenceId).to.equal(testLicence.chargeVersions[0].chargeReferences[0].id) + expect(result[0].chargePeriodStartDate).to.equal(testLicence.chargeVersions[0].chargePeriod.startDate) + expect(result[0].chargePeriodEndDate).to.equal(testLicence.chargeVersions[0].chargePeriod.endDate) + expect(result[0].chargeVersionChangeReason).to.equal(testLicence.chargeVersions[0].changeReason.description) expect(result[0].reviewChargeElementResults.chargeElementId).to.equal( - testLicences[0].chargeVersions[0].chargeReferences[0].chargeElements[0].id + testLicence.chargeVersions[0].chargeReferences[0].chargeElements[0].id ) expect(result[0].reviewChargeElementResults.allocated).to.equal( - testLicences[0].chargeVersions[0].chargeReferences[0].chargeElements[0].allocatedQuantity + testLicence.chargeVersions[0].chargeReferences[0].chargeElements[0].allocatedQuantity ) // As the aggregate is null on the charge reference the service returns 1 expect(result[0].reviewChargeElementResults.aggregate).to.equal(1) expect(result[0].reviewChargeElementResults.chargeDatesOverlap).to.equal( - testLicences[0].chargeVersions[0].chargeReferences[0].chargeElements[0].chargeDatesOverlap + testLicence.chargeVersions[0].chargeReferences[0].chargeElements[0].chargeDatesOverlap ) - expect(result[0].reviewReturnResults.returnId).to.equal(testLicences[0].returnLogs[0].id) - expect(result[0].reviewReturnResults.returnReference).to.equal(testLicences[0].returnLogs[0].returnRequirement) - expect(result[0].reviewReturnResults.startDate).to.equal(testLicences[0].returnLogs[0].startDate) - expect(result[0].reviewReturnResults.endDate).to.equal(testLicences[0].returnLogs[0].endDate) - expect(result[0].reviewReturnResults.dueDate).to.equal(testLicences[0].returnLogs[0].dueDate) - expect(result[0].reviewReturnResults.receivedDate).to.equal(testLicences[0].returnLogs[0].receivedDate) - expect(result[0].reviewReturnResults.status).to.equal(testLicences[0].returnLogs[0].status) - expect(result[0].reviewReturnResults.underQuery).to.equal(testLicences[0].returnLogs[0].underQuery) - expect(result[0].reviewReturnResults.nilReturn).to.equal(testLicences[0].returnLogs[0].nilReturn) - expect(result[0].reviewReturnResults.description).to.equal(testLicences[0].returnLogs[0].description) - expect(result[0].reviewReturnResults.purposes).to.equal(testLicences[0].returnLogs[0].purposes) - expect(result[0].reviewReturnResults.quantity).to.equal(testLicences[0].returnLogs[0].quantity) - expect(result[0].reviewReturnResults.allocated).to.equal(testLicences[0].returnLogs[0].allocatedQuantity) + expect(result[0].reviewReturnResults.returnId).to.equal(testLicence.returnLogs[0].id) + expect(result[0].reviewReturnResults.returnReference).to.equal(testLicence.returnLogs[0].returnRequirement) + expect(result[0].reviewReturnResults.startDate).to.equal(testLicence.returnLogs[0].startDate) + expect(result[0].reviewReturnResults.endDate).to.equal(testLicence.returnLogs[0].endDate) + expect(result[0].reviewReturnResults.dueDate).to.equal(testLicence.returnLogs[0].dueDate) + expect(result[0].reviewReturnResults.receivedDate).to.equal(testLicence.returnLogs[0].receivedDate) + expect(result[0].reviewReturnResults.status).to.equal(testLicence.returnLogs[0].status) + expect(result[0].reviewReturnResults.underQuery).to.equal(testLicence.returnLogs[0].underQuery) + expect(result[0].reviewReturnResults.nilReturn).to.equal(testLicence.returnLogs[0].nilReturn) + expect(result[0].reviewReturnResults.description).to.equal(testLicence.returnLogs[0].description) + expect(result[0].reviewReturnResults.purposes).to.equal(testLicence.returnLogs[0].purposes) + expect(result[0].reviewReturnResults.quantity).to.equal(testLicence.returnLogs[0].quantity) + expect(result[0].reviewReturnResults.allocated).to.equal(testLicence.returnLogs[0].allocatedQuantity) expect(result[0].reviewReturnResults.abstractionOutsidePeriod).to.equal( - testLicences[0].returnLogs[0].abstractionOutsidePeriod + testLicence.returnLogs[0].abstractionOutsidePeriod ) }) }) @@ -83,19 +83,19 @@ describe('Persist Allocated Licences to Results service', () => { const aggregate = 0.5 const returnMatched = false - testLicences = _generateData(aggregate, returnMatched) + testLicence = _generateData(aggregate, returnMatched) }) - it('persists the data into the results tables', async () => { - await PersistAllocatedLicencesToResultsService.go(billRunId, testLicences) + it.only('persists the data into the results tables', async () => { + await PersistAllocatedLicenceToResultsService.go(billRunId, testLicence) const result = await ReviewResultModel.query() - .where('licenceId', testLicences[0].id) + .where('licenceId', testLicence.id) .withGraphFetched('reviewChargeElementResults') .withGraphFetched('reviewReturnResults') expect(result[0].billRunId).to.equal(billRunId) - expect(result[0].licenceId).to.equal(testLicences[0].id) + expect(result[0].licenceId).to.equal(testLicence.id) expect(result[0].chargeVersionId).to.be.null() expect(result[0].chargeReferenceId).to.be.null() expect(result[0].chargePeriodStartDate).to.be.null() @@ -105,43 +105,43 @@ describe('Persist Allocated Licences to Results service', () => { expect(result[0].reviewChargeElementResults).to.be.null() - expect(result[0].reviewReturnResults.returnId).to.equal(testLicences[0].returnLogs[0].id) - expect(result[0].reviewReturnResults.returnReference).to.equal(testLicences[0].returnLogs[0].returnRequirement) - expect(result[0].reviewReturnResults.startDate).to.equal(testLicences[0].returnLogs[0].startDate) - expect(result[0].reviewReturnResults.endDate).to.equal(testLicences[0].returnLogs[0].endDate) - expect(result[0].reviewReturnResults.dueDate).to.equal(testLicences[0].returnLogs[0].dueDate) - expect(result[0].reviewReturnResults.receivedDate).to.equal(testLicences[0].returnLogs[0].receivedDate) - expect(result[0].reviewReturnResults.status).to.equal(testLicences[0].returnLogs[0].status) - expect(result[0].reviewReturnResults.underQuery).to.equal(testLicences[0].returnLogs[0].underQuery) - expect(result[0].reviewReturnResults.nilReturn).to.equal(testLicences[0].returnLogs[0].nilReturn) - expect(result[0].reviewReturnResults.description).to.equal(testLicences[0].returnLogs[0].description) - expect(result[0].reviewReturnResults.purposes).to.equal(testLicences[0].returnLogs[0].purposes) - expect(result[0].reviewReturnResults.quantity).to.equal(testLicences[0].returnLogs[0].quantity) - expect(result[0].reviewReturnResults.allocated).to.equal(testLicences[0].returnLogs[0].allocatedQuantity) + expect(result[0].reviewReturnResults.returnId).to.equal(testLicence.returnLogs[0].id) + expect(result[0].reviewReturnResults.returnReference).to.equal(testLicence.returnLogs[0].returnRequirement) + expect(result[0].reviewReturnResults.startDate).to.equal(testLicence.returnLogs[0].startDate) + expect(result[0].reviewReturnResults.endDate).to.equal(testLicence.returnLogs[0].endDate) + expect(result[0].reviewReturnResults.dueDate).to.equal(testLicence.returnLogs[0].dueDate) + expect(result[0].reviewReturnResults.receivedDate).to.equal(testLicence.returnLogs[0].receivedDate) + expect(result[0].reviewReturnResults.status).to.equal(testLicence.returnLogs[0].status) + expect(result[0].reviewReturnResults.underQuery).to.equal(testLicence.returnLogs[0].underQuery) + expect(result[0].reviewReturnResults.nilReturn).to.equal(testLicence.returnLogs[0].nilReturn) + expect(result[0].reviewReturnResults.description).to.equal(testLicence.returnLogs[0].description) + expect(result[0].reviewReturnResults.purposes).to.equal(testLicence.returnLogs[0].purposes) + expect(result[0].reviewReturnResults.quantity).to.equal(testLicence.returnLogs[0].quantity) + expect(result[0].reviewReturnResults.allocated).to.equal(testLicence.returnLogs[0].allocatedQuantity) expect(result[0].reviewReturnResults.abstractionOutsidePeriod).to.equal( - testLicences[0].returnLogs[0].abstractionOutsidePeriod + testLicence.returnLogs[0].abstractionOutsidePeriod ) expect(result[1].billRunId).to.equal(billRunId) - expect(result[1].licenceId).to.equal(testLicences[0].id) - expect(result[1].chargeVersionId).to.equal(testLicences[0].chargeVersions[0].id) - expect(result[1].chargeReferenceId).to.equal(testLicences[0].chargeVersions[0].chargeReferences[0].id) - expect(result[1].chargePeriodStartDate).to.equal(testLicences[0].chargeVersions[0].chargePeriod.startDate) - expect(result[1].chargePeriodEndDate).to.equal(testLicences[0].chargeVersions[0].chargePeriod.endDate) - expect(result[1].chargeVersionChangeReason).to.equal(testLicences[0].chargeVersions[0].changeReason.description) + expect(result[1].licenceId).to.equal(testLicence.id) + expect(result[1].chargeVersionId).to.equal(testLicence.chargeVersions[0].id) + expect(result[1].chargeReferenceId).to.equal(testLicence.chargeVersions[0].chargeReferences[0].id) + expect(result[1].chargePeriodStartDate).to.equal(testLicence.chargeVersions[0].chargePeriod.startDate) + expect(result[1].chargePeriodEndDate).to.equal(testLicence.chargeVersions[0].chargePeriod.endDate) + expect(result[1].chargeVersionChangeReason).to.equal(testLicence.chargeVersions[0].changeReason.description) expect(result[1].reviewReturnResultId).to.be.null() expect(result[1].reviewChargeElementResults.chargeElementId).to.equal( - testLicences[0].chargeVersions[0].chargeReferences[0].chargeElements[0].id + testLicence.chargeVersions[0].chargeReferences[0].chargeElements[0].id ) expect(result[1].reviewChargeElementResults.allocated).to.equal( - testLicences[0].chargeVersions[0].chargeReferences[0].chargeElements[0].allocatedQuantity + testLicence.chargeVersions[0].chargeReferences[0].chargeElements[0].allocatedQuantity ) expect(result[1].reviewChargeElementResults.aggregate).to.equal( - testLicences[0].chargeVersions[0].chargeReferences[0].aggregate + testLicence.chargeVersions[0].chargeReferences[0].aggregate ) expect(result[1].reviewChargeElementResults.chargeDatesOverlap).to.equal( - testLicences[0].chargeVersions[0].chargeReferences[0].chargeElements[0].chargeDatesOverlap + testLicence.chargeVersions[0].chargeReferences[0].chargeElements[0].chargeDatesOverlap ) expect(result[1].reviewReturnResults).to.be.null() @@ -153,7 +153,7 @@ describe('Persist Allocated Licences to Results service', () => { const testLicences = [] it('does not throw an error', () => { - expect(async () => await PersistAllocatedLicencesToResultsService.go(billRunId, testLicences)).to.not.throw() + expect(async () => await PersistAllocatedLicenceToResultsService.go(billRunId, testLicences)).to.not.throw() }) }) }) @@ -169,63 +169,62 @@ function _generateData (aggregate = null, returnMatched = true) { ] // All data not required for the tests has been excluded from the generated data - const dataToPersist = [ - { - id: generateUUID(), - chargeVersions: [ - { - id: generateUUID(), - changeReason: { - description: 'Strategic review of charges (SRoC)' - }, - chargeReferences: [ - { - id: generateUUID(), - aggregate, - chargeElements: [ - { - id: generateUUID(), - returnLogs: returnMatched ? chargeElementReturnLogs : [], - allocatedQuantity: returnMatched ? 32 : 0, - chargeDatesOverlap: false - } - ] - } - ], - chargePeriod: { - startDate: new Date('2022-04-01'), - endDate: new Date('2023-03-31') + const dataToPersist = + { + id: generateUUID(), + chargeVersions: [ + { + id: generateUUID(), + changeReason: { + description: 'Strategic review of charges (SRoC)' + }, + chargeReferences: [ + { + id: generateUUID(), + aggregate, + chargeElements: [ + { + id: generateUUID(), + returnLogs: returnMatched ? chargeElementReturnLogs : [], + allocatedQuantity: returnMatched ? 32 : 0, + chargeDatesOverlap: false + } + ] } - } - ], - returnLogs: [ - { - id: returnId, - returnRequirement: '10021668', - description: 'DRAINS ETC-DEEPING FEN AND OTHER LINKED SITES', + ], + chargePeriod: { startDate: new Date('2022-04-01'), - endDate: new Date('2023-03-31'), - receivedDate: new Date('2023-03-01'), - dueDate: new Date('2023-04-28'), - status: 'completed', - underQuery: false, - purposes: [ - { - tertiary: { - code: '400', - description: 'Spray Irrigation - Direct' - } - } - ], - nilReturn: false, - quantity: 32, - allocatedQuantity: returnMatched ? 32 : 0, - abstractionOutsidePeriod: false, - matched: returnMatched + endDate: new Date('2023-03-31') } - ] - } - ] + } + ], + returnLogs: [ + { + id: returnId, + returnRequirement: '10021668', + description: 'DRAINS ETC-DEEPING FEN AND OTHER LINKED SITES', + startDate: new Date('2022-04-01'), + endDate: new Date('2023-03-31'), + receivedDate: new Date('2023-03-01'), + dueDate: new Date('2023-04-28'), + status: 'completed', + underQuery: false, + purposes: [ + { + tertiary: { + code: '400', + description: 'Spray Irrigation - Direct' + } + } + ], + nilReturn: false, + quantity: 32, + allocatedQuantity: returnMatched ? 32 : 0, + abstractionOutsidePeriod: false, + matched: returnMatched + } + ] + } return dataToPersist } From c6afb58a3f07b6a517449919234f454984327cfd Mon Sep 17 00:00:00 2001 From: Rebecca Ransome Date: Mon, 15 Jan 2024 09:34:50 +0000 Subject: [PATCH 4/6] remove .only --- .../persist-allocated-licence-to-results.service.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/services/bill-runs/two-part-tariff/persist-allocated-licence-to-results.service.test.js b/test/services/bill-runs/two-part-tariff/persist-allocated-licence-to-results.service.test.js index 921153e414..7aef0af818 100644 --- a/test/services/bill-runs/two-part-tariff/persist-allocated-licence-to-results.service.test.js +++ b/test/services/bill-runs/two-part-tariff/persist-allocated-licence-to-results.service.test.js @@ -86,7 +86,7 @@ describe('Persist Allocated Licence to Results service', () => { testLicence = _generateData(aggregate, returnMatched) }) - it.only('persists the data into the results tables', async () => { + it('persists the data into the results tables', async () => { await PersistAllocatedLicenceToResultsService.go(billRunId, testLicence) const result = await ReviewResultModel.query() From f6f974e3742504b855813b77976c52027e4a5da1 Mon Sep 17 00:00:00 2001 From: Jason Claxton Date: Mon, 15 Jan 2024 11:52:21 +0000 Subject: [PATCH 5/6] Remove unit test for empty licence array as it can never happen --- ...located-licence-to-results.service.test.js | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/test/services/bill-runs/two-part-tariff/persist-allocated-licence-to-results.service.test.js b/test/services/bill-runs/two-part-tariff/persist-allocated-licence-to-results.service.test.js index 7aef0af818..9dbea6062e 100644 --- a/test/services/bill-runs/two-part-tariff/persist-allocated-licence-to-results.service.test.js +++ b/test/services/bill-runs/two-part-tariff/persist-allocated-licence-to-results.service.test.js @@ -16,14 +16,14 @@ const ReviewResultModel = require('../../../../app/models/review-result.model.js // Thing under test const PersistAllocatedLicenceToResultsService = require('../../../../app/services/bill-runs/two-part-tariff/persist-allocated-licence-to-results.service.js') -describe('Persist Allocated Licence to Results service', () => { +describe.only('Persist Allocated Licence to Results service', () => { const billRunId = generateUUID() beforeEach(async () => { await DatabaseHelper.clean() }) - describe('when there are valid records to be persisted', () => { + describe('when there are records to be persisted', () => { let testLicence describe('with a charge element that has been matched to a return', () => { @@ -86,7 +86,7 @@ describe('Persist Allocated Licence to Results service', () => { testLicence = _generateData(aggregate, returnMatched) }) - it('persists the data into the results tables', async () => { + it('persists the return logs data into the results tables', async () => { await PersistAllocatedLicenceToResultsService.go(billRunId, testLicence) const result = await ReviewResultModel.query() @@ -121,6 +121,15 @@ describe('Persist Allocated Licence to Results service', () => { expect(result[0].reviewReturnResults.abstractionOutsidePeriod).to.equal( testLicence.returnLogs[0].abstractionOutsidePeriod ) + }) + + it('persists the charge element data into the results tables', async () => { + await PersistAllocatedLicenceToResultsService.go(billRunId, testLicence) + + const result = await ReviewResultModel.query() + .where('licenceId', testLicence.id) + .withGraphFetched('reviewChargeElementResults') + .withGraphFetched('reviewReturnResults') expect(result[1].billRunId).to.equal(billRunId) expect(result[1].licenceId).to.equal(testLicence.id) @@ -148,14 +157,6 @@ describe('Persist Allocated Licence to Results service', () => { }) }) }) - - describe('when there are NO records to persist', () => { - const testLicences = [] - - it('does not throw an error', () => { - expect(async () => await PersistAllocatedLicenceToResultsService.go(billRunId, testLicences)).to.not.throw() - }) - }) }) function _generateData (aggregate = null, returnMatched = true) { From b1e93d935443c4b700293c0f2107f302cf161df8 Mon Sep 17 00:00:00 2001 From: Jason Claxton Date: Mon, 15 Jan 2024 11:54:10 +0000 Subject: [PATCH 6/6] Remove .only DOH --- .../persist-allocated-licence-to-results.service.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/services/bill-runs/two-part-tariff/persist-allocated-licence-to-results.service.test.js b/test/services/bill-runs/two-part-tariff/persist-allocated-licence-to-results.service.test.js index 9dbea6062e..6e959a5e55 100644 --- a/test/services/bill-runs/two-part-tariff/persist-allocated-licence-to-results.service.test.js +++ b/test/services/bill-runs/two-part-tariff/persist-allocated-licence-to-results.service.test.js @@ -16,7 +16,7 @@ const ReviewResultModel = require('../../../../app/models/review-result.model.js // Thing under test const PersistAllocatedLicenceToResultsService = require('../../../../app/services/bill-runs/two-part-tariff/persist-allocated-licence-to-results.service.js') -describe.only('Persist Allocated Licence to Results service', () => { +describe('Persist Allocated Licence to Results service', () => { const billRunId = generateUUID() beforeEach(async () => {