Skip to content

CCM-12950: Add Functional Tests for Events #449

Open
Namitha-Prabhu wants to merge 11 commits intomainfrom
feature/CCM-12950-AddEventsTests
Open

CCM-12950: Add Functional Tests for Events #449
Namitha-Prabhu wants to merge 11 commits intomainfrom
feature/CCM-12950-AddEventsTests

Conversation

@Namitha-Prabhu
Copy link
Contributor

Description

Context

Type of changes

  • Refactoring (non-breaking change)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would change existing functionality)
  • Bug fix (non-breaking change which fixes an issue)

Checklist

  • I am familiar with the contributing guidelines
  • I have followed the code style of the project
  • I have added tests to cover my changes
  • I have updated the documentation accordingly
  • This PR is a result of pair or mob programming
  • If I have used the 'skip-trivy-package' label I have done so responsibly and in the knowledge that this is being fixed as part of a separate ticket/PR.

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.

  • I confirm that neither PII/PID nor sensitive data are included in this PR and the codebase changes.

@Namitha-Prabhu Namitha-Prabhu requested review from a team as code owners March 9, 2026 16:24
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 18 out of 22 changed files in this pull request and generated 3 comments.

let statusCode = 0;
let letterStatus: string | undefined;

for (let attempt = 1; attempt <= 3; attempt++) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants