diff --git a/.github/actions/acceptance-tests/action.yaml b/.github/actions/acceptance-tests/action.yaml index d6735f77a..e063dab6b 100644 --- a/.github/actions/acceptance-tests/action.yaml +++ b/.github/actions/acceptance-tests/action.yaml @@ -77,9 +77,16 @@ runs: TEST_TYPE: ${{ inputs.testType }} ENVIRONMENT: ${{ inputs.targetEnvironment }} PLAYWRIGHT_SHARD: ${{ inputs.shard }} + - name: Sanitise shard for artifact name + id: shard_label + if: ${{ inputs.testType == 'integration' && inputs.shard != '' }} + shell: bash + run: echo "value=${SHARD//\// of }" >> $GITHUB_OUTPUT + env: + SHARD: ${{ inputs.shard }} - name: Archive integration test results if: ${{ inputs.testType == 'integration' }} uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6 with: - name: Integration test report + name: Integration test report${{ inputs.shard != '' && format(' ({0})', steps.shard_label.outputs.value) || '' }} path: "tests/playwright/playwright-report" diff --git a/lambdas/core-notifier-lambda/src/__tests__/apis/sqs-handler.test.ts b/lambdas/core-notifier-lambda/src/__tests__/apis/sqs-handler.test.ts index fd7046aad..c19446a44 100644 --- a/lambdas/core-notifier-lambda/src/__tests__/apis/sqs-handler.test.ts +++ b/lambdas/core-notifier-lambda/src/__tests__/apis/sqs-handler.test.ts @@ -155,6 +155,7 @@ describe('createHandler', () => { description: 'Failed processing message', messageId: sqsEvent.Records[0].messageId, senderId: validSender.senderId, + messageReference, }), ); }); @@ -227,6 +228,7 @@ describe('createHandler', () => { description: 'Failed processing message', messageId, senderId: undefined, + messageReference: undefined, }); expect(mockLogger.info).toHaveBeenCalledWith({ description: '0 of 1 records processed successfully', @@ -257,6 +259,7 @@ describe('createHandler', () => { description: 'Failed processing message', messageId, senderId: validSender.senderId, + messageReference, }); expect( mockEventPublisher.sendEvents, @@ -301,6 +304,7 @@ describe('createHandler', () => { description: 'Failed processing message', messageId, senderId: validSender.senderId, + messageReference, }); expect(mockEventPublisher.sendEvents).toHaveBeenCalledTimes(1); expect(mockEventPublisher.sendEvents).toHaveBeenCalledWith( diff --git a/lambdas/core-notifier-lambda/src/apis/sqs-handler.ts b/lambdas/core-notifier-lambda/src/apis/sqs-handler.ts index 015beff3e..591278f95 100644 --- a/lambdas/core-notifier-lambda/src/apis/sqs-handler.ts +++ b/lambdas/core-notifier-lambda/src/apis/sqs-handler.ts @@ -128,6 +128,7 @@ async function processSqsRecord( description: 'Failed processing message', messageId: sqsRecord.messageId, senderId: incoming?.data.senderId, + messageReference: incoming?.data.messageReference, }); if (error instanceof RequestNotifyError && incoming && sender) { diff --git a/tests/playwright/config/component/senders.setup.ts b/tests/playwright/config/component/senders.setup.ts index 43fb2addb..26f142f5b 100644 --- a/tests/playwright/config/component/senders.setup.ts +++ b/tests/playwright/config/component/senders.setup.ts @@ -2,6 +2,7 @@ import { test as setup } from '@playwright/test'; import senderRepository from 'helpers/sender-helpers'; import { Sender } from 'utils'; import { + ROUTING_CONFIG_ID, SENDER_ID_SKIPS_NOTIFY, SENDER_ID_THAT_TRIGGERS_ERROR_IN_NOTIFY_SANDBOX, SENDER_ID_VALID_FOR_NOTIFY_SANDBOX, @@ -20,7 +21,7 @@ const testSenders: Sender[] = [ senderName: 'componentTestSender_RoutingConfig', meshMailboxSenderId: 'meshMailboxSender1', meshMailboxReportsId: 'meshMailboxReports1', - routingConfigId: 'b838b13c-f98c-4def-93f0-515d4e4f4ee1', + routingConfigId: ROUTING_CONFIG_ID, fallbackWaitTimeSeconds: 100, }, { diff --git a/tests/playwright/constants/tests-constants.ts b/tests/playwright/constants/tests-constants.ts index 9cd18aef5..7d2d40f8c 100644 --- a/tests/playwright/constants/tests-constants.ts +++ b/tests/playwright/constants/tests-constants.ts @@ -17,15 +17,21 @@ export const ENVIRONMENT_SPECIFIC_CONSTANTS = { // Suppliers Dev Account '820178564574': { nhsAppBaseUrl: 'https://example.com', + routingConfigId: 'b838b13c-f98c-4def-93f0-515d4e4f4ee1', }, // Suppliers Non Prod Account '885964308133': { nhsAppBaseUrl: 'https://www-onboardingaos.nhsapp.service.nhs.uk', + routingConfigId: 'c940a9ce-e70d-4986-8046-afd168b39738', }, }; -export const NHS_APP_BASE_URL = +const ENVIRONMENT_CONFIG = ENVIRONMENT_SPECIFIC_CONSTANTS[ AWS_ACCOUNT_ID_SAFE as keyof typeof ENVIRONMENT_SPECIFIC_CONSTANTS - ].nhsAppBaseUrl; + ]; + +export const NHS_APP_BASE_URL = ENVIRONMENT_CONFIG.nhsAppBaseUrl; + +export const ROUTING_CONFIG_ID = ENVIRONMENT_CONFIG.routingConfigId; diff --git a/tests/playwright/digital-letters-component-tests/core-notify.component.spec.ts b/tests/playwright/digital-letters-component-tests/core-notify.component.spec.ts index 1d2a42d47..c653803af 100644 --- a/tests/playwright/digital-letters-component-tests/core-notify.component.spec.ts +++ b/tests/playwright/digital-letters-component-tests/core-notify.component.spec.ts @@ -192,7 +192,7 @@ test.describe('Digital Letters - Core Notify', () => { }); test('given PDMResourceAvailable event, when client does NOT exist then it goes to DLQ', async () => { - test.setTimeout(250_000); + test.setTimeout(360_000); const eventId = uuidv4(); const messageReference = uuidv4(); @@ -213,18 +213,21 @@ test.describe('Digital Letters - Core Notify', () => { validatePDMResourceAvailable, ); - await Promise.all([ - // Verify the event is processed and a message appears in the Lambda logs - expectToPassEventually(async () => { - const filteredLogs = await getLogsFromCloudwatch( - CORE_NOTIFIER_LAMBDA_LOG_GROUP_NAME, - ['$.message.description = "0 of 1 records processed successfully"'], - ); - - expect(filteredLogs.length).toBeGreaterThanOrEqual(1); - }, 240), - // Verify there is a message in the DLQ - expectMessageContainingString(CORE_NOTIFIER_DLQ_NAME, eventId, 240), - ]); + // Verify the event is processed and a message appears in the Lambda logs + await expectToPassEventually(async () => { + const filteredLogs = await getLogsFromCloudwatch( + CORE_NOTIFIER_LAMBDA_LOG_GROUP_NAME, + [ + '$.message.description = "Failed processing message"', + '$.message.error = "Sender not found for senderId: senderId_that_does_not_exist"', + `$.message.messageReference = "${messageReference}"`, + ], + ); + + expect(filteredLogs.length).toBeGreaterThanOrEqual(1); + }, 240); + + // Verify there is a message in the DLQ + await expectMessageContainingString(CORE_NOTIFIER_DLQ_NAME, eventId, 300); }); });