CCM-12950: Add Functional Tests for Events #449
CCM-12950: Add Functional Tests for Events #449Namitha-Prabhu wants to merge 11 commits intomainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Adds new functional/component test coverage around the Event Subscription (SNS) flow, alongside a few sandbox test expectation fixes and supporting test infrastructure updates.
Changes:
- Introduces component tests that publish prepared-letter CloudEvents to SNS and validate downstream allocation/upsert behavior via API + CloudWatch Logs polling.
- Updates sandbox test cases to align expected HTTP statuses (e.g., 202 on update, 404 for missing letter).
- Adds supporting helpers/deps (SNS publish helper, CloudWatch polling helper, fixtures) and wires in a sandbox test target/test type.
Reviewed changes
Copilot reviewed 13 out of 15 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/component-tests/events-tests/event-subscription.spec.ts | New SNS event subscription component tests covering success, invalid status, and duplicate events. |
| tests/helpers/send-sns-event.ts | Helper to publish events to SNS topic for tests. |
| tests/helpers/aws-cloudwatch-helper.ts | Helper to poll CloudWatch Logs for allocator/upsert processing evidence. |
| tests/helpers/event-fixtures.ts | Event payload fixture builder for prepared v1 CloudEvents. |
| tests/constants/api-constants.ts | Adds SNS topic name constant used by event tests/helpers. |
| tests/constants/request-headers.ts | Allows overriding supplier id when creating request headers (needed for allocator-derived supplier). |
| tests/sandbox/update-letter-status.spec.ts | Adjusts sandbox update-letter-status spec assertions. |
| tests/sandbox/testCases/update-multiple-status-test-cases.ts | Updates expected status from 200 to 202 for multi-status update. |
| tests/sandbox/testCases/get-letter-status-test-cases.ts | Fixes missing-letter expected status to 404. |
| tests/package.json | Adds CloudWatch Logs SDK dependency for new helper. |
| tests/e2e-tests/poetry.lock | Dependency bump for authlib. |
| .github/actions/test-types.json | Adds sandbox as a recognized test type. |
| Makefile | Adds test-sandbox target and modifies e2e proxy-name used by test command. |
| package.json | Adds an override for transitive dependency resolution. |
| package-lock.json | Lockfile updates for AWS SDK / related dependencies and new CloudWatch Logs client. |
| let statusCode = 0; | ||
| let letterStatus: string | undefined; | ||
|
|
||
| for (let attempt = 1; attempt <= 3; attempt++) { |
There was a problem hiding this comment.
I might pull this for loop into a separate function called poll_for_letter or something similar, just to keep the test function to a manageable length.
| logger.info(`Testing event subscription with domainId: ${domainId}`); | ||
| const preparedEvent = createPreparedV1Event({ domainId }); | ||
| const response = await sendSnsEvent(preparedEvent); | ||
| const RETRY_DELAY_MS = 30_000; |
There was a problem hiding this comment.
30 seconds seems a bit long for a retry delay - if it takes 35 seconds for the letter to be available, then it would take 60 seconds for the test to complete. We might want to consider reducing it to 5 or 10 seconds.
| }, | ||
| ); | ||
|
|
||
| expect(getLetterResponse.status()).toBe(500); |
There was a problem hiding this comment.
Why does the API return 500 here? If the letter doesn't exist in the database then wouldn't we get a 404?
| }); | ||
|
|
||
| export async function pollSupplierAllocatorLogForResolvedSpec( | ||
| domainId?: string, |
There was a problem hiding this comment.
Does domainId need to be optional here? If the caller doesn't supply it, then it looks like this function might incorrectly find logs relating to other tests. (I think you do supply it everywhere this function get called, so it might just be a case of making it non-optional in the function signature)
Description
Context
Type of changes
Checklist
Sensitive Information Declaration
To ensure the utmost confidentiality and protect your and others privacy, we kindly ask you to NOT including PII (Personal Identifiable Information) / PID (Personal Identifiable Data) or any other sensitive data in this PR (Pull Request) and the codebase changes. We will remove any PR that do contain any sensitive information. We really appreciate your cooperation in this matter.