Skip to content

Test/PROD-1439 duplicate content mapping guards#151

Open
5PK wants to merge 1 commit into
mainfrom
test/prod-1439-duplicate-mappings
Open

Test/PROD-1439 duplicate content mapping guards#151
5PK wants to merge 1 commit into
mainfrom
test/prod-1439-duplicate-mappings

Conversation

@5PK
Copy link
Copy Markdown
Collaborator

@5PK 5PK commented May 29, 2026

Summary

Adds unit tests for the two duplicate-mapping guards introduced in PR #143 (Jira ticket PROD-1439).

Tests added

src/lib/mappers/tests/content-item-mapper.test.ts

  • New test: "throws when source already has a mapping but a different unmapped target is provided (duplicate mapping attempt)"
  • Verifies that ContentItemMapper.addMapping throws 'Aborting a duplicate mapping attempt' when a source content item (ID 10) that is already mapped to a target (ID 20) is subsequently mapped to a different, previously-unmapped target (ID 99). This guards against silent data corruption where one source would end up pointing to multiple targets.

src/lib/pushers/content-pusher/util/tests/get-content-item-types.test.ts

  • New test: "item already in linkedSet is not re-added to normalSet when its own loop iteration runs"
  • Verifies that when a linked item appears after its parent in the input array, its own loop iteration does not incorrectly promote it back into normalContentItems. The test asserts that linkedItem appears exactly once in linkedContentItems and is absent from normalContentItems.

Related

Test plan

  • yarn test src/lib/mappers/tests/content-item-mapper.test.ts — new test passes
  • yarn test src/lib/pushers/content-pusher/util/tests/get-content-item-types.test.ts — new test passes
  • Full test suite passes (yarn test)

🤖 Generated with Claude Code

Add unit tests covering the two guards introduced in PR #143 (PROD-1439):
- content-item-mapper: throws on a duplicate mapping attempt where the source is already mapped to a different target
- getContentItemTypes: an item already promoted to linkedSet is not re-added to normalSet on its own loop iteration
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.

1 participant