-
Notifications
You must be signed in to change notification settings - Fork 78
Implement Initial Collections Artwork Filter Navigation Stack #2096
Conversation
a2941d2
to
8f1e386
Compare
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.
Few comments (mostly on tests) but this is looking great!!
<SortOptions navigator={mockNavigator as any} /> | ||
</Theme> | ||
) | ||
expect(SortOptionsScreen).toMatchSnapshot() |
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.
I tend to find snapshots not super helpful. Doesn't have to be for this PR, but instead could we test a meaningful aspect of the component? (Such as that the correct number of OptionListItem
s show up)?
src/lib/Components/FilterModal.tsx
Outdated
navigationBarHidden={true} | ||
initialRoute={{ | ||
component: FilterOptions, | ||
title: "", |
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.
I don't think we need this.
<FilterOptions navigator={mockNavigator as any} closeModal={jest.fn()} /> | ||
</Theme> | ||
) | ||
expect(FilterOptionsScreen).toMatchSnapshot() |
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.
Here too, I think this test would be more meaningful with more explicit assertions! (But not a blocker)
<FilterOptions closeModal={jest.fn()} navigator={mockNavigator as any} /> | ||
</Theme> | ||
) | ||
const filterListItem = filterScreen.root.findByProps({ "data-test-filter-item": "item" }) |
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.
It seems a little odd to pass props in order to find the item. Can we select for this based on the component's text or class name? (this applies to the other places as well!)
.create( | ||
const getNextScreenTitle = component => component.root.findByType(Sans).props.children | ||
|
||
expect(getNextScreenTitle(filterScreen)).toEqual("Sort") |
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.
🎉
expect(getPreviousScreenTitle(filterScreen)).toEqual("Filter") | ||
}) | ||
|
||
it("allows users to eit filter modal when selecting close icon", () => { |
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.
#superminor eit
-> exit
0ec266f
to
b42336f
Compare
b42336f
to
b958eeb
Compare
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.
Looking really good for a start!
src/lib/Components/FilterModal.tsx
Outdated
const { filterOptions } = this.state | ||
|
||
return ( | ||
<Flex flexGrow={1} data-test-filter-title="item"> |
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.
this data-test-[element-id]="item"
pattern confused me a little. React Native elements have a prop called testID
that people use for the same thing but it uses the form testID="[element-id]"
, so in this case instead of data-test-filter-title="item"
it would be testID="filter-title"
Although, having said that, our palette components use the web typings (😬) so typescript would not allow testID
, but you could do data-test-id="filter-title"
to keep the same naming pattern which would probably be less surprising to other folks reading this code later.
edit: sarah's suggestion is also good 👍 😅
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.
Yes, I was trying to avoid creating aliased styled-components simply for test purposes as there are multiple instances of the same component type and I needed a way to grab a specific instance. But it seems like there are trade-offs either way.
renderSortOption = ({ item }) => { | ||
return ( | ||
<OptionListItem> | ||
<Flex p={2} flexDirection="row" justifyContent="space-between" flexGrow={1}> | ||
<Serif size="3">{item}</Serif> | ||
</Flex> | ||
</OptionListItem> | ||
) | ||
} |
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.
would be good to have this typed, or personally I'd just move the jsx inline into the renderItem
prop so you get the typing for free
<Flex flexGrow={1}> | ||
<SortHeader> | ||
<Flex alignItems="flex-end" mt={0.5} mb={2}> | ||
<Box ml={2} mt={2} onTouchStart={() => this.handleBackNavigation()} data-test-sort-back-nav="item"> |
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.
normally on mobile we wouldn't handle presses using onTouchStart
because it fires as soon as the user's finger hits the area, but they might not have intended to press the button. It's best to use something like <TouchableWithOpacity onPress={...}>
which handles this situation.
export const SortHeader = styled(Flex)` | ||
flex-direction: row; | ||
justify-content: space-between; | ||
padding-right: 20px; |
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.
we should probably use the space
helper from palette here
padding-right: 20px; | |
padding-right: ${space(2)}px; |
<Flex flexGrow={1}> | ||
<SortHeader> | ||
<Flex alignItems="flex-end" mt={0.5} mb={2}> | ||
<ArrowLeftIconContainer onTouchStart={() => this.handleBackNavigation()}> |
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.
again, would be good to use TouchableOpacity here
src/lib/Components/FilterModal.tsx
Outdated
onPress={() => { | ||
this.closeModal() | ||
<ModalBackgroundView> | ||
<Flex onTouchStart={this.props.closeModal} style={{ flexGrow: 1 }} /> |
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.
would be good to use TouchableWithoutFeedback with onPress here
src/lib/Components/FilterModal.tsx
Outdated
<OptionListItem> | ||
<Flex p={2} flexDirection="row" justifyContent="space-between" flexGrow={1}> | ||
<Serif size="3">{type}</Serif> | ||
<TouchableOptionListItemRow onTouchStart={() => onTap()}> |
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.
again, would be good to use TouchableOpacity with onPress
const filterOptions = [] | ||
|
||
filterOptions.push({ | ||
type: "Sort by", | ||
onTap: this.handleNavigationToSortScreen, | ||
}) | ||
|
||
this.setState({ | ||
filterOptions, | ||
}) |
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.
Looks like this state value never changes so you can just inline it in the render method.
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.
@ashleyjelks this is another opportunity for cleanup!
src/lib/Components/FilterModal.tsx
Outdated
<Flex flexGrow={1}> | ||
<Flex flexDirection="row" justifyContent="space-between"> | ||
<Flex alignItems="flex-end" mt={0.5} mb={2}> | ||
<CloseIconContainer onTouchStart={() => this.props.closeModal()}> |
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.
💡 TouchableOpcaity + onPress
Cool! @ashleyjelks I'm going to merge this in 😄 but it's worth revisiting the few remaining items from @ds300's review in one of your subsequent PRs! |
🚀 PR was released in v1.21.52 🚀 |
#skip_new_tests