Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
07968b9
tests
Namitha-Prabhu May 14, 2026
8c9b688
data
Namitha-Prabhu May 14, 2026
7870d9b
tests
Namitha-Prabhu May 18, 2026
8ad4de1
data
Namitha-Prabhu May 21, 2026
cb5b4b3
tests
Namitha-Prabhu May 21, 2026
3843953
lint
Namitha-Prabhu May 21, 2026
165ec60
fix
Namitha-Prabhu May 21, 2026
f88a927
lint fix
Namitha-Prabhu May 21, 2026
b722f67
config
Namitha-Prabhu May 21, 2026
1421d42
config changes
Namitha-Prabhu May 21, 2026
8f9f169
config changes
Namitha-Prabhu May 21, 2026
944fc50
config fix
Namitha-Prabhu May 22, 2026
9956565
tests
Namitha-Prabhu May 27, 2026
ae10b59
Merge branch 'main' into feature/CCM-13382-AddTests
Namitha-Prabhu May 27, 2026
da2f081
fix
Namitha-Prabhu May 27, 2026
bdd3433
lint fix
Namitha-Prabhu May 27, 2026
a756a7d
Update event-fixtures.ts
Namitha-Prabhu May 27, 2026
b9f6803
merge
Namitha-Prabhu May 28, 2026
1f2bc58
config fix
Namitha-Prabhu May 28, 2026
9974c40
config fix
Namitha-Prabhu May 28, 2026
a9b20f8
Update allocation-helper.ts
Namitha-Prabhu May 28, 2026
39047ae
Merge branch 'main' into feature/CCM-13382-AddTests
Namitha-Prabhu Jun 1, 2026
9136a6f
Merge branch 'feature/CCM-13382-AddTests' of https://github.com/NHSDi…
Namitha-Prabhu Jun 1, 2026
93b03a3
add test to config
Namitha-Prabhu Jun 1, 2026
bcb6aa9
Merge branch 'main' into feature/CCM-13382-AddTests
Namitha-Prabhu Jun 1, 2026
dad1690
add missing ref
Namitha-Prabhu Jun 1, 2026
eed9947
fix flaky tests
Namitha-Prabhu Jun 1, 2026
b65a46c
fix flaky tests
Namitha-Prabhu Jun 1, 2026
eeaeff0
remove duplicate tests
Namitha-Prabhu Jun 2, 2026
ccf6f45
fix comments
Namitha-Prabhu Jun 3, 2026
7e32f3b
Merge branch 'main' into feature/CCM-13382-AddTests
Namitha-Prabhu Jun 4, 2026
d290606
Merge branch 'main' into feature/CCM-13382-AddTests
Namitha-Prabhu Jun 4, 2026
d7356d2
Merge branch 'main' into feature/CCM-13382-AddTests
Namitha-Prabhu Jun 4, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions config/suppliers/letter-variant/client1-campaign2.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"client1-campaign2"
],
"priority": 1,
"status": "INT",
"status": "PROD",
"type": "STANDARD",
"volumeGroupId": "volumeGroup-test3"
"volumeGroupId": "volumeGroup-test4"
}
30 changes: 30 additions & 0 deletions config/suppliers/letter-variant/notify-first-test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"constraints": {
"blackCoveragePercentage": {
"operator": "LESS_THAN",
"value": 20
},
"deliveryDays": {
"operator": "LESS_THAN",
"value": 2
},
"sheets": {
"operator": "LESS_THAN",
"value": 5
},
"sides": {
"operator": "LESS_THAN",
"value": 10
}
},
"description": "Black printing, first class postage tariff",
"id": "notify-first-test",
"name": "First class letter",
"packSpecificationIds": [
"notify-first-test"
],
"priority": 10,
"status": "PROD",
"type": "STANDARD",
"volumeGroupId": "volumeGroup-test5"
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
"id": "notify-standard-test1",
"name": "Dev Happy Path",
"packSpecificationIds": [
"notify-c5"
"notify-c5",
"notify-c4"
],
"priority": 50,
"status": "PROD",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"maxWeightGrams": 100,
"size": "STANDARD"
},
"status": "INT",
"status": "PROD",
"updatedAt": "2026-04-14T00:00:00.000Z",
"version": 1
}
48 changes: 48 additions & 0 deletions config/suppliers/pack-specification/notify-first-test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"assembly": {
"duplex": true,
"envelopeId": "first-c5",
"paper": {
"colour": "WHITE",
"id": "paper-std-white-80",
"name": "Standard White 80gsm",
"recycled": true,
"size": "A4",
"weightGSM": 80
},
"printColour": "BLACK"
},
"billingId": "notify-first-test",
"constraints": {
"blackCoveragePercentage": {
"operator": "LESS_THAN",
"value": 20
},
"deliveryDays": {
"operator": "LESS_THAN",
"value": 2
},
"sheets": {
"operator": "LESS_THAN",
"value": 5
},
"sides": {
"operator": "LESS_THAN",
"value": 10
}
},
"createdAt": "2026-01-12T00:00:00.000Z",
"description": "First class postage tariff",
"id": "notify-first-test",
"name": "First class",
"postage": {
"deliveryDays": 2,
"id": "first-class",
"maxThicknessMm": 5,
"maxWeightGrams": 100,
"size": "STANDARD"
},
"status": "PROD",
"updatedAt": "2026-01-12T00:00:00.000Z",
"version": 1
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"allocationPercentage": 100,
"allocationPercentage": 50,
"id": "supplier1-volumeGroup-test3",
"status": "PROD",
"supplier": "supplier1",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"allocationPercentage": 50,
"id": "supplier2-volumeGroup-test3",
"status": "PROD",
"supplier": "supplier2",
"volumeGroup": "volumeGroup-test3"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"allocationPercentage": 50,
"id": "supplier3-volumeGroup-test4",
"status": "PROD",
"supplier": "supplier3",
"volumeGroup": "volumeGroup-test4"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"allocationPercentage": 50,
"id": "supplier4-volumeGroup-test4",
"status": "PROD",
"supplier": "supplier4",
"volumeGroup": "volumeGroup-test4"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"allocationPercentage": 100,
"id": "supplier5-volumeGroup-test5",
"status": "PROD",
"supplier": "supplier5",
"volumeGroup": "volumeGroup-test5"
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
"id": "supplier1-client1-campaign8",
"packSpecificationId": "client1-campaign8",
"status": "PROD",
"supplierId": "supplier1"
"supplierId": ""
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"approval": "APPROVED",
"id": "supplier2-client1-campaign1",
"packSpecificationId": "client1-campaign1",
"status": "PROD",
"supplierId": "supplier2"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"approval": "APPROVED",
"id": "supplier3-client1-campaign2",
"packSpecificationId": "client1-campaign2",
"status": "PROD",
"supplierId": "supplier3"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"approval": "APPROVED",
"id": "supplier4-client1-campaign2",
"packSpecificationId": "client1-campaign2",
"status": "PROD",
"supplierId": "supplier4"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"approval": "APPROVED",
"id": "supplier5-notify-first-test",
"packSpecificationId": "notify-first-test",
"status": "PROD",
"supplierId": "supplier5"
}
7 changes: 7 additions & 0 deletions config/suppliers/supplier/supplier3.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"channelType": "LETTER",
"dailyCapacity": 500000,
"id": "supplier3",
"name": "Supplier3",
"status": "PROD"
}
7 changes: 7 additions & 0 deletions config/suppliers/supplier/supplier4.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"channelType": "LETTER",
"dailyCapacity": 500000,
"id": "supplier4",
"name": "Supplier4",
"status": "PROD"
}
7 changes: 7 additions & 0 deletions config/suppliers/supplier/supplier5.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"channelType": "LETTER",
"dailyCapacity": 500000,
"id": "supplier5",
"name": "Supplier5",
"status": "PROD"
}
7 changes: 7 additions & 0 deletions config/suppliers/volume-group/volumeGroup-test4.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"description": "Dev Test Volume Group 4",
"id": "volumeGroup-test4",
"name": "Dev Test Volume Group 4",
"startDate": "2026-01-01",
"status": "PROD"
}
7 changes: 7 additions & 0 deletions config/suppliers/volume-group/volumeGroup-test5.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"description": "Dev Test Volume Group 5",
"id": "volumeGroup-test5",
"name": "Dev Test Volume Group 5",
"startDate": "2026-01-01",
"status": "PROD"
}
1 change: 0 additions & 1 deletion internal/datastore/src/supplier-config-repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ export class SupplierConfigRepository {
},
}),
);

return $SupplierPack.array().parse(result.Items);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
import { randomUUID } from "node:crypto";
import test, { expect } from "playwright/test";
import {
getAllocationLogForDomainId,
getLetterVariantConfigFromDb,
getSupplierFromSupplierPack,
getVariantsForAllocation,
updateSupplierAllocation,
} from "tests/helpers/allocation-helper";
import { createPreparedV1Event } from "tests/helpers/event-fixtures";
import { getLettersFromSupplierTable } from "tests/helpers/generate-fetch-test-data";
import { sendSnsEvent } from "tests/helpers/send-sns-event";

test.describe("Allocation Target Percentage Tests", () => {
test.setTimeout(180_000); // 3 minutes for long running polling
test("Verify that supplier with zero target percentage is handled correctly", async () => {
const letterVariant = getVariantsForAllocation(8);
const domainId = `Zero-Percentage-${randomUUID()}`;

const letterVariantConfig =
await getLetterVariantConfigFromDb(letterVariant);
const volGroupId = letterVariantConfig.volumeGroupId;

// update target percentage
await updateSupplierAllocation("supplier1", volGroupId, 0);
const preparedEvent = createPreparedV1Event({
domainId,
letterVariantId: letterVariant,
});

const response = await sendSnsEvent(preparedEvent);
expect(response.MessageId).toBeTruthy();

const allocationLog = await getAllocationLogForDomainId(domainId);
const lettersInDb = await getLettersFromSupplierTable(
"unknown",
domainId,
"REJECTED",
);

expect(lettersInDb.status).toBe("REJECTED");
expect(lettersInDb.supplierId).toBe(
allocationLog.msg?.allocationDetails?.supplierSpec?.supplierId,
);
expect(lettersInDb.reasonCode).toBe("NO_SUPPLIERS_AVAILABLE");
expect(lettersInDb.reasonText).toBe(
`No valid supplier allocations found for suppliers with valid pack`,
);
});

test("Verify that supplier with less than 100 target percentage is handled correctly", async () => {
const letterVariant = getVariantsForAllocation(5);
const domainId = `Less-Than-100-Percentage-${randomUUID()}`;

const letterVariantConfig =
await getLetterVariantConfigFromDb(letterVariant);
const volGroupId = letterVariantConfig.volumeGroupId;
const [packSpecificationId] = letterVariantConfig.packSpecificationIds;

// update target percentage
const [supplier] = await getSupplierFromSupplierPack(packSpecificationId);

await updateSupplierAllocation(supplier, volGroupId, 50);
const preparedEvent = createPreparedV1Event({
domainId,
letterVariantId: letterVariant,
});

const response = await sendSnsEvent(preparedEvent);
expect(response.MessageId).toBeTruthy();

const allocationLog = await getAllocationLogForDomainId(domainId);
const lettersInDb = await getLettersFromSupplierTable(
allocationLog.msg?.allocationDetails?.supplierSpec?.supplierId!,
domainId,
"PENDING",
);

expect(lettersInDb.supplierId).toBe(
allocationLog.msg?.allocationDetails?.supplierSpec?.supplierId,
);
await updateSupplierAllocation(supplier, volGroupId, 100); // reset target percentage to avoid impact on other tests
});
});
Loading
Loading