Skip to content
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

PWA-989: Real Data Wishlists and Wishlist Create #3041

Merged
merged 19 commits into from
Mar 23, 2021

Conversation

eug123
Copy link
Contributor

@eug123 eug123 commented Mar 3, 2021

Description

  • Hook up the Wishlist page to pull actual real data from GraphQL (remove all the mock data)
  • Hook up the Create Wishlist button on the Favorites / Wishlist page so that it actually fires the createWishlist GQL mutation (and updates the page)

Related Issue

Closes PWA-989

Acceptance

  • Wishlist page should use real data from backend
  • Should be possible to create new wishlist, when new wishlist created - it appears on the page

Verification Stakeholders

@dpatil-magento

Specification

Verification Steps

  1. Create a Private wish list and check the UI.
  2. Create a Public wish list and check the UI.
  3. Verify existing list are shown when user log-in.
  4. Verify Private and Public lists with Max and Min characters and check the UI.
  5. Verify functionality of Cancel Button
  6. Verify wishlists are not accessible for guest users.
  7. Verify Auth user can access wish list of their account only.
  8. Verify UI on other browsers and devices (only if any UI changes)
  9. Run MFTF

Screenshots / Screen Captures (if appropriate)

Checklist

  • I have added tests to cover my changes, if necessary.
  • I have added translations for new strings, if necessary.
  • I have updated the documentation accordingly, if necessary.

@PWAStudioBot
Copy link
Contributor

PWAStudioBot commented Mar 3, 2021

Messages
📖

Associated JIRA tickets: PWA-989.

📖 DangerCI Failures related to missing labels/description/linked issues/etc will persist until the next push or next nightly build run (assuming they are fixed).
📖

Access a deployed version of this PR here. Make sure to wait for the "pwa-pull-request-deploy" job to complete.

Generated by 🚫 dangerJS against 77e12c2

@eug123 eug123 added the version: Minor This changeset includes functionality added in a backwards compatible manner. label Mar 9, 2021
@eug123 eug123 marked this pull request as ready for review March 9, 2021 23:05
Copy link
Contributor

@tjwiebell tjwiebell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some minor signature improvements to future proof, but overall looks great. I did run into an issue now that this is hooked up to live data.

If you create a brand new Customer, it appears the first wishlist is not automatically created via GraphQL, so the /wishlist page hangs. Likely an existing bug where some assumptions were made with mocked data that aren't correct. It does appear Luma will automatically create your first list for you, so we'll need to check with product if that's something Venia should do as well, or just render the page with no lists.

Copy link
Contributor

@tjwiebell tjwiebell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clarified some points about refetch logic, this is real close. Ping me on Slack if you have any questions.

variables: {
input: data
},
refetchQueries: [{ query: getCustomerWishlistsQuery }],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right implementation, wrong query 😄 this ended up adding another network round trip. Here's a screenshot of network requests with that mutation, which additionally showcases why we should be giving operations unique names as well.

Screen Shot 2021-03-12 at 11 33 31 AM

This will be a little more involved, but totally worth it.

  1. Migrate wishlistPage.gql.js to Peregrine. Update useWishlistPage talon to use the defaultOperations merge pattern.
  2. import { GET_CUSTOMER_WISHLIST } from './wishlistPage.gql'
  3. Use that query here
  4. Remove GET_CUSTOMER_WISHLISTS from createWishlist.gql.js
  5. Additionally, you can scale down the response of CREATE_WISHLIST to just id, since we expect to refetch here anyway

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have not checked network(. Corrected it.

Thank you

Comment on lines 31 to 40
const visibilityLabel =
visibility === 'PUBLIC'
? formatMessage({
id: 'wishlist.publicText',
defaultMessage: 'Public'
})
: formatMessage({
id: 'wishlist.privateText',
defaultMessage: 'Private'
});
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 globals here instead?

Suggested change
const visibilityLabel =
visibility === 'PUBLIC'
? formatMessage({
id: 'wishlist.publicText',
defaultMessage: 'Public'
})
: formatMessage({
id: 'wishlist.privateText',
defaultMessage: 'Private'
});
const visibilityLabel =
visibility === 'PUBLIC'
? formatMessage({
id: 'global.public',
defaultMessage: 'Public'
})
: formatMessage({
id: 'global.private',
defaultMessage: 'Private'
});

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 it makes sense for this phrase "global", and these global phrases already used in other wishlist component)
Fixed.
Thank you


return root.findByType('i').props.talonProps;
};
const createWishlistMock = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do you test the loading state of this mutation? I'm trying to do this in my PR but I'm having trouble...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nvm, found it :D Just don't await the act'ed click.

@dpatil-magento
Copy link
Contributor

Thanks @eug123 those 2 fixes looks good. Please check following -

  1. On Sign-Out Apollo cache still has wishlist info saved. I think wish list data should be cleared on sign-out given its customer specific.

  1. When Enable Multiple Wish Lists is not enabled then customer is not allowed to create one wishlist also.

  1. The Enable Multiple Wish Lists can be store specific but currently once I create on enabled store the same lists can be viewed on non-enabled store view also.

  2. CE default has wishlist and not Create List button.

Don't think we need to extend the scope of this PR, First issue is something I believe needs a fix but on other 3 observations lets Demo to @tkacheva and create a follow up story around admin configs if needed.

@eug123
Copy link
Contributor Author

eug123 commented Mar 22, 2021

@dpatil-magento,
Issues 1 and 2 are fixed, please check.

Thank you

@eug123 eug123 requested a review from tjwiebell March 22, 2021 21:23
Copy link
Contributor

@tjwiebell tjwiebell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's simplify the new utility as much we can, but otherwise the rest looks good 👍 ping me if you have questions.

*
* @param {ApolloClient} client
*/
export const clearWishlistDataFromCache = async client => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure about another utility function here, since I would consider wishlist part of customer data. Fine to keep this, but would be better to have clearCustomerDataFromCache call it.

Alternatively, there is a data security pattern we might want to establish. The clearCustomerDataFromCache will clear entities that start with Customer and I think we've just gotten lucky so far that they followed this pattern. You could instead define keyFields for Wishlist and WishlistItem, and this extra utility function wouldn't be needed.

Wishlist: {
    keyFields: ({ id }) => `CustomerWishlist:${id}`
},
WishlistItem: {
    keyFields: ({ id }) => `CustomerWishlistItem:${id}`
},

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed according your recommendations.
Thank you!

tjwiebell
tjwiebell previously approved these changes Mar 23, 2021
Copy link
Contributor

@tjwiebell tjwiebell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes look perfect, nice catch covering all the WishlistItem implementations. It does look like Coveralls is dinging us a tiny bit for not testing the params of these new keyField functions, but not a blocker for approval.

@dpatil-magento
Copy link
Contributor

QA Approved. Currently unable to check when multiple wishlist is disabled how the wishlist gonna look but will test it in pr 3048

@dpatil-magento dpatil-magento merged commit c11ed3d into magento:develop Mar 23, 2021
@dpatil-magento dpatil-magento deleted the PWA-989 branch March 23, 2021 16:59
@@ -350,8 +350,6 @@
"validation.mustBeChecked": "Doit être vérifié.",
"validation.validatePassword": "Un mot de passe doit contenir au moins 3 des éléments suivants: minuscules, majuscules, chiffres, caractères spéciaux.",
"wishlist.emptyListText": "Il n'y a actuellement aucun élément dans cette liste",
"wishlist.privateText": "Privée",
"wishlist.publicText": "Publique",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

packages/extensions/venia-sample-language-packs/i18n/fr_FR.json

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg:extensions pkg:peregrine pkg:venia-ui version: Minor This changeset includes functionality added in a backwards compatible manner.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants