Skip to content
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

Implement Text input example use cases and e2e tests #226

Open
wants to merge 3 commits into
base: mlh-fellowship-migrated-ui-changes
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
49 changes: 28 additions & 21 deletions packages/rn-tester/e2e/__tests__/TextInput-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,44 +19,51 @@ describe('TextInput', () => {
await device.reloadReactNative();
await openComponentWithLabel(
'TextInput',
'Single and multi-line text inputs.',
'TextInput A foundational component for inputting text into the app via a keyboard.',
);
});

it('Live rewrite with spaces should replace spaces and enforce max length', async () => {
await openExampleWithTitle('Live Re-Write \\(<sp>');
it('should accept input', async () => {
await openExampleWithTitle('TextInput with autoFocus={true}');

await element(by.id('rewrite_sp_underscore_input')).typeText(
'this is a long sentence',
);
await expect(element(by.id('rewrite_sp_underscore_input'))).toHaveText(
'this_is_a_long_sente',
await element(by.id('check_text_input')).typeText('Check text input');
await expect(element(by.id('check_text_input'))).toHaveText(
'Check text input',
);
});

it('Live rewrite with no spaces should remove spaces', async () => {
await openExampleWithTitle('Live Re-Write \\(no spaces');
it('should not allow spaces in no-spaces-input', async () => {
await openExampleWithTitle(
"TextInput that replaces spaces with underscore '_'",
);

await element(by.id('rewrite_no_sp_input')).typeText(
await element(by.id('rewrite_sp_underscore_input')).typeText(
'this is a long sentence',
);
await expect(element(by.id('rewrite_no_sp_input'))).toHaveText(
'thisisalongsentence',

await expect(element(by.id('rewrite_sp_underscore_input'))).toHaveText(
'this_is_a_long_sentence',
);
});

it('Live rewrite with clear should remove spaces and clear', async () => {
await openExampleWithTitle('and clear');
it('should not exceed maximum length when maxLength is used', async () => {
await openExampleWithTitle('TextInput with maxLength={limit}');

await element(by.id('rewrite_clear_input')).typeText(
'this is a long sentence',
await element(by.id('max_length_input')).typeText(
'this is a very long sentence.',
);
await expect(element(by.id('rewrite_clear_input'))).toHaveText(
'thisisalongsentence',

await expect(element(by.id('max_length_input'))).toHaveText(
'this is a very long ',
);
});

it("should be cleared by tapping 'Clear' button", async () => {
await openExampleWithTitle("TextInput along with 'Clear' button");
await element(by.id('clear_text_input')).typeText(
'this text needs to be cleared',
);
await element(by.id('rewrite_clear_button')).tap();

await expect(element(by.id('rewrite_clear_input'))).toHaveText('');
await expect(element(by.id('clear_text_input'))).toHaveText('');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -751,6 +751,7 @@ class AnnounceForAccessibility extends React.Component<{}> {
}

exports.title = 'Accessibility';
exports.documentationURL = 'https://reactnative.dev/docs/accessibilityinfo';
exports.description = 'Examples of using Accessibility APIs.';
exports.examples = [
{
Expand Down
1 change: 1 addition & 0 deletions packages/rn-tester/js/examples/Animated/AnimatedExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ const styles = StyleSheet.create({

exports.framework = 'React';
exports.title = 'Animated - Examples';
exports.documentationURL = 'https://reactnative.dev/docs/animated';
exports.description = ('Animated provides a powerful ' +
'and easy-to-use API for building modern, ' +
'interactive user experiences.': string);
Expand Down
1 change: 1 addition & 0 deletions packages/rn-tester/js/examples/AppState/AppStateExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ class AppStateSubscription extends React.Component<
}

exports.title = 'AppState';
exports.documentationURL = 'https://reactnative.dev/docs/appstate';
exports.description = 'app background status';
exports.examples = [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ const ThemedText = props => (
);

exports.title = 'Appearance';
exports.documentationURL = 'https://reactnative.dev/docs/appearance';
exports.description = 'Light and dark user interface examples.';
exports.examples = [
{
Expand Down
103 changes: 0 additions & 103 deletions packages/rn-tester/js/examples/AsyncStorage/AsyncStorageExample.js

This file was deleted.

1 change: 1 addition & 0 deletions packages/rn-tester/js/examples/Button/ButtonExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ exports.displayName = 'ButtonExample';
exports.framework = 'React';
exports.category = 'UI';
exports.title = 'Button';
exports.documentationURL = 'https://reactnative.dev/docs/button';
exports.description = 'Simple React Native button component.';

exports.examples = [
Expand Down
68 changes: 0 additions & 68 deletions packages/rn-tester/js/examples/Clipboard/ClipboardExample.js

This file was deleted.

Loading