Skip to content

AddToCart component receiving wrong diffLog on very first call #4185

@juho-jaakkola

Description

@juho-jaakkola

Current behavior

  1. Open a new incognito window (must have completely clean state!)
  2. Add a product to the cart
  3. Expectation is that addToCart method in the the AddToCart.vue component receives the diffLog produced by the request
  4. However the entries in the received diffLog are empty:
    items: Array(0)
        length: 0
    serverResponses: Array(0)
        length: 0
    clientNotifications: Array(0)
        length: 0
    
  5. On the following calls the diffLog has the correct data.

Expected behavior

The diffLog should contain the details, i.e:

items: Array(3)
    0: {party: "server", sku: "866550", status: "no-item"}
    1: {party: "client", status: "no-changes"}
    2: {party: "server", status: "no-changes"}
    length: 3
serverResponses: Array(1)
    0: {status: 200, sku: "866550", result: {…}}
    length: 1
clientNotifications: Array(0)
    length: 0

I think the problem happens because on the very first time the sync happens through the create action instead of the sync action

However, the create call does not return any diffLog. I believe the fix would be to return the result here: https://github.com/DivanteLtd/vue-storefront/blob/v1.11.2/core/modules/cart/store/actions/connectActions.ts#L72

And then process that result (use diffLog.merge()?) in order to return the correct data to the AddToCart component.

I do not fully understand how all the cart related features work together, so could someone confirm whether my suggestion makes sense?

Can you handle fixing this bug by yourself?

  • YES
  • NO

Which Release Cycle state this refers to? Info for developer.

Pick one option.

  • This is a bug report for test version on https://test.storefrontcloud.io - In this case Developer should create branch from develop branch and create Pull Request 2. Feature / Improvement back to develop.
  • This is a bug report for current Release Candidate version on https://next.storefrontcloud.io - In this case Developer should create branch from release branch and create Pull Request 3. Stabilisation fix back to release.
  • This is a bug report for current Stable version on https://demo.storefrontcloud.io and should be placed in next stable version hotfix - In this case Developer should create branch from hotfix or master branch and create Pull Request 4. Hotfix back to hotfix.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3: NormalPriority mark - normal prioritybugBug reports

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions