From eb1890741819ec9d593189460fd5797775d1c3e2 Mon Sep 17 00:00:00 2001 From: Jules Rosser Date: Mon, 24 Nov 2025 12:14:27 -0800 Subject: [PATCH 1/3] Add missing useNavigation mock to BaseSelectionListSectionsTest --- tests/unit/BaseSelectionListSectionsTest.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/unit/BaseSelectionListSectionsTest.tsx b/tests/unit/BaseSelectionListSectionsTest.tsx index a80d60fb531b..c4f8c74739cd 100644 --- a/tests/unit/BaseSelectionListSectionsTest.tsx +++ b/tests/unit/BaseSelectionListSectionsTest.tsx @@ -43,6 +43,7 @@ jest.mock('@react-navigation/native', () => { ...actualNav, useIsFocused: jest.fn(), useFocusEffect: jest.fn(), + useNavigation: jest.fn(), }; }); From c5da3cd120b979045ac813af4600266c54322913 Mon Sep 17 00:00:00 2001 From: Jules Rosser Date: Mon, 24 Nov 2025 13:18:18 -0800 Subject: [PATCH 2/3] Fix flaky test by using specific action type instead of random MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- tests/unit/OptionsListUtilsTest.tsx | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/tests/unit/OptionsListUtilsTest.tsx b/tests/unit/OptionsListUtilsTest.tsx index e0b95a367c85..a2c224593a64 100644 --- a/tests/unit/OptionsListUtilsTest.tsx +++ b/tests/unit/OptionsListUtilsTest.tsx @@ -1394,7 +1394,10 @@ describe('OptionsListUtils', () => { // Given a report without reportID (so it uses the lastReportAction) const report: Report | undefined = undefined; const lastActorDetails = PERSONAL_DETAILS['3']; - const lastAction = createRandomReportAction(1); + const lastAction = { + ...createRandomReportAction(1), + actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, + }; // When we call shouldShowLastActorDisplayName with all valid conditions const result = shouldShowLastActorDisplayName(report, lastActorDetails, lastAction); @@ -1406,7 +1409,10 @@ describe('OptionsListUtils', () => { // Given a report without reportID (so it uses the lastReportAction) const report: Report | undefined = undefined; const lastActorDetails = PERSONAL_DETAILS['2']; - const lastAction = createRandomReportAction(1); + const lastAction = { + ...createRandomReportAction(1), + actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, + }; const result = shouldShowLastActorDisplayName(report, lastActorDetails, lastAction); expect(result).toBe(true); @@ -1417,7 +1423,10 @@ describe('OptionsListUtils', () => { // Given a report without reportID const report: Report | undefined = undefined; const lastActorDetails = PERSONAL_DETAILS['2']; - const lastAction = createRandomReportAction(1); + const lastAction = { + ...createRandomReportAction(1), + actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, + }; // When we call shouldShowLastActorDisplayName with the current user as last actor const result = shouldShowLastActorDisplayName(report, lastActorDetails, lastAction); From b011b7e41454fb3f287847e4a8deba84a3971806 Mon Sep 17 00:00:00 2001 From: Jules Rosser Date: Mon, 24 Nov 2025 13:39:33 -0800 Subject: [PATCH 3/3] Update useNavigation mock to return isFocused method MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- tests/unit/BaseSelectionListSectionsTest.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/unit/BaseSelectionListSectionsTest.tsx b/tests/unit/BaseSelectionListSectionsTest.tsx index c4f8c74739cd..58b11fd7e53a 100644 --- a/tests/unit/BaseSelectionListSectionsTest.tsx +++ b/tests/unit/BaseSelectionListSectionsTest.tsx @@ -43,7 +43,9 @@ jest.mock('@react-navigation/native', () => { ...actualNav, useIsFocused: jest.fn(), useFocusEffect: jest.fn(), - useNavigation: jest.fn(), + useNavigation: jest.fn(() => ({ + isFocused: jest.fn(() => true), + })), }; });