Skip to content

Conversation

@LTS2
Copy link
Contributor

@LTS2 LTS2 commented Jan 13, 2026

Summary

  • Add comprehensive unit tests for deep-merge.ts utility functions

Changes

  • Create src/shared/deep-merge.test.ts with 26 test cases
    • isPlainObject: 11 tests covering null, undefined, primitives, Array, Date, RegExp, and plain objects
    • deepMerge: 15 tests covering:
      • Basic object merging (simple merge, override precedence, deep merge, multiple nesting levels)
      • Edge cases (undefined handling for base, override, and values)
      • Array replacement behavior (arrays are replaced, not concatenated)
      • Prototype pollution protection (__proto__, constructor, prototype keys are ignored)
      • MAX_DEPTH limit handling

Testing

bun run typecheck    # Passes
bun test src/shared/deep-merge.test.ts    # 26 tests pass
bun test    # All 1112 tests pass
bun run build    # Succeeds

Related Issues

N/A - This is a proactive improvement to increase test coverage for the shared module.


Summary by cubic

Added unit tests for the shared deep-merge utility to increase confidence and prevent regressions. Covers plain object detection, deep merge behavior, array replacement, undefined handling, prototype pollution protection, and max-depth handling.

Written for commit 2042a29. Summary will update on new commits.

@github-actions
Copy link
Contributor

github-actions bot commented Jan 13, 2026

All contributors have signed the CLA. Thank you! ✅
Posted by the CLA Assistant Lite bot.

Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 1 file

Confidence score: 4/5

  • Test coverage in src/shared/deep-merge.test.ts is weak: the MAX_DEPTH override scenario only checks that the nested structure exists and never asserts the value remains "override", so regressions in deep-merge behavior could slip through.
  • Pay close attention to src/shared/deep-merge.test.ts - strengthen the MAX_DEPTH override assertion to ensure overrides aren’t merged back with the base.
Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="src/shared/deep-merge.test.ts">

<violation number="1" location="src/shared/deep-merge.test.ts:328">
P2: Weak assertion: test claims to verify MAX_DEPTH override behavior but only checks structure existence. Should assert that the value at depth 51+ is `"override"` (not merged with base) to actually verify the stated behavior.</violation>
</file>

Since this is your first cubic review, here's how it works:

  • cubic automatically reviews your code and comments on bugs and improvements
  • Teach cubic by replying to its comments. cubic learns from your replies and gets better over time
  • Ask questions if you need clarification on any suggestion

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

@LTS2
Copy link
Contributor Author

LTS2 commented Jan 13, 2026

I have read the CLA Document and I hereby sign the CLA

@LTS2
Copy link
Contributor Author

LTS2 commented Jan 13, 2026

Hi, I've signed the CLA but the workflow is failing with:

Could not update the JSON file: Repository rule violations found
Changes must be made through a pull request.

It seems the branch protection rules are preventing the CLA Assistant from updating signatures/cla.json. Could you please help resolve this? Thank you!

@kdcokenny
Copy link
Collaborator

Hi, I've signed the CLA but the workflow is failing with:

Could not update the JSON file: Repository rule violations found
Changes must be made through a pull request.

It seems the branch protection rules are preventing the CLA Assistant from updating signatures/cla.json. Could you please help resolve this? Thank you!

We are fixing it rn!

github-actions bot added a commit that referenced this pull request Jan 13, 2026
Add comprehensive unit tests for the deep-merge.ts utility functions:

- isPlainObject: 11 test cases covering null, undefined, primitives,
  Array, Date, RegExp, and plain objects
- deepMerge: 15 test cases covering:
  - Basic object merging
  - Deep nested object merging
  - Edge cases (undefined handling)
  - Array replacement behavior
  - Prototype pollution protection (DANGEROUS_KEYS)
  - MAX_DEPTH limit handling
@LTS2 LTS2 force-pushed the test/deep-merge-unit-tests branch from 2782cea to 2042a29 Compare January 13, 2026 13:23
@LTS2
Copy link
Contributor Author

LTS2 commented Jan 13, 2026

Fixed the weak assertion in depth limit test (P2 feedback).

Before

expect(current.nested).toBeDefined()  // Only checks structure exists

After

// Use different keys to distinguish base vs override
const base = createDeepObject(55, { baseKey: "base" })
const override = createDeepObject(55, { overrideKey: "override" })

// At depth 55, only override's key should exist
expect(current.overrideKey).toBe("override")
expect(current.baseKey).toBeUndefined()

This now properly verifies that at depth 51+ (beyond MAX_DEPTH of 50), override replaces base entirely instead of merging.

@kdcokenny
Copy link
Collaborator

lgtm, thanks for the pr!

@kdcokenny kdcokenny merged commit 1a3fb00 into code-yeongyu:dev Jan 13, 2026
2 checks passed
kdcokenny pushed a commit that referenced this pull request Jan 13, 2026
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