Skip to content

Conversation

@devksingh4
Copy link
Member

@devksingh4 devksingh4 commented Nov 11, 2025

Summary by CodeRabbit

  • Tests
    • Enhanced test coverage with additional host-specific scenarios to verify response handling consistency across different configurations.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 11, 2025

Walkthrough

The test suite for the CloudFront Lambda@Edge Handler was updated to replace a single DynamoDB success test with two host-specific test scenarios for "go.acm" and "acm.gg". Each test now verifies the complete 302 response structure, including status code, headers, and redirect location.

Changes

Cohort / File(s) Summary
Test Suite Updates for CloudFront Lambda@Edge Handler
tests/unit/linkryEdgeFunction/main.test.ts
Renamed DynamoDB success test to specify host "go.acm" and added a second test for host "acm.gg". Both tests now construct events with host overrides and assert the full 302 response object structure (status, headers, redirect location) instead of partial assertions.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

  • Test-only changes with straightforward host-specific scenarios
  • Repetitive test structure additions for different hosts
  • Standard assertion expansions to verify response completeness

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: updating unit tests for the linkry edge redirect functionality, which aligns with the changes in the test file.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch dsingh14/update-unit-tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Contributor

💰 Infracost report

Monthly estimate generated

This comment will be updated when code changes.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
tests/unit/linkryEdgeFunction/main.test.ts (1)

117-143: LGTM! Good coverage for acm.gg domain.

The test properly verifies the redirect behavior for the acm.gg host with comprehensive assertions. This complements the existing acm.gg subdomain tests (lines 246-262) by covering the base domain scenario.

Optional: Consider using parameterized tests (e.g., it.each) to reduce duplication between the two similar tests:

it.each([
  { host: "go.acm.illinois.edu", slug: "test-link" },
  { host: "acm.gg", slug: "testgg" },
])("should return 302 redirect when link is found in DynamoDB for $host", async ({ host, slug }) => {
  const redirectUrl = "https://example.com/target";
  dynamoMock.on(QueryCommand).resolves({
    Items: [
      {
        slug: { S: slug },
        access: { S: "OWNER#user123" },
        redirect: { S: redirectUrl },
      },
    ],
  });

  const event = createEvent(`/${slug}`, host);
  const result = await handler(event);
  assertIsResponse(result);

  expect(result).toEqual({
    status: "302",
    statusDescription: "Found",
    headers: {
      location: [{ key: "Location", value: redirectUrl }],
      "cache-control": [
        { key: "Cache-Control", value: "public, max-age=30" },
      ],
    },
  });
});
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Cache: Disabled due to data retention organization setting

Knowledge base: Disabled due to data retention organization setting

📥 Commits

Reviewing files that changed from the base of the PR and between 26bcec3 and 37aff61.

📒 Files selected for processing (1)
  • tests/unit/linkryEdgeFunction/main.test.ts (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Build Application
  • GitHub Check: Run Unit Tests
🔇 Additional comments (2)
tests/unit/linkryEdgeFunction/main.test.ts (2)

89-89: Good improvement to test description specificity.

The updated test name clearly indicates which host domain is being tested, making the test suite more readable and maintainable.


101-115: LGTM! Enhanced test coverage and clarity.

The explicit host parameter and comprehensive response structure assertion significantly improve test quality by verifying the complete 302 redirect behavior rather than partial properties.

@devksingh4 devksingh4 merged commit 4029f33 into main Nov 12, 2025
11 of 12 checks passed
@devksingh4 devksingh4 deleted the dsingh14/update-unit-tests branch November 12, 2025 18:06
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.

2 participants