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

Set cart page is loading while fetching data from network #2454

Merged
merged 6 commits into from
Jun 16, 2020

Conversation

supernova-at
Copy link
Contributor

@supernova-at supernova-at commented Jun 2, 2020

Description

This PR sets the cart page's isCartUpdating flag while we are fetching data from the network.

This will not allow users to "Proceed to Checkout" until we know we have the latest data from the network and the user is seeing the most up-to-date information.

Notably, this PR does not solve the cart page flash problem - the cart page purposefully shows data returned from its cache first, and updates it with data fetched from the network. It purposefully does not show a loading spinner while we wait for network data (that would defeat the purpose of having cached data).

The "flash" is the page showing the cached data first and then switching to the network data.

PWA-321 will properly add items to the cache and actually solve the flash problem, but even then there is a chance the cache and the network are out of sync, and the changes in this PR are useful to have in place regardless.

Related Issue

Closes PWA-416.

Acceptance

Verification Stakeholders

Specification

Verification Steps

  1. Add an item to your cart
  2. Change your browser's network settings to "Fast 3G"
  3. Navigate to the /cart page
  4. See that the "Proceed to Checkout" button is disabled until the "get cart details" network call returns

Screenshots / Screen Captures (if appropriate)

Checklist

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

@PWAStudioBot
Copy link
Contributor

PWAStudioBot commented Jun 2, 2020

Messages
📖

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

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

Associated JIRA tickets: PWA-321.

Generated by 🚫 dangerJS against 303cba8

@devops-pwa-codebuild
Copy link
Collaborator

devops-pwa-codebuild commented Jun 2, 2020

Performance Test Results

The following fails have been reported by WebpageTest. These numbers indicates a possible performance issue with the PR which requires further manual testing to validate.

https://pr-2454.pwa-venia.com : LH Performance Expected 0.85 Actual 0.57, LH Best Practices Expected 1 Actual 0.92
https://pr-2454.pwa-venia.com/venia-tops.html : LH Performance Expected 0.75 Actual 0.35, LH Best Practices Expected 1 Actual 0.92
https://pr-2454.pwa-venia.com/valeria-two-layer-tank.html : LH Performance Expected 0.8 Actual 0.38, LH Accessibility Expected 0.9 Actual 0.89, LH Best Practices Expected 1 Actual 0.92

@supernova-at supernova-at added the version: Patch This changeset includes backwards compatible bug fixes. label Jun 3, 2020
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.

Conceptually I agree that we should always render data from the cache, but I think we should solve for this case. We do have the ability to derive that our cart is empty, and it seems preferable to render the loading indicator for that case. In the instance you have cart items, and a new update from the network, the current behavior is fine. Comes down to what should we prefer:

  1. Cart not empty - Flash of empty cart before seeing real cart vs loading indicator then cart
  2. Cart empty - see empty cart immediately vs waiting a little longer before displaying empty cart

I'm also not sure if this needs some new treatment after our meeting on Thursday, so I'm going to move back to UX Review so you and @schensley can review.

revanth0212
revanth0212 previously approved these changes Jun 9, 2020
Copy link
Contributor

@revanth0212 revanth0212 left a comment

Choose a reason for hiding this comment

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

Thank you updating the tests @supernova-at. Other than a minor comment about tests, it looks fine for me. I'll leave the test addition call to you.

@@ -4,15 +4,14 @@ import { createTestInstance } from '@magento/peregrine';
import { useCartPage } from '../useCartPage';
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure how granular can we get with testing but I feel we have to add tests around conditionals and effects. For instance, check if isCartUpdating is being updated on loading change.

tjwiebell
tjwiebell previously approved these changes Jun 12, 2020
@dpatil-magento
Copy link
Contributor

@supernova-at Looks good other than being on /cart page as Auth user and then logout.

@dpatil-magento dpatil-magento merged commit 38d652a into develop Jun 16, 2020
@dpatil-magento dpatil-magento deleted the supernova/416_empty_cart_flash branch June 16, 2020 17:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg:peregrine pkg:venia-ui version: Patch This changeset includes backwards compatible bug fixes.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants