From 504cf3e9330285ba8995dd938756d2ea13ffa28d Mon Sep 17 00:00:00 2001 From: Zeya Peng Date: Thu, 31 Jul 2025 15:20:54 -0700 Subject: [PATCH] cleanup TODOs in fantom tests around cxxNativeAnimatedRemoveJsSync (#52949) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/52949 ## Changelog: [Internal] [Changed] - cleanup TODOs in fantom tests around cxxNativeAnimatedRemoveJsSync Previous attempt to remove js sync so far is working expectedly since https://github.com/facebook/react-native/pull/52904 / D79080739 Reviewed By: sammy-SC Differential Revision: D79373130 fbshipit-source-id: e310b9250ba5da2e55435468f46b75977e46f111 --- .../Animated/__tests__/Animated-itest.js | 33 ++++++++----------- 1 file changed, 14 insertions(+), 19 deletions(-) diff --git a/packages/react-native/Libraries/Animated/__tests__/Animated-itest.js b/packages/react-native/Libraries/Animated/__tests__/Animated-itest.js index 2093ab8a0a0..c91e7bbc818 100644 --- a/packages/react-native/Libraries/Animated/__tests__/Animated-itest.js +++ b/packages/react-native/Libraries/Animated/__tests__/Animated-itest.js @@ -77,11 +77,10 @@ test('moving box by 100 points', () => { // Animation is completed now. C++ Animated will commit the final position to the shadow tree. if (ReactNativeFeatureFlags.cxxNativeAnimatedRemoveJsSync()) { - // TODO(T223344928,T232605345): this shouldn't be neccessary once we disable JS sync and Android's race condition. + // TODO(T232605345): this shouldn't be neccessary once we fix Android's race condition. Fantom.runWorkLoop(); expect(viewElement.getBoundingClientRect().x).toBe(100); } else { - expect(viewElement.getBoundingClientRect().x).toBe(0); Fantom.runWorkLoop(); // Animated still schedules a React state update for synchronisation to shadow tree expect(viewElement.getBoundingClientRect().x).toBe(100); } @@ -341,19 +340,16 @@ test('moving box by 50 points with offset 10', () => { expect(root.getRenderedOutput({props: ['transform']}).toJSX()).toEqual( , ); - // TODO(T223344928): this shouldn't be neccessary - Fantom.runWorkLoop(); } else { expect(root.getRenderedOutput({props: ['transform']}).toJSX()).toEqual( , ); Fantom.runWorkLoop(); // Animated still schedules a React state update for synchronisation to shadow tree + expect(root.getRenderedOutput({props: ['transform']}).toJSX()).toEqual( + , // // must include offset. + ); } - expect(root.getRenderedOutput({props: ['transform']}).toJSX()).toEqual( - , // // must include offset. - ); - expect(finishValue?.finished).toBe(true); expect(finishValue?.value).toBe(50); // must not include offset. expect(finishValue?.offset).toBe(10); @@ -440,9 +436,6 @@ describe('Value.flattenOffset', () => { Fantom.unstable_getDirectManipulationProps(viewElement).transform[0]; expect(transform.translateY).toBeCloseTo(40, 0.001); - - // TODO(T223344928): this shouldn't be neccessary with cxxNativeAnimatedRemoveJsSync:true - Fantom.runWorkLoop(); }); }); @@ -539,9 +532,6 @@ describe('Value.extractOffset', () => { // `extractOffset` resets value back to 0. // Previously we set offset to 35. The final value is 35. expect(transform.translateY).toBeCloseTo(35, 0.001); - - // TODO(T223344928): this shouldn't be neccessary with cxxNativeAnimatedRemoveJsSync:true - Fantom.runWorkLoop(); }); }); @@ -739,16 +729,21 @@ test('Animated.sequence', () => { expect(_isSequenceFinished).toBe(false); - expect(element.getBoundingClientRect().y).toBe(-16); - expect( // $FlowFixMe[incompatible-use] Fantom.unstable_getDirectManipulationProps(element).transform[0].translateY, ).toBeCloseTo(0, 0.001); - Fantom.runWorkLoop(); // React update to sync end state of 2nd timing animation in sequence - - expect(element.getBoundingClientRect().y).toBe(0); + if (ReactNativeFeatureFlags.cxxNativeAnimatedRemoveJsSync()) { + // TODO(T232605345): The following two lines won't be necessary once race condition on Android is fixed + expect(element.getBoundingClientRect().y).toBe(-16); + Fantom.runWorkLoop(); + expect(element.getBoundingClientRect().y).toBe(0); + } else { + expect(element.getBoundingClientRect().y).toBe(-16); + Fantom.runWorkLoop(); // React update to sync end state of 2nd timing animation in sequence + expect(element.getBoundingClientRect().y).toBe(0); + } expect(_isSequenceFinished).toBe(true); });