-
Notifications
You must be signed in to change notification settings - Fork 78
Adds collection artwork preview component #2015
Conversation
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 looks like the actual CollectionArtworkPreview component is not included in this PR. Is that accidental, or because it is a component that already existed?
This comment has been minimized.
This comment has been minimized.
4ea039a
to
53a35b3
Compare
if (!collection) { | ||
return null | ||
} | ||
const artworks = collection.artworks.edges.map(({ node }) => node) |
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.
Should we use the get
util against this long chain of properties, to avoid app crashes if for some reason something came back from metaphysics funny?
6f5b020
to
1d4f4dc
Compare
1d4f4dc
to
14c0859
Compare
d5d1769
to
dc47e5e
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.
Looks good, but I think the snapshot tests are not capturing what you're expecting them to capture. My other two comments are trivial, and I'm not expecting them to be addressed.
|
||
export class CollectionArtworkPreview extends React.Component<Props> { | ||
render() { | ||
let artworks |
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 is a total nit, and not something I'm expecting to change as part of this PR. Having a variable defined with let
at the top of a function gives me the impression that there's going to be some conditional logic to decide what to set it to. That isn't the case here, so I'd expect the declaration to happen on line 20, where it is set, like
const artworks = collectionArtworks.map....
Declaring it as a let
at the top just kind of leaves my brain hanging...it's something I have to keep track of as I read the function, to know when and how it's set.
@@ -0,0 +1,3 @@ | |||
// Jest Snapshot v1, https://goo.gl/fbAQLP | |||
|
|||
exports[`CollectionArtworkPreview renders properly 1`] = `null`; |
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 snapshot is null
- it looks like we didn't capture what we intended to capture.
</Text>, | ||
] | ||
`; | ||
exports[`renders a snapshot of the collection header 1`] = `"<view mb=\\"2\\"><aropaqueimageview imageurl=\\"http://imageuploadedbymarketingteam.jpg\\" height=\\"204\\" width=\\"750\\"></aropaqueimageview></view>"`; |
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 this snapshot captures what we intended to capture, either. From the CollectionHeader
component, I'd expect this snapshot to include the title, which I don't see.
if (!collection) { | ||
return null | ||
} | ||
const collectionArtworks = get(collection.artworks, artwork => artwork.edges, []) |
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.
Does the get
helper err out if the first argument is undefined? If so, or if you don't feel like looking, a quick way to avoid that happening here would be to move .artworks
to the second argument, like this:
const collectionArtworks = get(collection.artworks, artwork => artwork.edges, []) | |
const collectionArtworks = get(collection, collection => collection.artworks.artwork.edges, []) |
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.
Only comment from me is the thing I noted in Slack yesterday…
export const CollectionArtworkPreviewContainer = createFragmentContainer(CollectionArtworkPreview, { | ||
collection: graphql` | ||
fragment CollectionArtworkPreview_collection on MarketingCollection { | ||
artworks: artworksConnection(sort: "-merchandisability", first: 6) { |
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.
Should be -decayed_merch
n'est-ce pas? Slack convo here...
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, but I want to follow up with this in a sep PR bc it requires a change in Reaction and Emission and for now I think the data should be consistent.
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 still don't think these snapshot tests are functioning correctly. The snapshots themselves don't contain any details about the components that are being rendered.
</Text>, | ||
] | ||
`; | ||
exports[`renders properly 1`] = `"<view mb=\\"2\\"><aropaqueimageview imageurl=\\"http://imageuploadedbymarketingteam.jpg\\" height=\\"204\\" width=\\"750\\"></aropaqueimageview></view>"`; |
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 looks different than before, but I still don't think it's capturing what you intended it to capture.
@@ -0,0 +1,3 @@ | |||
// Jest Snapshot v1, https://goo.gl/fbAQLP | |||
|
|||
exports[`renders properly 1`] = `"<view mb=\\"4\\" width=\\"100%\\"></view>"`; |
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 looks different than before, but I still don't think it's capturing what you intended it to capture.
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.
So this new snapshot is testing the Container and that the relay mock query generates the expected underlying view component. If you compare a similar snapshot in the Show Artworks preview, it's compiling to the same underlying view:
emission/src/lib/Components/Show/__tests__/__snapshots__/ShowArtworksPreview-tests.tsx.snap
Line 3 in 3445422
exports[`renders properly 1`] = `"<text font-family=\\"ReactNativeAGaramondPro-Regular\\" font-size=\\"26px\\" lineheight=\\"32px\\" mt=\\"2\\" mb=\\"3\\">All works</text>"`; |
What do you think?
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 it's a test worth keeping, if that's what the snapshot looks like. That's not going to catch any changes to the underlying component. I'd ditch the test, or find a way to test the underlying component itself.
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'm going to disable the test for now and follow up with @ds300 or @ashfurrow when they return next week from the break. In the meantime I think this PR is safe to merge!
|
||
it("renders properly", async () => { | ||
const tree = await renderRelayTree({ | ||
Component: (props: any) => <CollectionArtworkPreview collection={props} {...props} />, |
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.
Do you we need the typing here? If so, it might be worth providing the exact type. CollectionArtworkPreview_collection
I think???
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'll defer to @pepopowitz on this as he's a lot more familiar with the codebase, chiming in now cuz I keep seeing this notification - sorry I didn't leave this comment before the break, see y'all in 2020!
🚀 PR was released in v1.20.6 🚀 |
This PR adds the artwork preview grid to the collections view.
Links to GROW-1473
We have a mob pairing session scheduled to work on adding tests, but I think this PR is at least in a good state to have the code reviewed for the component itself.
#skip_new_tests