diff --git a/tests/package.json b/tests/package.json index 5f18e94d8..c096908da 100644 --- a/tests/package.json +++ b/tests/package.json @@ -7,7 +7,8 @@ "@aws-sdk/client-lambda": "^3.986.0", "@aws-sdk/client-sns": "^3.984.0", "@aws-sdk/lib-dynamodb": "^3.1008.0", - "@nhsdigital/nhs-notify-event-schemas-letter-rendering": "2.0.1", + "@nhsdigital/nhs-notify-event-schemas-letter-rendering": "^2.0.1", + "@nhsdigital/notify-digital-letters-consumer-contracts": "^1.0.1", "@pact-foundation/pact": "^16.0.4", "@pact-foundation/pact-core": "^17.1.0", "@playwright/test": "^1.57.0", diff --git a/tests/pact-tests/provider/supplier-api.digital-letters.provider.pact.test.ts b/tests/pact-tests/provider/supplier-api.digital-letters.provider.pact.test.ts new file mode 100644 index 000000000..23dd0fea8 --- /dev/null +++ b/tests/pact-tests/provider/supplier-api.digital-letters.provider.pact.test.ts @@ -0,0 +1,44 @@ +import path from "node:path"; +import { MessageProviderPact } from "@pact-foundation/pact"; +import LetterAcceptedEvent from "@nhsdigital/nhs-notify-event-schemas-supplier-api/schemas/examples/letter.ACCEPTED.json"; +import LetterCancelledEvent from "@nhsdigital/nhs-notify-event-schemas-supplier-api/schemas/examples/letter.CANCELLED.json"; +import LetterDeliveredEvent from "@nhsdigital/nhs-notify-event-schemas-supplier-api/schemas/examples/letter.DELIVERED.json"; +import LetterDispatchedEvent from "@nhsdigital/nhs-notify-event-schemas-supplier-api/schemas/examples/letter.DISPATCHED.json"; +import LetterEnclosedEvent from "@nhsdigital/nhs-notify-event-schemas-supplier-api/schemas/examples/letter.ENCLOSED.json"; +import LetterFailedEvent from "@nhsdigital/nhs-notify-event-schemas-supplier-api/schemas/examples/letter.FAILED.json"; +import LetterForwardedEvent from "@nhsdigital/nhs-notify-event-schemas-supplier-api/schemas/examples/letter.FORWARDED.json"; +import LetterPendingEvent from "@nhsdigital/nhs-notify-event-schemas-supplier-api/schemas/examples/letter.PENDING.json"; +import LetterPrintedEvent from "@nhsdigital/nhs-notify-event-schemas-supplier-api/schemas/examples/letter.PRINTED.json"; +import LetterRejectedEvent from "@nhsdigital/nhs-notify-event-schemas-supplier-api/schemas/examples/letter.REJECTED.json"; +import LetterReturnedEvent from "@nhsdigital/nhs-notify-event-schemas-supplier-api/schemas/examples/letter.RETURNED.json"; + +describe("Supplier API -> Digital Letters pact tests", () => { + test("verify pacts", async () => { + const p = new MessageProviderPact({ + provider: "supplier-api", + pactUrls: [ + path.join( + __dirname, + "../../../node_modules", + "@nhsdigital/notify-digital-letters-consumer-contracts/pacts/supplier-api/digital-letters-supplier-api.json", + ), + ], + messageProviders: { + "SupplierApiEvent-letter_accepted": () => LetterAcceptedEvent, + "SupplierApiEvent-letter_cancelled": () => LetterCancelledEvent, + "SupplierApiEvent-letter_delivered": () => LetterDeliveredEvent, + "SupplierApiEvent-letter_dispatched": () => LetterDispatchedEvent, + "SupplierApiEvent-letter_enclosed": () => LetterEnclosedEvent, + "SupplierApiEvent-letter_failed": () => LetterFailedEvent, + "SupplierApiEvent-letter_forwarded": () => LetterForwardedEvent, + "SupplierApiEvent-letter_pending": () => LetterPendingEvent, + "SupplierApiEvent-letter_printed": () => LetterPrintedEvent, + "SupplierApiEvent-letter_rejected": () => LetterRejectedEvent, + "SupplierApiEvent-letter_returned": () => LetterReturnedEvent, + }, + logLevel: "error", + }); + + await expect(p.verify()).resolves.not.toThrow(); + }, 60_000); +}); diff --git a/tests/pact-tests/run-pact-tests.sh b/tests/pact-tests/run-pact-tests.sh index d2d00581a..3c024da21 100755 --- a/tests/pact-tests/run-pact-tests.sh +++ b/tests/pact-tests/run-pact-tests.sh @@ -4,6 +4,7 @@ set -euo pipefail # Ensure we have the latest package matching the major version npm install --no-lockfile @nhsdigital/nhs-notify-event-schemas-letter-rendering@^2 +npm install --no-lockfile @nhsdigital/notify-digital-letters-consumer-contracts@^1 # Reinstall pact to ensure platform-specific native dependencies are present # CI may run on a different architectures to local dev