Skip to content

Rewrite admin, announcement and shared-primitive test suites with React Testing Library#321

Open
jonathangreen wants to merge 1 commit into
mainfrom
rtl-admin-misc
Open

Rewrite admin, announcement and shared-primitive test suites with React Testing Library#321
jonathangreen wants to merge 1 commit into
mainfrom
rtl-admin-misc

Conversation

@jonathangreen

@jonathangreen jonathangreen commented Jul 13, 2026

Copy link
Copy Markdown
Member

Description

Rewrites the admin, discovery, announcement, and shared form/presentational primitive test suites with React Testing Library.

Migrated suites (old enzyme test in src/components/__tests__/ removed, RTL test added/expanded in tests/jest/components/):

  • IndividualAdminEditForm
  • IndividualAdmins
  • ChangePasswordForm
  • Header
  • LibraryRegistration
  • DiscoveryServices
  • NeighborhoodAnalyticsForm
  • AnnouncementForm
  • AnnouncementsSection
  • TextWithEditMode
  • EditableInput
  • ToolTip

Migration notes (carried over from #316, for the suites in this PR):

  • Prototype stubs (EditableInput.prototype.getValue, TextWithEditMode) become real userEvent.type that reads back through the component's ref API; state()/instance() reads become DOM assertions.
  • EditableInput and IndividualAdmins merge into existing jest suites rather than adding new files.
  • Where a suite covers a connected panel (e.g. DiscoveryServices, Header), it renders the connected default export so mapStateToProps/mapDispatchToProps stay covered.
  • userEvent usage follows the const user = userEvent.setup() convention used across tests/jest/.

This is one of four PRs splitting the oversized #316 into independently reviewable pieces, grouped by feature area. Each split branches from main and touches a disjoint set of component test files, so the four can be reviewed and merged in any order.

Motivation and Context

#316 rewrote the HARD-tier and remaining merge test suites from enzyme to React Testing Library in a single ~11k-line change, which is impractical to review. Splitting it by feature area keeps each PR at a reviewable size while preserving the same net result. These were among the hardest suites in the mocha/chai/enzyme → jest/RTL migration — enzyme mounted them and poked class internals, so the rewrites re-express those assertions as DOM and behavior checks.

How Has This Been Tested?

npx jest --selectProjects unit over the migrated suites on this branch: 12 suites / 153 tests pass. No application source changes — test files only.

Checklist:

  • All new and existing tests passed.

@claude

claude Bot commented Jul 13, 2026

Copy link
Copy Markdown

Claude finished @jonathangreen's task in 5m 21s —— View job


Code Review

  • Read changed test files
  • Compared against deleted enzyme suites for coverage gaps
  • Checked RTL/userEvent conventions and correctness
  • Posted review

Summary

This is a clean, faithful enzyme→RTL migration. I read all 12 suites and cross-checked the trickiest ones (IndividualAdminEditForm, Header, AnnouncementForm/AnnouncementsSection, NeighborhoodAnalyticsForm, TextWithEditMode, DiscoveryServices) against their component sources and against the deleted enzyme tests. The rewrites are consistently stronger than the originals: state()/instance() pokes become DOM and ref-API assertions, prototype stubs become real userEvent.type reads through the components' ref APIs, and connected default exports are rendered so mapStateToProps/mapDispatchToProps stay covered. No behavior coverage is lost (e.g. the AnnouncementsSection add/edit/delete/temp-id cases and ToolTip show/hide are all preserved and now verified through the DOM), the shared FormData shim is correctly modeled on "successful controls," and the added comments explaining fireEvent vs userEvent choices (readOnly guard, alt+click, date inputs) are accurate. Codecov confirms a net coverage increase with no source changes. I found no correctness issues, no false-confidence assertions, and nothing blocking — no changes recommended.
· rtl-admin-misc

@greptile-apps

greptile-apps Bot commented Jul 13, 2026

Copy link
Copy Markdown

Greptile Summary

This PR moves several legacy Enzyme component suites to React Testing Library. The main changes are:

  • Deleted legacy tests under src/components/__tests__.
  • Added RTL/Jest tests under tests/jest/components.
  • Reworked admin, announcement, discovery, header, form primitive, and tooltip coverage around DOM behavior and user interactions.

Confidence Score: 5/5

This looks safe to merge.

  • No blocking issues found in the changed code.

Important Files Changed

Filename Overview
tests/jest/components/IndividualAdminEditForm.test.tsx Rewrites admin edit form tests around rendered fields, role controls, password behavior, and save flows.
tests/jest/components/IndividualAdmins.test.tsx Updates individual admin tests with RTL coverage for rendering, role display, and connected behavior.
tests/jest/components/AnnouncementForm.test.tsx Adds RTL coverage for announcement form rendering, validation, add, edit, cancel, and reset behavior.
tests/jest/components/AnnouncementsSection.test.tsx Adds RTL coverage for announcement list rendering, add, edit, delete, and value serialization behavior.
tests/jest/components/ChangePasswordForm.test.tsx Rewrites password form tests around visible errors, loading state, validation, submission, and success feedback.
tests/jest/components/DiscoveryServices.test.tsx Expands discovery service tests around connected rendering, registration, and interaction flows.
tests/jest/components/Header.test.tsx Adds RTL coverage for header links, library selection, permissions display, and account menu behavior.
tests/jest/components/EditableInput.test.tsx Updates editable input tests around accessibility, value changes, ref methods, prop updates, and error states.

Reviews (2): Last reviewed commit: "Rewrite admin, announcement and shared-p..." | Re-trigger Greptile

@codecov-commenter

codecov-commenter commented Jul 13, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.28%. Comparing base (9fdb519) to head (900ed9f).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #321      +/-   ##
==========================================
+ Coverage   90.14%   90.28%   +0.14%     
==========================================
  Files         205      205              
  Lines        7610     7610              
  Branches     1664     1664              
==========================================
+ Hits         6860     6871      +11     
+ Misses        437      430       -7     
+ Partials      313      309       -4     
Flag Coverage Δ
jest 90.28% <ø> (+0.14%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@jonathangreen jonathangreen requested a review from a team July 13, 2026 14:27
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