Skip to content

test(mobile): stub BackHandler for the to-do list settings sheet - #8475

Merged
iscekic merged 1 commit into
mainfrom
fix/mobile-todo-sheet-backhandler-mock
Oct 21, 2026
Merged

iscekic merged 1 commit into
mainfrom
fix/mobile-todo-sheet-backhandler-mock

Conversation

@iscekic

@iscekic iscekic commented Oct 21, 2026

Copy link
Copy Markdown
Collaborator

Problem

main CI is red: mobile-test (5/8) fails on src/components/todos/todo-list-model-picker.mounted.test.tsx.

Error: [vitest] No "BackHandler" export is defined on the "react-native" mock.
 ❯ src/components/todos/todo-list-settings-sheet.tsx:76:28

The to-do list settings sheet now installs a focus-scoped hardwareBackPress listener (#8249), but the mounted suite's partial react-native mock never exported BackHandler. The merge queue inherits the same failure.

Fix

Add BackHandler to the test's react-native mock, the same stub the other guarded-sheet suites use:

BackHandler: { addEventListener: () => ({ remove: () => undefined }) },

Test-only change.

Verification

  • pnpm vitest run src/components/todos/ — 3 files, 8 tests pass (fails before the change with the error above).
  • oxfmt --list-different clean.

The sheet adds a focus-scoped hardware Back listener, so its mounted
suite's partial react-native mock must export BackHandler.
@iscekic
iscekic enabled auto-merge October 21, 2026 15:50
@iscekic
iscekic added this pull request to the merge queue Oct 21, 2026
Merged via the queue into main with commit 20b489b Oct 21, 2026
46 checks passed
vi.mock('react-native', async () => {
const { NativeTextInput } = await import('./todo-list-model-picker.mounted.test-helpers');
return {
BackHandler: { addEventListener: () => ({ remove: () => undefined }) },

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.

SUGGESTION: Inert stub leaves the hardware-back path unexercised

The stub fixes the mock error, but it never records or invokes the registered handler, so the focus-scoped hardwareBackPress listener added in todo-list-settings-sheet.tsx:76 (register on focus, remove on blur) is now mounted but untested in this suite. tour-screen.mounted.test.tsx:26-58 models BackHandler as a live subscription set precisely so a test can press Back and assert which listeners are registered; adopting the same shape here would let a later test cover the guard without another mock change.

@iscekic
iscekic deleted the fix/mobile-todo-sheet-backhandler-mock branch October 21, 2026 16:04
@kilo-code-bot

kilo-code-bot Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: 1 Issue Found | Recommendation: Address before merge

Executive Summary

The test-only BackHandler stub is correct and matches the existing member-limit-sheet pattern, unblocking the mobile suite; the only note is that the stub is inert, so the new focus-scoped back-press path it mounts remains unexercised.

Assumptions: [INFERENCE] The fix was not run locally in this read-only session; the reported mobile-test (5/8) failure and its resolution are taken from the PR description. No memory-leak risk found: the stub's addEventListener returns a remove function, matching the cleanup in todo-list-settings-sheet.tsx:80-82.

Overview

Severity Count
CRITICAL 0
WARNING 0
SUGGESTION 1
Issue Details (click to expand)

SUGGESTION

File Line Issue
apps/mobile/src/components/todos/todo-list-model-picker.mounted.test.tsx 38 Inert stub records no handler, so the settings sheet's hardwareBackPress registration and remove cleanup are not asserted; tour-screen.mounted.test.tsx shows a live-subscription shape that allows pressing Back.
Files Reviewed (1 file)
  • apps/mobile/src/components/todos/todo-list-model-picker.mounted.test.tsx - 1 issue

Fix these issues in Kilo Cloud


Reviewed by deepseek-flash-latest · Input: 43.1K · Output: 2.7K · Cached: 272.5K

Review guidance: REVIEW.md from base branch main

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