Skip to content

Commit 7c7ed9a

Browse files
simonlabareremasl2
andauthored
CCM-17208: Digital Letter - Supplier API Pact tests (#557)
* CCM-17208: Digital Letter - Supplier API Pact tests * CCM-17208: Digital Letter - Supplier API Pact tests * CCM-17208: Fix linting issues * CCM-17208: Fix spelling mistake * CCM-17208: Use contract published by Digital Letters --------- Co-authored-by: Mark Slowey <113013138+masl2@users.noreply.github.com>
1 parent 2c87e04 commit 7c7ed9a

4 files changed

Lines changed: 55 additions & 2 deletions

File tree

package-lock.json

Lines changed: 8 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
"@aws-sdk/client-lambda": "^3.986.0",
88
"@aws-sdk/client-sns": "^3.984.0",
99
"@aws-sdk/lib-dynamodb": "^3.1008.0",
10-
"@nhsdigital/nhs-notify-event-schemas-letter-rendering": "2.0.1",
10+
"@nhsdigital/nhs-notify-event-schemas-letter-rendering": "^2.0.1",
11+
"@nhsdigital/notify-digital-letters-consumer-contracts": "^1.0.1",
1112
"@pact-foundation/pact": "^16.0.4",
1213
"@pact-foundation/pact-core": "^17.1.0",
1314
"@playwright/test": "^1.57.0",
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import path from "node:path";
2+
import { MessageProviderPact } from "@pact-foundation/pact";
3+
import LetterAcceptedEvent from "@nhsdigital/nhs-notify-event-schemas-supplier-api/schemas/examples/letter.ACCEPTED.json";
4+
import LetterCancelledEvent from "@nhsdigital/nhs-notify-event-schemas-supplier-api/schemas/examples/letter.CANCELLED.json";
5+
import LetterDeliveredEvent from "@nhsdigital/nhs-notify-event-schemas-supplier-api/schemas/examples/letter.DELIVERED.json";
6+
import LetterDispatchedEvent from "@nhsdigital/nhs-notify-event-schemas-supplier-api/schemas/examples/letter.DISPATCHED.json";
7+
import LetterEnclosedEvent from "@nhsdigital/nhs-notify-event-schemas-supplier-api/schemas/examples/letter.ENCLOSED.json";
8+
import LetterFailedEvent from "@nhsdigital/nhs-notify-event-schemas-supplier-api/schemas/examples/letter.FAILED.json";
9+
import LetterForwardedEvent from "@nhsdigital/nhs-notify-event-schemas-supplier-api/schemas/examples/letter.FORWARDED.json";
10+
import LetterPendingEvent from "@nhsdigital/nhs-notify-event-schemas-supplier-api/schemas/examples/letter.PENDING.json";
11+
import LetterPrintedEvent from "@nhsdigital/nhs-notify-event-schemas-supplier-api/schemas/examples/letter.PRINTED.json";
12+
import LetterRejectedEvent from "@nhsdigital/nhs-notify-event-schemas-supplier-api/schemas/examples/letter.REJECTED.json";
13+
import LetterReturnedEvent from "@nhsdigital/nhs-notify-event-schemas-supplier-api/schemas/examples/letter.RETURNED.json";
14+
15+
describe("Supplier API -> Digital Letters pact tests", () => {
16+
test("verify pacts", async () => {
17+
const p = new MessageProviderPact({
18+
provider: "supplier-api",
19+
pactUrls: [
20+
path.join(
21+
__dirname,
22+
"../../../node_modules",
23+
"@nhsdigital/notify-digital-letters-consumer-contracts/pacts/supplier-api/digital-letters-supplier-api.json",
24+
),
25+
],
26+
messageProviders: {
27+
"SupplierApiEvent-letter_accepted": () => LetterAcceptedEvent,
28+
"SupplierApiEvent-letter_cancelled": () => LetterCancelledEvent,
29+
"SupplierApiEvent-letter_delivered": () => LetterDeliveredEvent,
30+
"SupplierApiEvent-letter_dispatched": () => LetterDispatchedEvent,
31+
"SupplierApiEvent-letter_enclosed": () => LetterEnclosedEvent,
32+
"SupplierApiEvent-letter_failed": () => LetterFailedEvent,
33+
"SupplierApiEvent-letter_forwarded": () => LetterForwardedEvent,
34+
"SupplierApiEvent-letter_pending": () => LetterPendingEvent,
35+
"SupplierApiEvent-letter_printed": () => LetterPrintedEvent,
36+
"SupplierApiEvent-letter_rejected": () => LetterRejectedEvent,
37+
"SupplierApiEvent-letter_returned": () => LetterReturnedEvent,
38+
},
39+
logLevel: "error",
40+
});
41+
42+
await expect(p.verify()).resolves.not.toThrow();
43+
}, 60_000);
44+
});

tests/pact-tests/run-pact-tests.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ set -euo pipefail
44

55
# Ensure we have the latest package matching the major version
66
npm install --no-lockfile @nhsdigital/nhs-notify-event-schemas-letter-rendering@^2
7+
npm install --no-lockfile @nhsdigital/notify-digital-letters-consumer-contracts@^1
78

89
# Reinstall pact to ensure platform-specific native dependencies are present
910
# CI may run on a different architectures to local dev

0 commit comments

Comments
 (0)