-
Notifications
You must be signed in to change notification settings - Fork 734
Timeline - Add testIDs #3706
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
Timeline - Add testIDs #3706
Changes from 14 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
832af2a
Add testID prop to Line, Point, and Timeline components for improved …
adids1221 e711022
small type revert
adids1221 964ff4a
Remove testID from timelineContainer
adids1221 d49ce70
make Line and Point testID prop internal prop
adids1221 2ae6efd
Timeline driver + test
adids1221 9162d72
Add Point rendering tests and enhance TimelineDriver with getPoint me…
adids1221 d222854
Timeline driver refactor
adids1221 fdd9731
Refactor Timeline and Point drivers for improved test structure and s…
adids1221 70afbd4
Fix testID prop usage in Line and Point components
adids1221 602a9a4
Merge branch 'master' into infra/Timeline_testID
adids1221 9ab14bf
Add TimelineDriver export to testkit index
adids1221 491696a
Refactor Timeline tests to simplify driver retrieval
adids1221 c239b5f
Top/Bottom line moved from sainty, no icon no label test
adids1221 591b49c
Update Timeline sainty tests to include checks for top and bottom lines
adids1221 8dbdb68
Remove redundant TopLine test
adids1221 b1c9868
Merge branch 'master' into infra/Timeline_testID
adids1221 e13463d
Add isVisible method to LineDriver and update tests to verify visibility
adids1221 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
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
112 changes: 112 additions & 0 deletions
112
src/components/timeline/__tests__/driver.index.spec.tsx
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 |
---|---|---|
@@ -0,0 +1,112 @@ | ||
import React from 'react'; | ||
import {render} from '@testing-library/react-native'; | ||
import {TimelineDriver} from '../timeline.driver'; | ||
import {TimelineProps} from '../types'; | ||
import Timeline from '../index'; | ||
import Text from '../../text'; | ||
import Assets from '../../../assets'; | ||
|
||
const testID = 'test-timeline'; | ||
const labelContent = 2; | ||
const defaultIcon = Assets.internal.icons.check; | ||
|
||
const getDriver = (props?: TimelineProps) => { | ||
const renderTree = render(<Timeline testID={testID} {...props}> | ||
<Text>Timeline</Text> | ||
</Timeline>); | ||
return TimelineDriver({renderTree, testID}); | ||
}; | ||
|
||
describe('Timeline', () => { | ||
describe('sanity', () => { | ||
it('should render Timeline', () => { | ||
const timelineDriver = getDriver(); | ||
expect(timelineDriver.exists()).toBeTruthy(); | ||
expect(timelineDriver.getPoint().exists()).toBeTruthy(); | ||
expect(timelineDriver.getTopLine().exists()).toBeTruthy(); | ||
expect(timelineDriver.getBottomLine().exists()).toBeFalsy(); | ||
}); | ||
}); | ||
|
||
describe('Point', () => { | ||
describe('with Icon', () => { | ||
Inbal-Tish marked this conversation as resolved.
Show resolved
Hide resolved
|
||
it('should override icon color when passing iconProps.tintColor', () => { | ||
const props = {point: {icon: defaultIcon, iconProps: {tintColor: '#A2387E'}}}; | ||
const timelineDriver = getDriver(props); | ||
const contentStyle = timelineDriver.getPoint().getContentStyle(); | ||
expect(contentStyle.tintColor).toEqual('#A2387E'); | ||
expect(contentStyle.color).toBeUndefined(); | ||
}); | ||
}); | ||
|
||
describe('with Label', () => { | ||
it('should override label color when passing labelColor', () => { | ||
const props = {point: {label: labelContent, labelColor: '#A2387E'}}; | ||
const timelineDriver = getDriver(props); | ||
const contentStyle = timelineDriver.getPoint().getContentStyle(); | ||
expect(contentStyle.color).toEqual('#A2387E'); | ||
expect(contentStyle.tintColor).toBeUndefined(); | ||
}); | ||
}); | ||
|
||
it('should render Icon when icon and label passed', () => { | ||
const props = {point: {icon: defaultIcon, iconProps: {tintColor: '#A2387E'}, label: labelContent}}; | ||
const timelineDriver = getDriver(props); | ||
const contentStyle = timelineDriver.getPoint().getContentStyle(); | ||
expect(contentStyle.tintColor).toEqual('#A2387E'); | ||
expect(contentStyle.color).toBeUndefined(); | ||
}); | ||
|
||
it('tintColor and color should be undefined when icon and label are not passed', () => { | ||
const timelineDriver = getDriver(); | ||
const contentStyle = timelineDriver.getPoint().getContentStyle(); | ||
expect(contentStyle.tintColor).toBeUndefined(); | ||
expect(contentStyle.color).toBeUndefined(); | ||
}); | ||
}); | ||
|
||
describe('TopLine', () => { | ||
it('should render TopLine', () => { | ||
const props = {topLine: {}}; | ||
Inbal-Tish marked this conversation as resolved.
Show resolved
Hide resolved
|
||
const timelineDriver = getDriver(props); | ||
const topLine = timelineDriver.getTopLine(); | ||
expect(topLine.exists()).toBeTruthy(); | ||
}); | ||
|
||
it('should override top line color and width', () => { | ||
const props = {topLine: {color: '#00A87E', width: 3}}; | ||
const timelineDriver = getDriver(props); | ||
const topLine = timelineDriver.getTopLine(); | ||
expect(topLine.exists()).toBeTruthy(); | ||
const topLineStyle = topLine.getStyle(); | ||
expect(topLineStyle.backgroundColor).toEqual('#00A87E'); | ||
expect(topLineStyle.width).toEqual(3); | ||
}); | ||
|
||
it('should render line with entryPoint', () => { | ||
const props = {topLine: {entry: true}}; | ||
const timelineDriver = getDriver(props); | ||
const topLine = timelineDriver.getTopLine(); | ||
expect(topLine.isEntryPointExists()).toBeTruthy(); | ||
}); | ||
}); | ||
|
||
describe('BottomLine', () => { | ||
it('should render BottomLine', () => { | ||
const props = {bottomLine: {}}; | ||
const timelineDriver = getDriver(props); | ||
const bottomLine = timelineDriver.getBottomLine(); | ||
expect(bottomLine.exists()).toBeTruthy(); | ||
}); | ||
|
||
it('should override bottom line color and width', () => { | ||
const props = {bottomLine: {color: '#FFF4D3', width: 5}}; | ||
const timelineDriver = getDriver(props); | ||
const bottomLine = timelineDriver.getBottomLine(); | ||
expect(bottomLine.exists()).toBeTruthy(); | ||
const bottomLineStyle = bottomLine.getStyle(); | ||
expect(bottomLineStyle.backgroundColor).toEqual('#FFF4D3'); | ||
expect(bottomLineStyle.width).toEqual(5); | ||
}); | ||
}); | ||
}); |
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
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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import {StyleSheet} from 'react-native'; | ||
import {ComponentProps} from '../../testkit/new/Component.driver'; | ||
import {ViewDriver} from '../view/View.driver.new'; | ||
|
||
export const LineDriver = (props: ComponentProps) => { | ||
const lineDriver = ViewDriver({ | ||
renderTree: props.renderTree, | ||
testID: `${props.testID}` | ||
}); | ||
|
||
const entryPointDriver = ViewDriver({ | ||
renderTree: props.renderTree, | ||
testID: `${props.testID}.entryPoint` | ||
}); | ||
|
||
const getLine = () => { | ||
const exists = (): boolean => { | ||
return lineDriver.exists(); | ||
}; | ||
const getStyle = () => { | ||
return StyleSheet.flatten(lineDriver.getElement().props.style); | ||
}; | ||
const isEntryPointExists = (): boolean => { | ||
return entryPointDriver.exists(); | ||
}; | ||
const getEntryPointStyle = () => { | ||
return entryPointDriver.getStyle(); | ||
}; | ||
return {exists, getStyle, isEntryPointExists, getEntryPointStyle}; | ||
}; | ||
|
||
return { | ||
getLine | ||
}; | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import {StyleSheet} from 'react-native'; | ||
import {ComponentProps} from '../../testkit/new/Component.driver'; | ||
import {TextDriver} from '../text/Text.driver.new'; | ||
import {ImageDriver} from '../image/Image.driver.new'; | ||
import {ViewDriver} from '../view/View.driver.new'; | ||
|
||
export const PointDriver = (props: ComponentProps) => { | ||
const pointDriver = ViewDriver({ | ||
renderTree: props.renderTree, | ||
testID: `${props.testID}` | ||
}); | ||
|
||
const labelDriver = TextDriver({ | ||
renderTree: props.renderTree, | ||
testID: `${props.testID}.label` | ||
}); | ||
|
||
const iconDriver = ImageDriver({ | ||
renderTree: props.renderTree, | ||
testID: `${props.testID}.icon` | ||
}); | ||
|
||
const getLabel = () => { | ||
const exists = (): boolean => { | ||
return labelDriver.exists(); | ||
}; | ||
return {...labelDriver, exists}; | ||
}; | ||
|
||
const getIcon = () => { | ||
const exists = (): boolean => { | ||
return iconDriver.exists(); | ||
}; | ||
return {...iconDriver, exists}; | ||
}; | ||
|
||
const getPoint = () => { | ||
const exists = (): boolean => { | ||
return pointDriver.exists(); | ||
}; | ||
const getStyle = () => { | ||
return StyleSheet.flatten(pointDriver.getElement().props.style); | ||
}; | ||
const getContentStyle = () => { | ||
return getIcon().exists() | ||
? StyleSheet.flatten(getIcon().getElement().props.style) | ||
: getLabel().exists() && StyleSheet.flatten(getLabel().getElement().props.style); | ||
}; | ||
return {exists, getStyle, getContentStyle}; | ||
}; | ||
|
||
return { | ||
getPoint | ||
}; | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import {useComponentDriver, ComponentProps} from '../../testkit/new/Component.driver'; | ||
import {LineDriver} from './line.driver'; | ||
import {PointDriver} from './point.driver'; | ||
|
||
export const TimelineDriver = (props: ComponentProps) => { | ||
const driver = useComponentDriver(props); | ||
|
||
const pointDriver = PointDriver({ | ||
renderTree: props.renderTree, | ||
testID: `${props.testID}.point` | ||
}); | ||
|
||
const topLineDriver = LineDriver({ | ||
renderTree: props.renderTree, | ||
testID: `${props.testID}.topLine` | ||
}); | ||
const bottomLineDriver = LineDriver({ | ||
renderTree: props.renderTree, | ||
testID: `${props.testID}.bottomLine` | ||
}); | ||
|
||
const getPoint = () => { | ||
return {...pointDriver.getPoint()}; | ||
}; | ||
|
||
const getTopLine = () => { | ||
return {...topLineDriver.getLine()}; | ||
}; | ||
|
||
const getBottomLine = () => { | ||
return {...bottomLineDriver.getLine()}; | ||
}; | ||
|
||
return { | ||
...driver, | ||
getPoint, | ||
getTopLine, | ||
getBottomLine | ||
}; | ||
}; |
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
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.
Uh oh!
There was an error while loading. Please reload this page.