Skip to content

Drawer - testID #905

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 3 commits into from
Aug 19, 2020
Merged
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
31 changes: 23 additions & 8 deletions demo/src/screens/componentScreens/DrawerScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,20 @@ const ITEMS = {
read: {
icon: require('../../assets/icons/mail.png'),
text: 'Read',
background: Colors.green30
background: Colors.green30,
testID: "left_item_read"
},
archive: {
icon: require('../../assets/icons/archive.png'),
text: 'Archive',
background: Colors.blue30
background: Colors.blue30,
testID: "right_item_archive"
},
delete: {
icon: require('../../assets/icons/delete.png'),
text: 'Delete',
background: Colors.red30
background: Colors.red30,
testID: "right_item_delete"
}
};

Expand Down Expand Up @@ -131,18 +134,21 @@ class DrawerScreen extends Component {
label="Open left"
style={{margin: 3}}
size={'xSmall'}
testID="open_left_btn"
/>
<Button
onPress={this.openLeftDrawerFull}
label="Full left swipe"
style={{margin: 3}}
size={'xSmall'}
testID="swipe_left_btn"
/>
<Button
onPress={this.toggleLeftDrawer}
label="Left toggle"
style={{margin: 3}}
size={'xSmall'}
testID="toggle_left_btn"
/>
</View>

Expand All @@ -152,6 +158,7 @@ class DrawerScreen extends Component {
label="Close"
style={{margin: 3}}
size={'xSmall'}
testID="close_btn"
/>
</View>

Expand All @@ -161,12 +168,14 @@ class DrawerScreen extends Component {
label="Open right"
style={{margin: 3}}
size={'xSmall'}
testID="open_right_btn"
/>
<Button
onPress={this.openRightDrawerFull}
label="Full right swipe"
style={{margin: 3}}
size={'xSmall'}
testID="swipe_right_btn"
/>
</View>
</View>
Expand All @@ -175,6 +184,8 @@ class DrawerScreen extends Component {
}

renderListItem() {
const data = conversations[2];

return (
<View
bg-grey80
Expand All @@ -183,13 +194,14 @@ class DrawerScreen extends Component {
row
centerV
style={{borderBottomWidth: 1, borderColor: Colors.grey60}}
testID="drawer_item"
>
{this.state.unread && <Badge size={'pimpleSmall'} backgroundColor={Colors.red30} containerStyle={{marginRight: 8}}/>}
<Avatar source={{uri: conversations[0].thumbnail}}/>
{this.state.unread && <Badge testID="drawer_item_badge" size={'pimpleSmall'} backgroundColor={Colors.red30} containerStyle={{marginRight: 8}}/>}
<Avatar source={{uri: data.thumbnail}}/>
<View marginL-20>
<Text text70R={!this.state.unread} text70BO={this.state.unread}>{conversations[0].name}</Text>
<Text text70R={!this.state.unread} text70BO={this.state.unread}>{data.name}</Text>
<Text text80 marginT-2>
{conversations[0].text}
{data.text}
</Text>
</View>
</View>
Expand Down Expand Up @@ -218,14 +230,16 @@ class DrawerScreen extends Component {
fullSwipeLeft,
onWillFullSwipeLeft: this.deleteItem,
onToggleSwipeLeft: this.toggleReadState,
leftToggleHapticTrigger: this.triggerLeftToggleHaptic
leftToggleHapticTrigger: this.triggerLeftToggleHaptic,
testID: 'drawer'
};
if (showRightItems) {
drawerProps.rightItems = [{...ITEMS.delete, onPress: this.deleteItem}, ITEMS.archive];
}

if (showLeftItem) {
drawerProps.leftItem = {
...ITEMS.read,
icon: this.state.unread ? require('../../assets/icons/mail.png') : require('../../assets/icons/refresh.png'),
text: !this.state.unread ? 'Unread' : 'Read',
background: this.state.unread ? Colors.green30 : Colors.orange30,
Expand All @@ -245,6 +259,7 @@ class DrawerScreen extends Component {
iconSource={Assets.icons.demo.refresh}
onPress={this.showItem}
disabled={!hideItem}
testID="refresh_btn"
/>
</View>
{!hideItem && (
Expand Down
4 changes: 3 additions & 1 deletion src/components/drawer/Swipeable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,8 @@ export default class Swipeable extends Component<PropType, StateType> {
leftActionsContainerStyle,
rightActionsContainerStyle,
containerStyle,
childrenContainerStyle
childrenContainerStyle,
testID
} = this.props;

const left = renderLeftActions && (
Expand Down Expand Up @@ -468,6 +469,7 @@ export default class Swipeable extends Component<PropType, StateType> {
{right}
<TapGestureHandler onHandlerStateChange={this._onTapHandlerStateChange}>
<Animated.View
testID={testID}
style={[
{transform: [{translateX: this._transX}]},
childrenContainerStyle
Expand Down