Remove persistence from RNTester app (#22596)
Summary: Previously the RNTester app saved what screen you were on and what filter text was entered into the initial screen. This made e2e testing complex, as each test needed to manually restore the state to the home screen. If the state ever got out of sync with the test's expectations, it could lead to multiple failed tests. There is still one specific component that uses persistence: `RNTesterSettingSwitchRow`. Persistence can be removed from this component next time tests for it are updated. As a result, `RNTesterStatePersister` is not yet entirely removed from the app. Pull Request resolved: https://github.com/facebook/react-native/pull/22596 Differential Revision: D13413457 Pulled By: cpojer fbshipit-source-id: 3faa26a94139397b4bce6b62ff43e9c2f870b145
This commit is contained in:
Родитель
794d2264f9
Коммит
33fb70f6b6
|
@ -8,10 +8,11 @@
|
||||||
* @format
|
* @format
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* global element, by, expect */
|
/* global device, element, by, expect */
|
||||||
|
|
||||||
describe('Button', () => {
|
describe('Button', () => {
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
|
await device.reloadReactNative();
|
||||||
await element(by.id('explorer_search')).replaceText('<Button>');
|
await element(by.id('explorer_search')).replaceText('<Button>');
|
||||||
await element(
|
await element(
|
||||||
by.label('<Button> Simple React Native button component.'),
|
by.label('<Button> Simple React Native button component.'),
|
||||||
|
|
|
@ -8,12 +8,13 @@
|
||||||
* @format
|
* @format
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* global element, by, expect */
|
/* global device, element, by, expect */
|
||||||
|
|
||||||
const jestExpect = require('expect');
|
const jestExpect = require('expect');
|
||||||
|
|
||||||
describe('Switch', () => {
|
describe('Switch', () => {
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
|
await device.reloadReactNative();
|
||||||
await element(by.id('explorer_search')).replaceText('<Switch>');
|
await element(by.id('explorer_search')).replaceText('<Switch>');
|
||||||
await element(by.label('<Switch> Native boolean input')).tap();
|
await element(by.label('<Switch> Native boolean input')).tap();
|
||||||
});
|
});
|
||||||
|
|
|
@ -70,17 +70,8 @@ class RNTesterApp extends React.Component<Props, RNTesterNavigationState> {
|
||||||
);
|
);
|
||||||
const urlAction = URIActionMap(url);
|
const urlAction = URIActionMap(url);
|
||||||
const launchAction = exampleAction || urlAction;
|
const launchAction = exampleAction || urlAction;
|
||||||
if (err || !storedString) {
|
const initialAction = launchAction || {type: 'InitialAction'};
|
||||||
const initialAction = launchAction || {type: 'InitialAction'};
|
this.setState(RNTesterNavigationReducer(undefined, initialAction));
|
||||||
this.setState(RNTesterNavigationReducer(undefined, initialAction));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const storedState = JSON.parse(storedString);
|
|
||||||
if (launchAction) {
|
|
||||||
this.setState(RNTesterNavigationReducer(storedState, launchAction));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this.setState(storedState);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -18,13 +18,11 @@ const Text = require('Text');
|
||||||
const TextInput = require('TextInput');
|
const TextInput = require('TextInput');
|
||||||
const TouchableHighlight = require('TouchableHighlight');
|
const TouchableHighlight = require('TouchableHighlight');
|
||||||
const RNTesterActions = require('./RNTesterActions');
|
const RNTesterActions = require('./RNTesterActions');
|
||||||
const RNTesterStatePersister = require('./RNTesterStatePersister');
|
|
||||||
const View = require('View');
|
const View = require('View');
|
||||||
|
|
||||||
/* $FlowFixMe(>=0.78.0 site=react_native_android_fb) This issue was found when
|
/* $FlowFixMe(>=0.78.0 site=react_native_android_fb) This issue was found when
|
||||||
* making Flow check .android.js files. */
|
* making Flow check .android.js files. */
|
||||||
import type {RNTesterExample} from './RNTesterList.ios';
|
import type {RNTesterExample} from './RNTesterList.ios';
|
||||||
import type {PassProps} from './RNTesterStatePersister';
|
|
||||||
import type {TextStyleProp, ViewStyleProp} from 'StyleSheet';
|
import type {TextStyleProp, ViewStyleProp} from 'StyleSheet';
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
|
@ -33,8 +31,6 @@ type Props = {
|
||||||
ComponentExamples: Array<RNTesterExample>,
|
ComponentExamples: Array<RNTesterExample>,
|
||||||
APIExamples: Array<RNTesterExample>,
|
APIExamples: Array<RNTesterExample>,
|
||||||
},
|
},
|
||||||
persister: PassProps<*>,
|
|
||||||
searchTextInputStyle: TextStyleProp,
|
|
||||||
style?: ?ViewStyleProp,
|
style?: ?ViewStyleProp,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -73,8 +69,10 @@ const renderSectionHeader = ({section}) => (
|
||||||
);
|
);
|
||||||
|
|
||||||
class RNTesterExampleList extends React.Component<Props, $FlowFixMeState> {
|
class RNTesterExampleList extends React.Component<Props, $FlowFixMeState> {
|
||||||
|
state = {filter: ''};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const filterText = this.props.persister.state.filter;
|
const filterText = this.state.filter;
|
||||||
let filterRegex = /.*/;
|
let filterRegex = /.*/;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -178,13 +176,13 @@ class RNTesterExampleList extends React.Component<Props, $FlowFixMeState> {
|
||||||
autoCorrect={false}
|
autoCorrect={false}
|
||||||
clearButtonMode="always"
|
clearButtonMode="always"
|
||||||
onChangeText={text => {
|
onChangeText={text => {
|
||||||
this.props.persister.setState(() => ({filter: text}));
|
this.setState(() => ({filter: text}));
|
||||||
}}
|
}}
|
||||||
placeholder="Search..."
|
placeholder="Search..."
|
||||||
underlineColorAndroid="transparent"
|
underlineColorAndroid="transparent"
|
||||||
style={[styles.searchTextInput, this.props.searchTextInputStyle]}
|
style={styles.searchTextInput}
|
||||||
testID="explorer_search"
|
testID="explorer_search"
|
||||||
value={this.props.persister.state.filter}
|
value={this.state.filter}
|
||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
|
@ -199,17 +197,6 @@ const ItemSeparator = ({highlighted}) => (
|
||||||
<View style={highlighted ? styles.separatorHighlighted : styles.separator} />
|
<View style={highlighted ? styles.separatorHighlighted : styles.separator} />
|
||||||
);
|
);
|
||||||
|
|
||||||
/* $FlowFixMe(>=0.85.0 site=react_native_fb) This comment suppresses an error
|
|
||||||
* found when Flow v0.85 was deployed. To see the error, delete this comment
|
|
||||||
* and run Flow. */
|
|
||||||
RNTesterExampleList = RNTesterStatePersister.createContainer(
|
|
||||||
RNTesterExampleList,
|
|
||||||
{
|
|
||||||
cacheKeySuffix: () => 'mainList',
|
|
||||||
getInitialState: () => ({filter: ''}),
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
listContainer: {
|
listContainer: {
|
||||||
flex: 1,
|
flex: 1,
|
||||||
|
|
Загрузка…
Ссылка в новой задаче