Skip to content

Extract mountActiveSegment/mountSnapSpacer test helpers#106

Merged
alex-rawlings-yyc merged 1 commit into
mainfrom
use-segment-window-test
Jun 15, 2026
Merged

Extract mountActiveSegment/mountSnapSpacer test helpers#106
alex-rawlings-yyc merged 1 commit into
mainfrom
use-segment-window-test

Conversation

@imnasnainaec

@imnasnainaec imnasnainaec commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Replace the 11 inline aria-current="true" recenter-target setups in useSegmentWindow.test.ts with two composable local helpers, mirroring the existing mountSegmentEls. Two helpers (rather than one spacer-option helper) keep both return types a plain HTMLElement, avoiding an HTMLElement | undefined union at the call sites that the no-type-assertion rule would make awkward.

Devin: https://app.devin.ai/review/sillsdev/interlinearizer-extension/pull/106


This change is Reviewable

Summary by CodeRabbit

  • Tests
    • Refactored test setup helpers to reduce code duplication and improve maintainability of test cases for snap behavior and settling timing scenarios.

Replace the 11 inline aria-current="true" recenter-target setups in
useSegmentWindow.test.ts with two composable local helpers, mirroring the
existing mountSegmentEls. Two helpers (rather than one spacer-option helper)
keep both return types a plain HTMLElement, avoiding an HTMLElement | undefined
union at the call sites that the no-type-assertion rule would make awkward.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jun 15, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 5baddb4e-603e-4603-91a3-b51d0a577cee

📥 Commits

Reviewing files that changed from the base of the PR and between b9dec18 and e82d610.

📒 Files selected for processing (1)
  • src/__tests__/hooks/useSegmentWindow.test.ts

📝 Walkthrough

Walkthrough

Two DOM setup helpers, mountActiveSegment and mountSnapSpacer, are added to the useSegmentWindow test file. Twelve test cases that previously created aria-current="true" elements and [data-snap-spacer] elements inline now call these helpers instead.

Changes

Test DOM Setup Helper Extraction

Layer / File(s) Summary
Helper definitions and all call-site replacements
src/__tests__/hooks/useSegmentWindow.test.ts
mountActiveSegment and mountSnapSpacer are defined once (lines 237–266) with an optional initial height parameter; all twelve test setups that previously created these DOM elements inline now call the helpers.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐇 Hop hop, no more copy-paste to dread,
A helper now creates each testing bed.
mountActiveSegment leaps into place,
mountSnapSpacer sets the height with grace.
The warren is tidy, the tests run neat—
One little rabbit keeps the suite complete! 🌿

🚥 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 title clearly and accurately summarizes the main change: extracting two test helper functions to reduce code duplication.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
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 use-segment-window-test

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.

@imnasnainaec imnasnainaec marked this pull request as ready for review June 15, 2026 16:46

@alex-rawlings-yyc alex-rawlings-yyc left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@alex-rawlings-yyc reviewed 1 file and all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on imnasnainaec).

@alex-rawlings-yyc alex-rawlings-yyc merged commit 675face into main Jun 15, 2026
11 checks passed
@alex-rawlings-yyc alex-rawlings-yyc deleted the use-segment-window-test branch June 15, 2026 18:14
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