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 sorting on customer orders list #10639

Merged
merged 1 commit into from Aug 28, 2019
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -23,3 +23,11 @@ Feature: Browsing orders of a customer
Then I should see a single order in the list
And I should see the order with number "#00000007" in the list
And I should not see the order with number "#00000008" in the list

@ui
Scenario: Browsing orders of a specific customer in the list
When I browse orders of a customer "logan@wolverine.com"
And I sort them by channel
Then I should see a single order in the list
And I should see the order with number "#00000007" in the list
And I should not see the order with number "#00000008" in the list
12 changes: 10 additions & 2 deletions src/Sylius/Behat/Context/Ui/Admin/ManagingCustomersContext.php
Expand Up @@ -360,16 +360,24 @@ public function iChooseCreateAccountOption()
/**
* @When I browse orders of a customer :customer
*/
public function iBrowseOrdersOfACustomer(CustomerInterface $customer)
public function iBrowseOrdersOfACustomer(CustomerInterface $customer): void
{
$this->ordersIndexPage->open(['id' => $customer->getId()]);
}

/**
* @When I sort them by :sortBy
*/
public function iSortThemByChannel(string $sortBy): void
{
$this->ordersIndexPage->sort(ucfirst($sortBy));
}

/**
* @Then the customer :customer should have an account created
* @Then /^(this customer) should have an account created$/
*/
public function theyShouldHaveAnAccountCreated(CustomerInterface $customer)
public function theyShouldHaveAnAccountCreated(CustomerInterface $customer): void
{
Assert::notNull(
$customer->getUser()->getPassword(),
Expand Down
5 changes: 5 additions & 0 deletions src/Sylius/Behat/Page/Admin/Crud/IndexPage.php
Expand Up @@ -139,6 +139,11 @@ public function bulkDelete(): void
$this->getElement('confirmation_button')->click();
}

public function sort(string $order): void
{
$this->getDocument()->clickLink($order);
}

public function getRouteName(): string
{
return $this->routeName;
Expand Down
2 changes: 2 additions & 0 deletions src/Sylius/Behat/Page/Admin/Crud/IndexPageInterface.php
Expand Up @@ -37,4 +37,6 @@ public function countItems(): int;
public function filter(): void;

public function bulkDelete(): void;

public function sort(string $order): void;
}
Expand Up @@ -61,11 +61,9 @@ public function createListQueryBuilder(): QueryBuilder
*/
public function createByCustomerIdQueryBuilder($customerId): QueryBuilder
{
return $this->createQueryBuilder('o')
return $this->createListQueryBuilder()
->andWhere('o.customer = :customerId')
->andWhere('o.state != :state')
->setParameter('customerId', $customerId)
->setParameter('state', OrderInterface::STATE_CART)
;
}

Expand Down