Skip to content
This repository was archived by the owner on Dec 19, 2019. It is now read-only.

Improve coverage for mutation addConfigurableProductToCart #437

Closed
TomashKhamlai opened this issue Mar 5, 2019 · 4 comments
Closed

Improve coverage for mutation addConfigurableProductToCart #437

TomashKhamlai opened this issue Mar 5, 2019 · 4 comments

Comments

@TomashKhamlai
Copy link
Contributor

testAddOutOfStockProduct()
not covered all possible scenarios

Preconditions (*)

Steps to reproduce (*)

  1. Create Configurable Product with
    Name Configurable Product
    SKU: configurable-product
    Weight: 1
    Price: 1
    Variations:
  • sku: configurable-product-option1, qty: 1000, price: 10
  • sku: configurable-product-option2, qty: 1000, price: 10
  1. Create empty cart as a Guest or as Customer (GraphQL)
  2. Add configurable product to Cart (GraphQL)
  3. Go to admin
  4. Set Configurable product to be Out of Stock but don't change anything in configurable variations
  5. Add configurable product to Cart again (GraphQL)
mutation {
  addConfigurableProductsToCart(
    input: {
      cart_id: "{{ CART_ID }}"
      cartItems: [
        {
          variant_sku: "useless-field"
          data: {
            qty: 11
            sku: "configurable-product-option1"
          }
        }
        {
          variant_sku: "useless-field"
          data: {
            qty: 11
            sku: "configurable-product-option2"
          }
        }
      ]
    }
  ) {
    cart {
      items {
        qty
      }
    }
  }
}

Expected result (*)

  1. When we try to add the product to the cart
    screenshot_20190305_145317

  2. When we try to proceed to checkout
    screenshot_20190305_145302

Actual result (*)

  1. Product is added to cart
{
  "data": {
    "addConfigurableProductsToCart": {
      "cart": {
        "items": [
          {
            "qty": 5034
          },
          {
            "qty": 5034
          }
        ]
      }
    }
  }
}
@rogyar
Copy link
Contributor

rogyar commented Mar 5, 2019

I would recommend postponing testing virtual products until the mutation is fixed. Currently, adding virtual products to cart does not work. Current routine does not take into account variant_sku and adds only simple products to the shopping cart.
It's also related to #349

In a few words, we need to achieve the following scenario:

  • Specify configurable product(s) for adding to cart
  • Specify super attributes (configurable options) for the configurable product
  • Add the configurable product to the shopping cart
  • Check the database, quote_item table contains a configurable product and a simple product that corresponds the selected super attributes. The simple products have configurable cart item ID in the parent_item_id field.

I have ideas about the fix but need to discuss with @naydav.

@rogyar
Copy link
Contributor

rogyar commented Mar 5, 2019

@TomashKhamlai I described the problem in details here #438

@TomashKhamlai
Copy link
Contributor Author

Ok, I understood what you explain. #439 describes the problem and expectations that could be in future in a more simple manner.

@naydav
Copy link
Contributor

naydav commented Apr 24, 2019

Closed due to work on
#438

@naydav naydav closed this as completed Apr 24, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants