diff --git a/.changeset/virtual-list-testid.md b/.changeset/virtual-list-testid.md new file mode 100644 index 0000000..ed59c7c --- /dev/null +++ b/.changeset/virtual-list-testid.md @@ -0,0 +1,6 @@ +--- +'@plextv/react-lightning': patch +'@plextv/react-lightning-components': patch +--- + +`VirtualList` forwards `testID` to its outer container. Its props were a closed interface with no `testID`, so the prop was dropped and never reached an element, which left any screen whose root is a `VirtualList` invisible to test tooling that matches on it. `testID` is also declared on `LightningViewElementProps` now, since the react-native compat layer already passed it through untyped and the element treats it as inert. diff --git a/packages/react-lightning-components/src/components/VirtualList/VirtualList.tsx b/packages/react-lightning-components/src/components/VirtualList/VirtualList.tsx index 4f6035f..d69b5d6 100644 --- a/packages/react-lightning-components/src/components/VirtualList/VirtualList.tsx +++ b/packages/react-lightning-components/src/components/VirtualList/VirtualList.tsx @@ -121,6 +121,7 @@ function VirtualListInner( extraData, contentContainerStyle, style, + testID, ListHeaderComponent, listHeaderSize = 0, ListFooterComponent, @@ -891,6 +892,7 @@ function VirtualListInner( allowOffscreen={true} autoFocus={autoFocus} style={outerStyle} + testID={testID} trapFocusDown={trapFocusDown} trapFocusLeft={trapFocusLeft} trapFocusRight={trapFocusRight} diff --git a/packages/react-lightning-components/src/components/VirtualList/VirtualListTypes.ts b/packages/react-lightning-components/src/components/VirtualList/VirtualListTypes.ts index 77d0a10..b5c39a7 100644 --- a/packages/react-lightning-components/src/components/VirtualList/VirtualListTypes.ts +++ b/packages/react-lightning-components/src/components/VirtualList/VirtualListTypes.ts @@ -92,6 +92,8 @@ export interface VirtualListProps { contentContainerStyle?: ContentStyle; /** Style for the outer list container. Must include w and h. */ style?: LightningViewElementStyle; + /** Forwarded to the outer container so test tooling can find the list. */ + testID?: string; /** Component rendered before the first item. */ ListHeaderComponent?: ComponentType | ReactElement | null; diff --git a/packages/react-lightning/src/types/Props.ts b/packages/react-lightning/src/types/Props.ts index 793f3a1..5974d11 100644 --- a/packages/react-lightning/src/types/Props.ts +++ b/packages/react-lightning/src/types/Props.ts @@ -55,6 +55,8 @@ export interface LightningViewElementProps< rtt?: boolean; children?: ReactNode | null; style?: TStyleProps | null; + /** Inert at render time, but the inspector mirrors it for test tooling. */ + testID?: string; } export type LightningImageElementProps<