Skip to content

Conversation

khrystynastolbova
Copy link
Contributor

Description (*)

Related Pull Requests

This PR added new mutation 'deleteCustomer'

Fixed Issues (if relevant)

  1. Fixes Add deleteCustomer mutation #33383

Manual testing scenarios (*)

  1. Generate customer token
  2. Use customer tokens in the header of your GraphQL call
  3. Run
mutation {
  deleteCustomer
}

Screenshot 2021-07-01 at 16 02 14

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)
  • README.md files for modified modules are updated and included in the pull request if any README.md predefined sections require an update
  • All automated tests passed successfully (all builds are green)

@m2-assistant
Copy link

m2-assistant bot commented Jul 2, 2021

Hi @khrystynastolbova. Thank you for your contribution
Here are 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
  13. Semantic Version Checker

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

@magento-engcom-team magento-engcom-team added Component: CustomerGraphQl Release Line: 2.4 Partner: Atwix Pull Request is created by partner Atwix partners-contribution Pull Request is created by Magento Partner labels Jul 2, 2021
@khrystynastolbova
Copy link
Contributor Author

@magento run all tests

@magento-automated-testing
Copy link

The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.

@m2-community-project m2-community-project bot added the Priority: P1 Once P0 defects have been fixed, a defect having this priority is the next candidate for fixing. label Jul 5, 2021
@eduard13 eduard13 self-assigned this Jul 6, 2021
Copy link
Contributor

@eduard13 eduard13 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 @khrystynastolbova for working on this one. Could you please review the questions and suggestions below?

Comment on lines +58 to +61
$isSecure = $this->registry->registry('isSecureArea');

$this->registry->unregister('isSecureArea');
$this->registry->register('isSecureArea', true);
Copy link
Contributor

Choose a reason for hiding this comment

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

I have a concern regarding the deprecated \Magento\Framework\Registry usage. Is there any alternative? Are we required to play with this configuration?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The check is located in magento/lib/internal/Magento/Framework/Model/ActionValidator/RemoveAction.php

 public function isAllowed(AbstractModel $model)
    {
        $isAllowed = true;

        if ($this->registry->registry('isSecureArea')) {
            $isAllowed = true;
        } elseif (in_array($this->getBaseClassName($model), $this->protectedModels)) {
            $isAllowed = false;
        }
        return $isAllowed;
    }

ProtectedModels include the customer model too. In the file magento/app/code/Magento/Customer/etc/di.xml

<type name="Magento\Framework\Model\ActionValidator\RemoveAction">
        <arguments>
            <argument name="protectedModels" xsi:type="array">
                <item name="customer" xsi:type="string">Magento\Customer\Model\Customer</item>
            </argument>
        </arguments>
    </type>

Copy link
Contributor Author

Choose a reason for hiding this comment

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

To avoid deprecated \Magento\Framework\Registry, we can remove the Customer model from protected models in general or copy all protected models to graphQL/di.xml for all magento modules except the Customer one.

@khrystynastolbova
Copy link
Contributor Author

Hi @eduard13. Thank you for your suggestions. I made changes except the deprecated \Magento\Framework\Registry usage.

@khrystynastolbova
Copy link
Contributor Author

@magento run all tests

@magento-automated-testing
Copy link

The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.

Copy link
Contributor

@eduard13 eduard13 left a comment

Choose a reason for hiding this comment

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

Could you please review the below suggestions as well?
Thank you.

use Magento\Integration\Api\CustomerTokenServiceInterface;

/**
* Delete custom tests
Copy link
Contributor

Choose a reason for hiding this comment

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

Please adjust the description

*/
protected function setUp(): void
{
parent::setUp();
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there any reason to call the parent method?

public function testDeleteCustomerIfAccountIsLocked(): void
{
$this->expectException(\Exception::class);
$this->expectExceptionMessage('The account sign-in was incorrect or your account is disabled temporarily. Please wait and try again later');
Copy link
Contributor

Choose a reason for hiding this comment

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

Lets avoid long code lines

Suggested change
$this->expectExceptionMessage('The account sign-in was incorrect or your account is disabled temporarily. Please wait and try again later');
$this->expectExceptionMessage(
'The account sign-in was incorrect or your account is disabled temporarily. Please wait and try again later'
);

) {
$this->getCustomer = $getCustomer;
$this->deleteCustomer = $deleteCustomer;
$this->registry =$registry;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
$this->registry =$registry;
$this->registry = $registry;

@eduard13 eduard13 added Auto-Tests: Covered All changes in Pull Request is covered by auto-tests Award: bug fix labels Jul 12, 2021
@engcom-Alfa
Copy link
Contributor

@magento run Static Tests, Magento Health Index

@magento-automated-testing
Copy link

The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.

@engcom-Alfa
Copy link
Contributor

✔️ QA Passed

Preconditions:

  1. Have Magento latest installed
  2. Make sure to have at least one working customer login.

Manual testing scenario:

  1. Get the customer token thru GraphQL request.

  2. GraphQl request with below mutation, and validate the response
    mutation { deleteCustomer }

Before: ✖️ We had no GraphQL mutation at all to delete the customer.
image

After: ✔️ Customer with given token in the GraphQL request header gets deleted successfully
image

Additional Testing scenarios:

  1. Deleted the customer thru above GraphQL mutation and tried to re-add the same customer from front end Create an account option.
  2. Kept the customer UI account with active login and deleted the account, validated the logged browser session get wiped put automatically.

There are no any additional testing is required as part of regression since there is an automation cases already covered.

@engcom-Alfa
Copy link
Contributor

Since there are a couple of auto jobs are getting failed, and so moving the ticket to Extended Testing.

Note: Before moving the ticket to Merge In Progress, we should have a devdoc updates request on this case!

@engcom-Charlie
Copy link
Contributor

@magento run all tests

@magento-automated-testing
Copy link

The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.

@engcom-Charlie
Copy link
Contributor

@magento run all tests

@magento-automated-testing
Copy link

The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.

@engcom-Charlie
Copy link
Contributor

@magento run Functional Tests B2B, Integration Tests, Magento Health Index

@magento-automated-testing
Copy link

The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.

@engcom-Charlie
Copy link
Contributor

engcom-Charlie commented May 18, 2022

The failing test of Functional B2B test is not part of this PR or not failing because of this PR changes.

Related to failed Magento Health Index test, raised approval JIRA ticket. Waiting for approval now.

Thank you!

@engcom-Charlie
Copy link
Contributor

@magento run all tests

@magento-automated-testing
Copy link

The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.

@engcom-Charlie
Copy link
Contributor

@magento run Magento Health Index , Functional Tests B2B, Functional Tests EE

@magento-automated-testing
Copy link

The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.

@engcom-Charlie
Copy link
Contributor

engcom-Charlie commented Aug 18, 2022

Raised new approval jira on adobe portal.

@cpartica can you please provide JIRA approval for Magento health Index.

Once we get the approval we can move this PR in Merge In Progress.

Thank you!

@engcom-Charlie
Copy link
Contributor

Since we got all the approvals for magento health index on JIRA moving this PR to Merge in Progress.

Thank you!

magento-devops-reposync-svc pushed a commit that referenced this pull request Sep 23, 2022
33383 GraphQL: add new mutation 'deleteCustomer' #33411
@magento-devops-reposync-svc magento-devops-reposync-svc merged commit ec794f1 into magento:2.4-develop Sep 23, 2022
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: bug fix Award: test coverage Component: CustomerGraphQl 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: accept Project: GraphQL Release Line: 2.4
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add deleteCustomer mutation
6 participants