Skip to content

refactor(tests): extract buildCreateChange helper for 6F suite#6

Merged
joalves merged 1 commit into
mainfrom
refactor/tests-create-change-builder
Apr 30, 2026
Merged

refactor(tests): extract buildCreateChange helper for 6F suite#6
joalves merged 1 commit into
mainfrom
refactor/tests-create-change-builder

Conversation

@joalves
Copy link
Copy Markdown
Contributor

@joalves joalves commented Apr 30, 2026

Summary

Follow-up to #5 addressing CodeRabbit's nitpick: the create-change payloads were duplicated across the 6F2-6F8 viewport-create tests. This PR extracts a buildCreateChange(overrides) helper near the imports and routes the 6F2-6F8 tests through it. Each test now declares only the fields that vary (targetSelector, element, position, malformed cases use targetSelector: undefined).

Pure refactor — no behavioural change. Net -55 lines.

Test plan

  • npx jest --testPathPattern="DOMChangesPluginLite" — 7 suites, 263 passed (unchanged from main).
  • npx jest --testPathPattern="crossVariantExposure" -t "6F" — all 11 6F.* tests pass.
  • npm run lint — 0 errors after prettier.
  • CI green.

Summary by CodeRabbit

Release Notes

  • Tests
    • Internal test code refactored for improved maintainability.

Note: This release contains no user-visible changes.

Addresses CodeRabbit nitpick on PR #5: the create-change payloads were
duplicated across 6F2-6F8. Add a buildCreateChange(overrides) helper near
the imports and route the 6F2-6F8 tests through it. Each test now declares
only the fields that vary (targetSelector, element, position, malformed).

No behavioural change - all 263 tests pass.
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 30, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 9ba52114-add4-4ede-87f4-6264bba9cd73

📥 Commits

Reviewing files that changed from the base of the PR and between 968fcd0 and 0f19b46.

📒 Files selected for processing (1)
  • src/core/__tests__/DOMChangesPluginLite.crossVariantExposure.test.ts

Walkthrough

The pull request introduces a buildCreateChange helper function that generates default 'create' DOMChange objects with standard fields (selector, type, element, targetSelector, position, trigger_on_view), whilst allowing field overrides. Multiple test cases are refactored to use this helper instead of manually constructing verbose inline payloads, reducing code duplication across the test suite. Malformed-create scenarios are also updated to leverage the helper with specific overrides rather than type-cast incomplete objects.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Poem

A helper hops through test-land bright, ✨
Building changes left and right,
No verbose clutter, just clean code—
Less duplication on the road! 🐰

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title accurately describes the main change: extracting a buildCreateChange helper function for the 6F test suite to reduce duplication in test payloads.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/tests-create-change-builder

Review rate limit: 4/5 reviews remaining, refill in 12 minutes.

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

@joalves joalves merged commit 3d9e9f9 into main Apr 30, 2026
2 checks passed
@joalves joalves deleted the refactor/tests-create-change-builder branch April 30, 2026 09:08
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