Skip to content

Add tests of keyframe animations #6433

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type { ReactNode } from 'react';
import React, { useEffect, useRef, useState } from 'react';
import { runTests, configure } from './RuntimeTestsApi';
import { RenderLock } from './utils/SyncUIRunner';
import { FlatList } from 'react-native-gesture-handler';

export class ErrorBoundary extends React.Component<
{ children: React.JSX.Element | Array<React.JSX.Element> },
Expand Down Expand Up @@ -72,18 +73,18 @@ export default function RuntimeTestsRunner({ tests }: RuntimeTestRunnerProps) {
}

return (
<View style={styles.container}>
<View style={styles.flexOne}>
{started ? null : (
<>
<TestSelector tests={tests} testSelectionCallbacks={testSelectionCallbacks} />
<Pressable onPressOut={handleStartClick} style={styles.button}>
<Text style={styles.buttonTextWhite}>Run tests</Text>
<Text style={styles.whiteText}>Run tests</Text>
</Pressable>
</>
)}
{/* Don't render anything if component is undefined to prevent blinking */}
{component || null}
{finished ? <Text style={styles.reloadText}>Reload the app to run the tests again</Text> : null}
{finished ? <Text style={styles.navyText}>Reload the app to run the tests again</Text> : null}
</View>
);
}
Expand Down Expand Up @@ -122,22 +123,24 @@ function TestSelector({ tests, testSelectionCallbacks }: TestSelectorProps) {
}

return (
<View>
<View style={styles.flexOne}>
<SelectAllButtonProps handleSelectAllClick={selectAllClick} select={true} />
<SelectAllButtonProps handleSelectAllClick={selectAllClick} select={false} />

<View style={styles.selectButtonsFrame}>
{tests.map(testData => {
<FlatList
style={styles.selectButtonsFrame}
data={tests}
renderItem={({ item }) => {
return (
<SelectTest
key={testData.testSuiteName}
testSuiteName={testData.testSuiteName}
selectClick={() => selectClick(testData)}
key={item.testSuiteName}
testSuiteName={item.testSuiteName}
selectClick={() => selectClick(item)}
selectedTests={selectedTests}
/>
);
})}
</View>
}}
/>
</View>
);
}
Expand Down Expand Up @@ -167,7 +170,7 @@ function SelectTest({ testSuiteName, selectClick, selectedTests }: SelectTestPro
onPressOut={() => handleSelectClickOut()}>
<View style={[styles.checkbox, selectedTests.get(testSuiteName) ? styles.checkedCheckbox : {}]} />
<View style={styles.selectButton}>
<Text style={styles.buttonText}>{testSuiteName}</Text>
<Text style={styles.navyText}>{testSuiteName}</Text>
</View>
</Pressable>
);
Expand Down Expand Up @@ -195,26 +198,43 @@ function SelectAllButtonProps({ handleSelectAllClick, select }: SelectAllButtonP
onPressIn={handleSelectAllClickIn}
onPressOut={() => handleSelectAllClickOut()}
style={[styles.selectAllButton, isPressed ? styles.pressedButton : {}]}>
<Text style={styles.buttonText}>{select ? 'Select all' : 'Deselect all'}</Text>
<Text style={styles.navyText}>{select ? 'Select all' : 'Deselect all'}</Text>
</Pressable>
);
}

const TEXT = {
fontSize: 20,
alignSelf: 'center',
} as const;

const BUTTON = {
height: 40,
justifyContent: 'center',
alignItems: 'center',
} as const;

const WHITE_BUTTON = {
...BUTTON,
borderWidth: 2,
backgroundColor: 'white',
borderColor: 'navy',
marginVertical: 5,
borderRadius: 10,
} as const;

const styles = StyleSheet.create({
container: {
flexOne: {
flex: 1,
flexDirection: 'column',
},
selectAllButton: {
marginVertical: 5,
...WHITE_BUTTON,
marginHorizontal: 20,
height: 40,
borderWidth: 2,
borderRadius: 10,
backgroundColor: 'white',
borderColor: 'navy',
justifyContent: 'center',
alignItems: 'center',
},
selectButton: {
...WHITE_BUTTON,
flex: 1,
},
selectButtonsFrame: {
borderRadius: 10,
Expand All @@ -223,30 +243,17 @@ const styles = StyleSheet.create({
paddingHorizontal: 10,
paddingVertical: 10,
},
selectButton: {
height: 40,
borderWidth: 2,
marginVertical: 5,
borderRadius: 10,
backgroundColor: 'white',
borderColor: 'navy',
justifyContent: 'center',
alignItems: 'center',
flex: 1,
},
button: {
height: 40,
...BUTTON,
backgroundColor: 'navy',
justifyContent: 'center',
alignItems: 'center',
zIndex: 1,
},
buttonText: {
fontSize: 20,
navyText: {
...TEXT,
color: 'navy',
},
buttonTextWhite: {
fontSize: 20,
whiteText: {
...TEXT,
color: 'white',
},
buttonWrapper: {
Expand All @@ -266,11 +273,6 @@ const styles = StyleSheet.create({
checkedCheckbox: {
backgroundColor: 'navy',
},
reloadText: {
fontSize: 20,
color: 'navy',
alignSelf: 'center',
},
pressedButton: {
zIndex: 2,
backgroundColor: '#FFFA',
Expand Down
26 changes: 26 additions & 0 deletions apps/common-app/src/examples/RuntimeTests/RuntimeTestsExample.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,31 @@ export default function RuntimeTestsExample() {
require('./tests/utilities/relativeCoords.test');
},
},
{
testSuiteName: 'entering and exiting',
importTest: () => {
require('./tests/layoutAnimations/entering/enteringColors.test');
require('./tests/layoutAnimations/entering/predefinedEntering.test');
require('./tests/layoutAnimations/exiting/predefinedExiting.test');
},
},
{
testSuiteName: 'layout transitions',
importTest: () => {
describe('Compare layout transitions with **constant view size** with snapshots', () => {
require('./tests/layoutAnimations/layout/predefinedLayoutPosition.test');
});
describe('Compare Test layout transitions including view **size changes** with snapshots', () => {
require('./tests/layoutAnimations/layout/positionAndSize.test');
});
},
},
{
testSuiteName: 'keyframe animations',
importTest: () => {
require('./tests/layoutAnimations/keyframe/basic.test');
},
},
{
testSuiteName: 'layoutAnimations',
importTest: () => {
Expand All @@ -66,6 +91,7 @@ export default function RuntimeTestsExample() {
});
},
},

{
testSuiteName: 'advanced API',
importTest: () => {
Expand Down
Loading