From 0aeb26bdfc11f4a0dcd62d3cade3bbfac50b15bc Mon Sep 17 00:00:00 2001 From: Ruslan Shestopalyuk Date: Fri, 8 Aug 2025 10:02:57 -0700 Subject: [PATCH] e2e test for Text.role (#53176) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/53176 # Changelog: [Internal] - As in the title Reviewed By: andrewdacenko Differential Revision: D79891116 fbshipit-source-id: 13042a9b82373b8e0073c8421e532e6e463d60f8 --- .../Libraries/Text/__tests__/Text-itest.js | 110 ++++++++++++++++++ 1 file changed, 110 insertions(+) diff --git a/packages/react-native/Libraries/Text/__tests__/Text-itest.js b/packages/react-native/Libraries/Text/__tests__/Text-itest.js index c640d35a7a2..fd000d156f4 100644 --- a/packages/react-native/Libraries/Text/__tests__/Text-itest.js +++ b/packages/react-native/Libraries/Text/__tests__/Text-itest.js @@ -11,6 +11,7 @@ import '@react-native/fantom/src/setUpDefaultReactNativeEnvironment'; +import type {Role} from '../../Components/View/ViewAccessibility'; import type {HostInstance} from 'react-native'; import ensureInstance from '../../../src/private/__tests__/utilities/ensureInstance'; @@ -244,6 +245,115 @@ describe('', () => { }); }); + describe('role', () => { + it(`has none by default`, () => { + const root = Fantom.createRoot(); + + Fantom.runTask(() => { + root.render({TEST_TEXT}); + }); + + expect(root.getRenderedOutput({props: ['role']}).toJSX()).toEqual( + {TEST_TEXT}, + ); + }); + + it(`maps invalid values to 'none'`, () => { + const root = Fantom.createRoot(); + + Fantom.runTask(() => { + // $FlowExpectedError[incompatible-type] + root.render({TEST_TEXT}); + }); + + expect(root.getRenderedOutput({props: ['role']}).toJSX()).toEqual( + {TEST_TEXT}, + ); + }); + + it(`propagates correctly all possible values`, () => { + const root = Fantom.createRoot(); + ( + [ + 'alert', + 'alertdialog', + 'application', + 'article', + 'banner', + 'button', + 'cell', + 'checkbox', + 'columnheader', + 'combobox', + 'complementary', + 'contentinfo', + 'definition', + 'dialog', + 'directory', + 'document', + 'feed', + 'figure', + 'form', + 'grid', + 'group', + 'heading', + 'img', + 'link', + 'list', + 'listitem', + 'log', + 'main', + 'marquee', + 'math', + 'menu', + 'menubar', + 'menuitem', + 'meter', + 'navigation', + 'none', + 'note', + 'option', + 'presentation', + 'progressbar', + 'radio', + 'radiogroup', + 'region', + 'row', + 'rowgroup', + 'rowheader', + 'scrollbar', + 'searchbox', + 'separator', + 'slider', + 'spinbutton', + 'status', + 'summary', + 'switch', + 'tab', + 'table', + 'tablist', + 'tabpanel', + 'term', + 'timer', + 'toolbar', + 'tooltip', + 'tree', + 'treegrid', + 'treeitem', + 'treeitem', + ] as Array + ).forEach(propVal => { + Fantom.runTask(() => { + root.render({TEST_TEXT}); + }); + + expect(root.getRenderedOutput({props: ['role']}).toJSX()).toEqual( + {TEST_TEXT}, + ); + }); + }); + }); + describe('selectable', () => { it(`can be set to "true"`, () => { const root = Fantom.createRoot();