-
Notifications
You must be signed in to change notification settings - Fork 24.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate FlatList/SectionList from Catalyst to RNTester
Summary: **Context** - RNTester can be built for ios/android on new/legacy arch - We are migrating all our catalyst rntester E2E tests to rntester standalone - [Here is a list](https://docs.google.com/document/d/16ga5R-c2kBx_l2ATTcHL7aJiSSt3eEXQV9tD4MvSb4Q) of E2E tests w/ `coverages: ["internal"]` - The FlatList/Section list tests were never run on RNTester. These were only accessible via the Catalyst E2E test landing page {F1835450142} **Change** - Migrate FlatList/SectionList from Catalyst to RNTester - Fix deeplinks for rntester (remove `viewability-` prefix) - Add a `isE2ETestCase` flag for these test cases since we don't want to show all these similar versions in the UI |without flag|with flag| |{F1835455698}| {F1835488548} | NOTE: There are some flakey rntester e2e tests. Will do my best to forward fix or disable if they cause too much churn. Differential Revision: D62002065
- Loading branch information
1 parent
d055efd
commit 5ff8a19
Showing
20 changed files
with
546 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
packages/rn-tester/js/examples/FlatList/FlatList-onViewableItemsChanged-default.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/** | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* @format | ||
* @flow | ||
*/ | ||
|
||
'use strict'; | ||
|
||
import type {RNTesterModuleExample} from '../../types/RNTesterTypes'; | ||
|
||
import {FlatList_onViewableItemsChanged_base} from 'FlatList-onViewableItemsChanged-base'; | ||
import * as React from 'react'; | ||
|
||
const VIEWABILITY_CONFIG_WAIT_FOR_INTERACTION = { | ||
minimumViewTime: 1000, | ||
viewAreaCoveragePercentThreshold: 100, | ||
waitForInteraction: true, | ||
}; | ||
|
||
export default ({ | ||
title: 'FlatList onViewableItemsChanged', | ||
name: 'onViewableItemsChanged-waitForInteraction', | ||
description: 'Test onViewableItemsChanged behavior', | ||
render: () => ( | ||
<FlatList_onViewableItemsChanged_base | ||
viewabilityConfig={VIEWABILITY_CONFIG_WAIT_FOR_INTERACTION} | ||
/> | ||
), | ||
}: RNTesterModuleExample); |
35 changes: 35 additions & 0 deletions
35
...es/rn-tester/js/examples/FlatList/FlatList-onViewableItemsChanged-horizontal-offScreen.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/** | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* @format | ||
* @flow | ||
*/ | ||
|
||
'use strict'; | ||
|
||
import type {RNTesterModuleExample} from '../../types/RNTesterTypes'; | ||
|
||
import {FlatList_onViewableItemsChanged_base} from 'FlatList-onViewableItemsChanged-base'; | ||
import * as React from 'react'; | ||
|
||
const VIEWABILITY_CONFIG_WAIT_FOR_INTERACTION = { | ||
minimumViewTime: 1000, | ||
viewAreaCoveragePercentThreshold: 100, | ||
waitForInteraction: true, | ||
}; | ||
|
||
export default ({ | ||
title: 'onViewableItemsChanged', | ||
name: 'onViewableItemsChanged-horizontal', | ||
description: 'E2E Testing:\nonViewableItemsChanged-horizontal', | ||
isE2ETestCase: true, | ||
render: () => ( | ||
<FlatList_onViewableItemsChanged_base | ||
horizontal | ||
viewabilityConfig={VIEWABILITY_CONFIG_WAIT_FOR_INTERACTION} | ||
/> | ||
), | ||
}: RNTesterModuleExample); |
36 changes: 36 additions & 0 deletions
36
...ter/js/examples/FlatList/FlatList-onViewableItemsChanged-horizontal-waitForInteraction.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/** | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* @format | ||
* @flow | ||
*/ | ||
|
||
'use strict'; | ||
|
||
import type {RNTesterModuleExample} from '../../types/RNTesterTypes'; | ||
|
||
import {FlatList_onViewableItemsChanged_base} from 'FlatList-onViewableItemsChanged-base'; | ||
import * as React from 'react'; | ||
|
||
const VIEWABILITY_CONFIG_WAIT_FOR_INTERACTION = { | ||
minimumViewTime: 1000, | ||
viewAreaCoveragePercentThreshold: 100, | ||
waitForInteraction: true, | ||
}; | ||
|
||
export default ({ | ||
title: 'onViewableItemsChanged', | ||
name: 'onViewableItemsChanged-horizontal-waitForInteraction', | ||
description: | ||
'E2E Testing:\nonViewableItemsChanged-horizontal-waitForInteraction', | ||
isE2ETestCase: true, | ||
render: () => ( | ||
<FlatList_onViewableItemsChanged_base | ||
horizontal | ||
viewabilityConfig={VIEWABILITY_CONFIG_WAIT_FOR_INTERACTION} | ||
/> | ||
), | ||
}: RNTesterModuleExample); |
35 changes: 35 additions & 0 deletions
35
packages/rn-tester/js/examples/FlatList/FlatList-onViewableItemsChanged-horizontal.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/** | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* @format | ||
* @flow | ||
*/ | ||
|
||
'use strict'; | ||
|
||
import type {RNTesterModuleExample} from '../../types/RNTesterTypes'; | ||
|
||
import {FlatList_onViewableItemsChanged_base} from 'FlatList-onViewableItemsChanged-base'; | ||
import * as React from 'react'; | ||
|
||
const VIEWABILITY_CONFIG_WAIT_FOR_INTERACTION = { | ||
minimumViewTime: 1000, | ||
viewAreaCoveragePercentThreshold: 100, | ||
waitForInteraction: true, | ||
}; | ||
|
||
export default ({ | ||
title: 'onViewableItemsChanged', | ||
name: 'onViewableItemsChanged-horizontal', | ||
description: 'E2E Testing:\nonViewableItemsChanged-horizontal', | ||
isE2ETestCase: true, | ||
render: () => ( | ||
<FlatList_onViewableItemsChanged_base | ||
horizontal | ||
viewabilityConfig={VIEWABILITY_CONFIG_WAIT_FOR_INTERACTION} | ||
/> | ||
), | ||
}: RNTesterModuleExample); |
34 changes: 34 additions & 0 deletions
34
...es/rn-tester/js/examples/FlatList/FlatList-onViewableItemsChanged-noWaitForInteraction.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/** | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* @format | ||
* @flow | ||
*/ | ||
|
||
'use strict'; | ||
|
||
import type {RNTesterModuleExample} from '../../types/RNTesterTypes'; | ||
|
||
import {FlatList_onViewableItemsChanged_base} from 'FlatList-onViewableItemsChanged-base'; | ||
import * as React from 'react'; | ||
|
||
const VIEWABILITY_CONFIG_NO_WAIT_FOR_INTERACTION = { | ||
minimumViewTime: 1000, | ||
viewAreaCoveragePercentThreshold: 100, | ||
waitForInteraction: false, | ||
}; | ||
|
||
export default ({ | ||
title: 'onViewableItemsChanged', | ||
name: 'onViewableItemsChanged_noWaitForInteraction', | ||
description: 'E2E Testing:\nonViewableItemsChanged-noWaitForInteraction', | ||
isE2ETestCase: true, | ||
render: () => ( | ||
<FlatList_onViewableItemsChanged_base | ||
viewabilityConfig={VIEWABILITY_CONFIG_NO_WAIT_FOR_INTERACTION} | ||
/> | ||
), | ||
}: RNTesterModuleExample); |
35 changes: 35 additions & 0 deletions
35
packages/rn-tester/js/examples/FlatList/FlatList-onViewableItemsChanged-offScreen.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/** | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* @format | ||
* @flow | ||
*/ | ||
|
||
'use strict'; | ||
|
||
import type {RNTesterModuleExample} from '../../types/RNTesterTypes'; | ||
|
||
import {FlatList_onViewableItemsChanged_base} from 'FlatList-onViewableItemsChanged-base'; | ||
import * as React from 'react'; | ||
|
||
const VIEWABILITY_CONFIG_WAIT_FOR_INTERACTION = { | ||
minimumViewTime: 1000, | ||
viewAreaCoveragePercentThreshold: 100, | ||
waitForInteraction: true, | ||
}; | ||
|
||
export default ({ | ||
title: 'onViewableItemsChanged', | ||
name: 'onViewableItemsChanged-offScreen', | ||
description: 'E2E Testing:\nonViewableItemsChanged-offScreen', | ||
isE2ETestCase: true, | ||
render: () => ( | ||
<FlatList_onViewableItemsChanged_base | ||
offScreen | ||
viewabilityConfig={VIEWABILITY_CONFIG_WAIT_FOR_INTERACTION} | ||
/> | ||
), | ||
}: RNTesterModuleExample); |
34 changes: 34 additions & 0 deletions
34
...ages/rn-tester/js/examples/FlatList/FlatList-onViewableItemsChanged-waitForInteraction.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/** | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* @format | ||
* @flow | ||
*/ | ||
|
||
'use strict'; | ||
|
||
import type {RNTesterModuleExample} from '../../types/RNTesterTypes'; | ||
|
||
import {FlatList_onViewableItemsChanged_base} from 'FlatList-onViewableItemsChanged-base'; | ||
import * as React from 'react'; | ||
|
||
const VIEWABILITY_CONFIG_WAIT_FOR_INTERACTION = { | ||
minimumViewTime: 1000, | ||
viewAreaCoveragePercentThreshold: 100, | ||
waitForInteraction: true, | ||
}; | ||
|
||
export default ({ | ||
title: 'onViewableItemsChanged', | ||
name: 'onViewableItemsChanged-waitForInteraction', | ||
description: 'E2E Testing:\nonViewableItemsChanged-waitForInteraction', | ||
isE2ETestCase: true, | ||
render: () => ( | ||
<FlatList_onViewableItemsChanged_base | ||
viewabilityConfig={VIEWABILITY_CONFIG_WAIT_FOR_INTERACTION} | ||
/> | ||
), | ||
}: RNTesterModuleExample); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
packages/rn-tester/js/examples/SectionList/SectionList-onViewableItemsChanged-base.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/** | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* @format | ||
* @flow | ||
*/ | ||
|
||
import type {ViewToken} from 'react-native/Libraries/Lists/ViewabilityHelper'; | ||
|
||
import SectionListBaseExample from './SectionListBaseExample'; | ||
import * as React from 'react'; | ||
import {SectionList, StyleSheet, View} from 'react-native'; | ||
|
||
type SectionListProps = React.ElementProps<typeof SectionList>; | ||
type ViewabilityConfig = $PropertyType<SectionListProps, 'viewabilityConfig'>; | ||
|
||
export function SectionList_onViewableItemsChanged_base(props: { | ||
viewabilityConfig: ViewabilityConfig, | ||
offScreen?: ?boolean, | ||
horizontal?: ?boolean, | ||
useScrollRefScroll?: ?boolean, | ||
}): React.Node { | ||
const {viewabilityConfig, offScreen, horizontal, useScrollRefScroll} = props; | ||
const [output, setOutput] = React.useState(''); | ||
const exampleProps = { | ||
onViewableItemsChanged: (info: { | ||
changed: Array<ViewToken>, | ||
viewableItems: Array<ViewToken>, | ||
... | ||
}) => | ||
setOutput( | ||
info.viewableItems | ||
.filter(viewToken => viewToken.index != null && viewToken.isViewable) | ||
.map(viewToken => viewToken.item) | ||
.join(', '), | ||
), | ||
viewabilityConfig, | ||
horizontal, | ||
}; | ||
const ref = React.useRef<any>(null); | ||
const onTest = | ||
useScrollRefScroll === true | ||
? () => { | ||
ref?.current?.getScrollResponder()?.scrollToEnd(); | ||
} | ||
: null; | ||
|
||
return ( | ||
<SectionListBaseExample | ||
ref={ref} | ||
exampleProps={exampleProps} | ||
onTest={onTest} | ||
testOutput={output}> | ||
{offScreen === true ? <View style={styles.offScreen} /> : null} | ||
</SectionListBaseExample> | ||
); | ||
} | ||
const styles = StyleSheet.create({ | ||
offScreen: { | ||
height: 1000, | ||
}, | ||
}); |
Oops, something went wrong.