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

[Admin] Fix deleting customer account #17445

Merged
merged 1 commit into from
Nov 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,19 @@ Feature: Deleting the customer account
And there is a user "theodore@example.com" identified by "pswd"
And I am logged in as an administrator

@api @ui
@api @no-ui
Scenario: Deleting account should not delete customer details
When I delete the account of "theodore@example.com" user
Then the user account should be deleted
But the customer with this email should still exist

@no-api @ui
Scenario: Deleting account should not delete customer details
When I delete the account of "theodore@example.com" user
Then I should be notified that it has been successfully deleted
And the customer should have no account
But the customer with this email should still exist

@api @ui
Scenario: A customer with no user cannot be deleted
Given the account of "theodore@example.com" was deleted
Expand Down
5 changes: 2 additions & 3 deletions src/Sylius/Behat/Context/Ui/UserContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,11 @@ public function iDeleteAccount($email)
}

/**
* @Then the user account should be deleted
* @Then the customer should have no account
*/
public function accountShouldBeDeleted()
public function theCustomerShouldHaveNoAccount(): void
{
$deletedUser = $this->sharedStorage->get('deleted_user');

$this->customerShowPage->open(['id' => $deletedUser->getCustomer()->getId()]);

Assert::false($this->customerShowPage->hasAccount());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{% set user = hookable_metadata.context.resource.user %}
{% set customer = hookable_metadata.context.resource %}
{% set user = customer.user %}

{% if user != null %}
<form action="{{ path('sylius_admin_shop_user_delete', {'id': user.id}) }}" method="POST">
<form action="{{ path('sylius_admin_shop_user_delete', {'id': user.id, 'customerId': customer.id}) }}" method="POST">
<input type="hidden" name="_method" value="DELETE" />
<input type="hidden" name="_csrf_token" value="{{ csrf_token(user.id) }}" />
<button type="submit" class="dropdown-item" {{ sylius_test_html_attribute('customer-actions-delete') }}>
Expand Down
Loading