Skip to content

refactor(state): delete the useApp() merged view and migrate tests to domain hooks - #418

Open
NesiciCoding wants to merge 1 commit into
perf/selector-storefrom
chore/remove-useapp-hook
Open

refactor(state): delete the useApp() merged view and migrate tests to domain hooks#418
NesiciCoding wants to merge 1 commit into
perf/selector-storefrom
chore/remove-useapp-hook

Conversation

@NesiciCoding

@NesiciCoding NesiciCoding commented Aug 11, 2026

Copy link
Copy Markdown
Owner

What

Deletes useApp() — the merged view that spread all seven domain contexts into one value — and migrates every remaining test call site to the domain hooks.

  • AppContext.tsx: the hook and its only import consumer (AppContextValue) are gone; domain-hook imports narrow to just the Provider components (the hooks are re-exported separately).
  • Context tests (AppContext.test.tsx, AppContext.extended.test.tsx, dyslexiaMode.test.tsx, themeBundleApply.test.tsx): each renderHook(() => useApp(), ...) becomes renderHook(() => useRoster(), ...) or a small composition like ({ ...useRoster(), ...useAuthoring() }) covering exactly the domains that test exercises.
  • 57 shared vi.mock('.../AppContext') factories in page/component suites: the now-nonexistent useApp export is dropped; the domain-hook mocks are untouched.
  • Comments referencing useApp() updated.

Why

useApp() merged every domain context, so a single dispatch re-rendered all of its consumers — the exact whole-app re-render the domain split and the selector store exist to prevent. Zero production call sites remained (the #414 ESLint rule enforced that), so the hook was pure regression-trap surface. Deleting it forces every consumer — including tests — to name the domain(s) they actually use.

Verification

  • tsc --noEmit clean, npm run lint 0 errors (159 warnings, at/below the pre-change baseline).
  • Full suite: 213 files / 2,863 tests pass.
  • grep -rn "useApp" src0 matches.

Summary by CodeRabbit

  • Refactor

    • Replaced the consolidated application context access with focused, domain-specific context hooks.
    • Removed obsolete context access from internal test setups.
  • Tests

    • Updated context, component, page, accessibility, and interaction tests to use the focused hooks.
    • Preserved existing test behavior and assertions while aligning mocks with the updated context structure.

… domain hooks

useApp() merged every domain context into one value, so a single dispatch
re-rendered all of its consumers — the exact whole-app re-render the domain
split and selector store exist to prevent. App code was already migrated to
the domain hooks (useRoster, useAuthoring, ...), leaving useApp() as a
regression trap with no remaining production call sites.

Delete the hook and its AppContextValue-only import, and migrate the test
suite off it:

- Context tests (AppContext, AppContext.extended, dyslexiaMode,
  themeBundleApply) now render each case against exactly the domain hooks it
  exercises, e.g. renderHook(() => useRoster()) or a two-hook composition
  like ({ ...useRoster(), ...useAuthoring() }) — which also makes each test's
  domain dependency explicit instead of silently subscribing to all seven.
- All 57 shared vi.mock('.../AppContext') factories in page/component suites
  drop the now-nonexistent useApp export; their domain-hook mocks are
  unchanged.
- Comments referencing useApp() updated to describe the domain hooks.

The domain-hook imports in AppContext.tsx are narrowed to just the Provider
components (the hooks are re-exported separately), removing the last unused
imports. Verified: tsc --noEmit clean, eslint 0 errors, and all 2,863 tests
pass with zero useApp references remaining anywhere in src.

Generated with Codebuff 🤖
Co-Authored-By: Codebuff <noreply@codebuff.com>
@coderabbitai

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 8a3d4c8e-a837-46c7-9fb9-ed0f28eb75e0

📥 Commits

Reviewing files that changed from the base of the PR and between 35d4942 and cb253af.

📒 Files selected for processing (62)
  • src/components/Comments/__tests__/CommentBankManager.test.tsx
  • src/components/Comments/__tests__/CommentBankModal.test.tsx
  • src/components/Layout/__tests__/Sidebar.test.tsx
  • src/components/Layout/__tests__/Topbar.test.tsx
  • src/components/Students/__tests__/CsvImportModal.test.tsx
  • src/components/Students/__tests__/StudentDecksSection.test.tsx
  • src/components/Tests/__tests__/QuestionBankItemEditorModal.test.tsx
  • src/components/Tests/__tests__/QuestionBankManager.test.tsx
  • src/components/Tests/__tests__/QuestionBankSectionEditor.test.tsx
  • src/components/Tests/__tests__/QuestionEditor.test.tsx
  • src/components/Tests/__tests__/TestAssignmentModal.test.tsx
  • src/components/__tests__/GlobalSearch.test.tsx
  • src/components/__tests__/StandardsPickerModal.test.tsx
  • src/components/__tests__/components.smoke.test.tsx
  • src/components/__tests__/components.untested.test.tsx
  • src/context/AppContext.extended.test.tsx
  • src/context/AppContext.test.tsx
  • src/context/AppContext.tsx
  • src/context/dyslexiaMode.test.tsx
  • src/context/themeBundleApply.test.tsx
  • src/hooks/__tests__/hooks.test.ts
  • src/hooks/useNotificationFeed.test.ts
  • src/pages/__tests__/ActivityDashboardPage.test.tsx
  • src/pages/__tests__/AttachmentsPage.test.tsx
  • src/pages/__tests__/ComparativeGrading.test.tsx
  • src/pages/__tests__/DocsPage.test.tsx
  • src/pages/__tests__/EssayBuilderPage.test.tsx
  • src/pages/__tests__/EssayListPage.test.tsx
  • src/pages/__tests__/ExportPage.test.tsx
  • src/pages/__tests__/GradeStudent.test.tsx
  • src/pages/__tests__/LiveMonitorPage.test.tsx
  • src/pages/__tests__/MarketplacePage.test.tsx
  • src/pages/__tests__/MessagesPage.test.tsx
  • src/pages/__tests__/ModerationQueuePage.test.tsx
  • src/pages/__tests__/NotificationsPage.test.tsx
  • src/pages/__tests__/PeerReviewAnalyticsPage.test.tsx
  • src/pages/__tests__/PeerReviewView.test.tsx
  • src/pages/__tests__/RubricBuilder.test.tsx
  • src/pages/__tests__/RubricList.test.tsx
  • src/pages/__tests__/SelfAssessPage.test.tsx
  • src/pages/__tests__/SettingsPage.test.tsx
  • src/pages/__tests__/SpeakingSession.test.tsx
  • src/pages/__tests__/StatisticsPage.test.tsx
  • src/pages/__tests__/StudentLearningPathPage.test.tsx
  • src/pages/__tests__/StudentPortalPage.test.tsx
  • src/pages/__tests__/StudentProfilePage.test.tsx
  • src/pages/__tests__/StudentsPage.test.tsx
  • src/pages/__tests__/TestBuilderPage.test.tsx
  • src/pages/__tests__/TestListPage.test.tsx
  • src/pages/__tests__/TestResultsPage.test.tsx
  • src/pages/__tests__/VocabularyDashboardPage.test.tsx
  • src/pages/__tests__/pages-phase4.a11y.test.tsx
  • src/pages/__tests__/pages.a11y.test.tsx
  • src/pages/__tests__/pages.admin.a11y.test.tsx
  • src/pages/__tests__/pages.deepcoverage.test.tsx
  • src/pages/__tests__/pages.deepcoverage2.test.tsx
  • src/pages/__tests__/pages.functions.test.tsx
  • src/pages/__tests__/pages.interaction.test.tsx
  • src/pages/__tests__/pages.missing.test.tsx
  • src/pages/__tests__/pages.smoke.test.tsx
  • src/pages/__tests__/pages.student.a11y.test.tsx
  • src/pages/__tests__/pages.unit.test.tsx
💤 Files with no reviewable changes (48)
  • src/pages/tests/LiveMonitorPage.test.tsx
  • src/components/tests/GlobalSearch.test.tsx
  • src/pages/tests/pages.interaction.test.tsx
  • src/components/Comments/tests/CommentBankManager.test.tsx
  • src/components/tests/StandardsPickerModal.test.tsx
  • src/components/tests/components.smoke.test.tsx
  • src/pages/tests/StudentLearningPathPage.test.tsx
  • src/components/Tests/tests/QuestionBankItemEditorModal.test.tsx
  • src/components/Layout/tests/Topbar.test.tsx
  • src/hooks/useNotificationFeed.test.ts
  • src/pages/tests/ModerationQueuePage.test.tsx
  • src/pages/tests/DocsPage.test.tsx
  • src/pages/tests/TestResultsPage.test.tsx
  • src/pages/tests/pages.unit.test.tsx
  • src/components/Students/tests/StudentDecksSection.test.tsx
  • src/pages/tests/TestListPage.test.tsx
  • src/pages/tests/AttachmentsPage.test.tsx
  • src/pages/tests/SelfAssessPage.test.tsx
  • src/pages/tests/EssayListPage.test.tsx
  • src/components/Tests/tests/QuestionBankSectionEditor.test.tsx
  • src/pages/tests/RubricList.test.tsx
  • src/pages/tests/pages.smoke.test.tsx
  • src/components/Layout/tests/Sidebar.test.tsx
  • src/pages/tests/SpeakingSession.test.tsx
  • src/components/Tests/tests/TestAssignmentModal.test.tsx
  • src/pages/tests/MarketplacePage.test.tsx
  • src/components/Comments/tests/CommentBankModal.test.tsx
  • src/pages/tests/VocabularyDashboardPage.test.tsx
  • src/pages/tests/pages.deepcoverage2.test.tsx
  • src/pages/tests/EssayBuilderPage.test.tsx
  • src/pages/tests/pages.functions.test.tsx
  • src/pages/tests/ExportPage.test.tsx
  • src/components/Tests/tests/QuestionEditor.test.tsx
  • src/pages/tests/ActivityDashboardPage.test.tsx
  • src/pages/tests/pages.deepcoverage.test.tsx
  • src/pages/tests/PeerReviewAnalyticsPage.test.tsx
  • src/pages/tests/pages-phase4.a11y.test.tsx
  • src/pages/tests/PeerReviewView.test.tsx
  • src/pages/tests/pages.missing.test.tsx
  • src/pages/tests/TestBuilderPage.test.tsx
  • src/components/tests/components.untested.test.tsx
  • src/pages/tests/RubricBuilder.test.tsx
  • src/pages/tests/StudentPortalPage.test.tsx
  • src/pages/tests/StudentProfilePage.test.tsx
  • src/pages/tests/MessagesPage.test.tsx
  • src/components/Tests/tests/QuestionBankManager.test.tsx
  • src/pages/tests/StudentsPage.test.tsx
  • src/components/Students/tests/CsvImportModal.test.tsx

📝 Walkthrough

Walkthrough

The merged useApp hook was removed from AppContext. Direct tests and shared mocks now use domain-specific hooks such as useRoster, useAuthoring, useAssessment, and useSettings.

Changes

AppContext hook migration

Layer / File(s) Summary
Context API and direct tests
src/context/AppContext.tsx, src/context/AppContext*.test.tsx, src/context/*Mode.test.tsx, src/context/themeBundleApply.test.tsx
Removed the merged useApp export. Updated direct context tests to consume domain-specific hooks.
Component and hook test mocks
src/components/**/__tests__/*, src/hooks/**
Removed useApp mocks and added or retained specialized context-hook mocks.
Page test mocks
src/pages/__tests__/*
Updated page, accessibility, smoke, and coverage mocks to use domain-specific hooks and shared mock state.

Estimated code review effort: 2 (Simple) | ~10 minutes

Poem

I’m a rabbit with hooks in a row,
useApp hops out, domains now flow.
Roster and settings sit neatly apart,
Authoring and assessment each play their part.
Test mocks now burrow with care.

🚥 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 summarizes the removal of useApp() and migration of tests to domain-specific hooks.
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.
✨ 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 chore/remove-useapp-hook

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.

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