-
Notifications
You must be signed in to change notification settings - Fork 734
Automation gap - WOAUILIB-3704 #2902
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
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
f8a6d14
Added test for automation gap bug on android
nitzanyiz dcd4112
Added resetModules in order to test both platforms
nitzanyiz f6dbf82
Added test with mocking. Doesn't work
nitzanyiz c12cb4b
Added test for automation gap
nitzanyiz 9fa25a5
Removed comment
nitzanyiz 00d859a
Change constant import
nitzanyiz faeeec7
Added getDriver
nitzanyiz 2a198e0
Added ltr tests and reorded tests
nitzanyiz fb955ab
removed renderTree from driver
nitzanyiz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
---|---|---|
@@ -1,46 +1,91 @@ | ||
import React from 'react'; | ||
import {render} from '@testing-library/react-native'; | ||
import View from '../../view'; | ||
import Text from '../index'; | ||
import {TextDriver} from '../Text.driver.new'; | ||
import {StyleSheet} from 'react-native'; | ||
|
||
const TEXT_ID = 'text_test_id'; | ||
const TEXT_CONTENT = 'text content'; | ||
|
||
function WrapperScreenWithText(textProps: {onPress?: jest.Mock} = {}) { | ||
const {onPress} = textProps; | ||
const Text = require('../index').default; | ||
return ( | ||
<View> | ||
<Text testID={TEXT_ID} onPress={onPress}> | ||
{TEXT_CONTENT} | ||
</Text> | ||
</View> | ||
<Text testID={TEXT_ID} onPress={onPress}> | ||
{TEXT_CONTENT} | ||
</Text> | ||
); | ||
} | ||
|
||
const getDriver = (textProps: {onPress?: jest.Mock} = {}) => { | ||
const {onPress} = textProps; | ||
const renderTree = render(<WrapperScreenWithText onPress={onPress}/>); | ||
const textDriver = TextDriver({renderTree, testID: TEXT_ID}); | ||
return {textDriver}; | ||
}; | ||
|
||
describe('Text', () => { | ||
it('should render Text Component', () => { | ||
const renderTree = render(<WrapperScreenWithText/>); | ||
const textDriver = TextDriver({renderTree, testID: TEXT_ID}); | ||
const {textDriver} = getDriver(); | ||
const content = textDriver.getText(); | ||
expect(content).toEqual(TEXT_CONTENT); | ||
}); | ||
|
||
describe('onPress', () => { | ||
it('should press the text, and run callback', () => { | ||
const onPressCallback = jest.fn(); | ||
const renderTree = render(<WrapperScreenWithText onPress={onPressCallback}/>); | ||
const textDriver = TextDriver({renderTree, testID: TEXT_ID}); | ||
|
||
const {textDriver} = getDriver({onPress: onPressCallback}); | ||
textDriver.press(); | ||
|
||
expect(onPressCallback).toHaveBeenCalledTimes(1); | ||
}); | ||
|
||
it('should not be pressable if onPress prop is not supplied', () => { | ||
const renderTree = render(<WrapperScreenWithText/>); | ||
const textDriver = TextDriver({renderTree, testID: TEXT_ID}); | ||
const {textDriver} = getDriver(); | ||
expect(textDriver.hasOnPress()).toBeFalsy(); | ||
}); | ||
}); | ||
const setConstants = (isAndroid: boolean, isRTL: boolean) => { | ||
const {Constants} = require('../../../commons/new'); | ||
Constants.isAndroid = isAndroid; | ||
Constants.isIOS = !isAndroid; | ||
Constants.isRTL = isRTL; | ||
}; | ||
|
||
describe('Automation gap', () => { | ||
describe('Both RTL and LTR', () => { | ||
it('Should always align text to left on Android', () => { | ||
jest.isolateModules(() => { | ||
setConstants(true, true); | ||
const {textDriver} = getDriver(); | ||
const textStyle = textDriver.getProps().style; | ||
expect(StyleSheet.flatten(textStyle).textAlign).toEqual('left'); | ||
}); | ||
jest.isolateModules(() => { | ||
setConstants(true, false); | ||
const {textDriver} = getDriver(); | ||
const textStyle = textDriver.getProps().style; | ||
expect(StyleSheet.flatten(textStyle).textAlign).toEqual('left'); | ||
}); | ||
}); | ||
}); | ||
describe('RTL', () => { | ||
it('Should have text of left on iOS', () => { | ||
jest.isolateModules(() => { | ||
setConstants(false, true); | ||
const {textDriver} = getDriver(); | ||
const textStyle = textDriver.getProps().style; | ||
expect(StyleSheet.flatten(textStyle).writingDirection).toEqual('rtl'); | ||
}); | ||
}); | ||
}); | ||
describe('LTR', () => { | ||
it('Should have text of right on iOS', () => { | ||
jest.isolateModules(() => { | ||
setConstants(false, false); | ||
const {textDriver} = getDriver(); | ||
const textStyle = textDriver.getProps().style; | ||
expect(StyleSheet.flatten(textStyle).writingDirection).toEqual('ltr'); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please change the name