From ef54f74deb598ba6c751c2fba61627280f5cb82c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20Norte?= Date: Tue, 14 Jul 2026 14:33:44 -0700 Subject: [PATCH] Extend Image Fantom tests for alt, aria-label and prefetchWithMetadata (#57549) Summary: Pull Request resolved: https://github.com/react/react-native/pull/57549 Extends `Image-itest.js` with coverage for public `Image` APIs that were previously untested, all exercised through the public `react-native` surface: - the `alt` prop, which maps to `accessibilityLabel` and marks the image accessible; - the `aria-label` prop, which maps to `accessibilityLabel`; and - the `Image.prefetchWithMetadata` static method. Changelog: [Internal] Reviewed By: sammy-SC Differential Revision: D111914101 fbshipit-source-id: c63aaf2df28af7853dc1d75b2ba5ea6fbed894bb --- .../Libraries/Image/__tests__/Image-itest.js | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/packages/react-native/Libraries/Image/__tests__/Image-itest.js b/packages/react-native/Libraries/Image/__tests__/Image-itest.js index 98466bd85f8..33ac94c9456 100644 --- a/packages/react-native/Libraries/Image/__tests__/Image-itest.js +++ b/packages/react-native/Libraries/Image/__tests__/Image-itest.js @@ -620,6 +620,34 @@ describe('', () => { }); }); + describe('alt', () => { + it('is passed as accessibilityLabel and marks the image accessible', () => { + const root = Fantom.createRoot(); + Fantom.runTask(() => { + root.render(a picture); + }); + expect( + root + .getRenderedOutput({props: ['accessibilityLabel', 'accessible']}) + .toJSX(), + ).toEqual( + , + ); + }); + }); + + describe('aria-label', () => { + it('is passed as accessibilityLabel', () => { + const root = Fantom.createRoot(); + Fantom.runTask(() => { + root.render(); + }); + expect( + root.getRenderedOutput({props: ['accessibilityLabel']}).toJSX(), + ).toEqual(); + }); + }); + component TestComponent(testID?: ?string, ...props: AccessibilityProps) { return ; } @@ -1047,6 +1075,24 @@ describe('', () => { }); }); + describe('prefetchWithMetadata', () => { + it('prefetches the image', () => { + const uri = 'https://reactnative.dev/img/tiny_logo.png'; + + NativeFantom.setImageResponse(uri, { + width: 100, + height: 100, + }); + + let result; + Fantom.runTask(async () => { + result = await Image.prefetchWithMetadata(uri, 'queryRootName'); + }); + + expect(result).toEqual(true); + }); + }); + describe('queryCache', () => { it('returns empty when image is not cached', () => { const uri = 'https://reactnative.dev/img/tiny_logo.png';