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

[GRAPHQL] Made the attribute destination_cart_id for mergeCarts mutation not required. #30633

Merged
merged 4 commits into from
Nov 3, 2020

Conversation

andrewbess
Copy link
Contributor

Description (*)

This PR makes the attribute destination_cart_id for mergeCarts mutation not required.

Related Pull Requests

Fixed Issues (if relevant)

  1. Fixes [Atwix]Make the destination_cart_id argument optional in the mergeCarts mutation #30469: [Atwix] Make the destination_cart_id argument optional in the mergeCarts mutation

Manual testing scenarios (*)

Scenario 1.

  1. Create an empty cart using GraphQl mutation createEmptyCart (keep the cart ID);
  2. Add product to cart;
  3. Generate customer token and write it to headers;
  4. Merge guest cart (with ID kept above) with the current logged in customer's cart (don't use destination_cart_id)
mutation {
  mergeCarts(
    source_cart_id: "<YOUR-GUEST-CART-ID>"
  ) {
    items {
      id
      product {
        name
        sku
      }
      quantity
    }
  }
}
  1. Check the response. The added product should be in the customer cart.

Scenario 2.

  1. Generate customer token and write it to headers;
  2. Get the cart ID using customerCart query;
  3. Add the product(s) to cart;
  4. Revoke customer token;
  5. Create an empty cart using GraphQl mutation createEmptyCart (keep the cart ID);
  6. Add product to cart;
  7. Generate customer token and write it to headers (for the customer from p.1);
  8. Merge guest cart (with ID kept in p.5) with the current logged in customer's cart (don't use destination_cart_id)
mutation {
  mergeCarts(
    source_cart_id: "<YOUR-GUEST-CART-ID>"
  ) {
    items {
      id
      product {
        name
        sku
      }
      quantity
    }
  }
}
  1. Check the response. All added products should be in the customer cart.

Questions or comments

Contribution checklist (*)

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • All automated tests passed successfully (all builds are green)

@m2-assistant
Copy link

m2-assistant bot commented Oct 23, 2020

Hi @andrewbess. Thank you for your contribution
Here is some useful tips how you can test your changes using Magento test environment.
Add the comment under your pull request to deploy test or vanilla Magento instance:

  • @magento give me test instance - deploy test instance based on PR changes
  • @magento give me 2.4-develop instance - deploy vanilla Magento instance

❗ Automated tests can be triggered manually with an appropriate comment:

  • @magento run all tests - run or re-run all required tests against the PR changes
  • @magento run <test-build(s)> - run or re-run specific test build(s)
    For example: @magento run Unit Tests

<test-build(s)> is a comma-separated list of build names. Allowed build names are:

  1. Database Compare
  2. Functional Tests CE
  3. Functional Tests EE,
  4. Functional Tests B2B
  5. Integration Tests
  6. Magento Health Index
  7. Sample Data Tests CE
  8. Sample Data Tests EE
  9. Sample Data Tests B2B
  10. Static Tests
  11. Unit Tests
  12. WebAPI Tests

You can find more information about the builds here

ℹ️ Please run only needed test builds instead of all when developing. Please run all test builds before sending your PR for review.

For more details, please, review the Magento Contributor Guide documentation.

⚠️ According to the Magento Contribution requirements, all Pull Requests must go through the Community Contributions Triage process. Community Contributions Triage is a public meeting.

🕙 You can find the schedule on the Magento Community Calendar page.

📞 The triage of Pull Requests happens in the queue order. If you want to speed up the delivery of your contribution, please join the Community Contributions Triage session to discuss the appropriate ticket.

🎥 You can find the recording of the previous Community Contributions Triage on the Magento Youtube Channel

✏️ Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel

@andrewbess
Copy link
Contributor Author

@magento run all tests

@andrewbess
Copy link
Contributor Author

@magento run all tests

@andrewbess
Copy link
Contributor Author

@magento run all tests

@rogyar rogyar self-assigned this Oct 24, 2020
}

$guestMaskedCartId = $args['source_cart_id'];
$customerMaskedCartId = $args['destination_cart_id'];
$customerMaskedCartId = $customerMaskedCartId ?? $args['destination_cart_id'];
Copy link
Contributor

Choose a reason for hiding this comment

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

There's magic in 7.4 that allows us to turn it into

Suggested change
$customerMaskedCartId = $customerMaskedCartId ?? $args['destination_cart_id'];
$customerMaskedCartId ??= $args['destination_cart_id'];

But let's leave it as it is to preserve compatibility with 7.3

Copy link
Contributor

@rogyar rogyar left a comment

Choose a reason for hiding this comment

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

Hi @andrewbess. Looks great, thanks. Please, check my suggestion regarding the test below

@@ -192,9 +192,6 @@ public function testMergeCartsWithEmptySourceCartId()
*/
public function testMergeCartsWithEmptyDestinationCartId()
Copy link
Contributor

Choose a reason for hiding this comment

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

I would ask you to cover this case with an additional test. The test will assert that without providing the destination cart id, the current cart is being used.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hello @rogyar
Thank you for your review.
I extended the tests.
Please check.

Thank you in advance.

@rogyar rogyar added the Auto-Tests: Not Covered Changes in Pull Request requires coverage by auto-tests label Oct 24, 2020
@ghost ghost dismissed prabhuram93’s stale review October 27, 2020 07:37

Pull Request state was updated. Re-review required.

@rogyar rogyar added Award: test coverage Auto-Tests: Covered All changes in Pull Request is covered by auto-tests and removed Auto-Tests: Not Covered Changes in Pull Request requires coverage by auto-tests labels Oct 27, 2020
) {
$this->getCartForUser = $getCartForUser;
$this->cartRepository = $cartRepository;
$this->customerCartResolver = $customerCartResolver;
Copy link
Contributor

Choose a reason for hiding this comment

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

Hi @andrewbess can you check for null, for the new params here. We can have issues during the upgrade if not. Thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hello @prabhuram93
Thank you for your note.
I have fixed it.
Please check.
Thank you in advance.

Copy link
Contributor

Choose a reason for hiding this comment

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

Looks good. Thanks!

@andrewbess andrewbess requested a review from rogyar October 28, 2020 08:44
@ghost ghost added Progress: ready for testing Priority: P1 Once P0 defects have been fixed, a defect having this priority is the next candidate for fixing. and removed Progress: review labels Oct 28, 2020
@magento-engcom-team magento-engcom-team merged commit d04bf94 into magento:2.4-develop Nov 3, 2020
@m2-assistant
Copy link

m2-assistant bot commented Nov 3, 2020

Hi @andrewbess, thank you for your contribution!
Please, complete Contribution Survey, it will take less than a minute.
Your feedback will help us to improve contribution process.

@andrewbess andrewbess deleted the CE-30469 branch November 3, 2020 08:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Auto-Tests: Covered All changes in Pull Request is covered by auto-tests Award: test coverage Component: QuoteGraphQl Event: MageCONF CD 2020 Partner: Atwix Pull Request is created by partner Atwix partners-contribution Pull Request is created by Magento Partner Priority: P1 Once P0 defects have been fixed, a defect having this priority is the next candidate for fixing. Progress: ready for testing Project: GraphQL Release Line: 2.4
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Atwix]Make the destination_cart_id argument optional in the mergeCarts mutation
6 participants