Skip to content
This repository has been archived by the owner on Mar 12, 2020. It is now read-only.

Adds collection artwork preview component #2015

Merged
merged 8 commits into from
Jan 2, 2020
Merged

Conversation

ashleyjelks
Copy link
Contributor

@ashleyjelks ashleyjelks commented Dec 17, 2019

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.

Kapture 2019-12-17 at 15 34 43

#skip_new_tests

Copy link
Contributor

@pepopowitz pepopowitz left a 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?

@ashleyjelks

This comment has been minimized.

if (!collection) {
return null
}
const artworks = collection.artworks.edges.map(({ node }) => node)
Copy link
Contributor

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?

Copy link
Contributor

@pepopowitz pepopowitz left a 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
Copy link
Contributor

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`;
Copy link
Contributor

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>"`;
Copy link
Contributor

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, [])
Copy link
Contributor

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:

Suggested change
const collectionArtworks = get(collection.artworks, artwork => artwork.edges, [])
const collectionArtworks = get(collection, collection => collection.artworks.artwork.edges, [])

Copy link
Member

@anandaroop anandaroop left a 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) {
Copy link
Member

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...

Copy link
Contributor Author

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.

Copy link
Contributor

@pepopowitz pepopowitz left a 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>"`;
Copy link
Contributor

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>"`;
Copy link
Contributor

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.

Copy link
Contributor Author

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:

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?

Copy link
Contributor

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.

Copy link
Contributor Author

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} />,
Copy link
Contributor

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???

Copy link

@mbilokonsky mbilokonsky left a 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!

@ashleyjelks ashleyjelks merged commit 99a838a into master Jan 2, 2020
@ashleyjelks ashleyjelks deleted the artwork-preview branch January 2, 2020 13:24
@artsyit
Copy link
Collaborator

artsyit commented Jan 2, 2020

🚀 PR was released in v1.20.6 🚀

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants