Skip to content

Commit

Permalink
Fix 'draft' tests
Browse files Browse the repository at this point in the history
One of our failing tests highlighted we had been a bit to eager when deleting the status WHERE condition. Though we've not seen much evidence of its use, charge versions do have a status of 'draft'.

So, just in case we add that WHERE condition back in and update the tests appropriately.
  • Loading branch information
Cruikshanks committed Apr 20, 2023
1 parent 1d2d700 commit 4cb1ea5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ async function _fetch (regionId, billingPeriod) {
.where('regionId', regionId)
.where('chargeVersions.startDate', '>=', billingPeriod.startDate)
.where('chargeVersions.startDate', '<=', billingPeriod.endDate)
.whereNot('chargeVersions.status', 'draft')
.whereNotExists(
ChargeVersionWorkflow.query()
.select(1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,22 +164,18 @@ describe('Fetch Charge Versions service', () => {
})
})

describe("because all the applicable charge versions do not have a 'current' status", () => {
describe("because all the applicable charge versions have a 'draft' status", () => {
beforeEach(async () => {
billingPeriod = {
startDate: new Date('2022-04-01'),
endDate: new Date('2023-03-31')
}

const srocSupersededChargeVersion = await ChargeVersionHelper.add(
{ status: 'superseded' },
{ regionId, isWaterUndertaker: true, includeInSrocSupplementaryBilling: true }
)
const srocDraftChargeVersion = await ChargeVersionHelper.add(
{ status: 'draft' },
{ regionId, isWaterUndertaker: true, includeInSrocSupplementaryBilling: true }
)
testRecords = [srocSupersededChargeVersion, srocDraftChargeVersion]
testRecords = [srocDraftChargeVersion]
})

it('returns no applicable charge versions', async () => {
Expand Down

0 comments on commit 4cb1ea5

Please sign in to comment.