diff --git a/features/seeing_refund_payments_on_admin_order_view.feature b/features/seeing_refund_payments_on_admin_order_view.feature index 9459a69c..493f5c7b 100644 --- a/features/seeing_refund_payments_on_admin_order_view.feature +++ b/features/seeing_refund_payments_on_admin_order_view.feature @@ -26,3 +26,10 @@ Feature: Seeing refund payments on admin order view Scenario: Seeing refund payment on order view When I view the summary of the order "#00000022" Then I should see 1 refund payment with status "New" + + @ui + Scenario: Having all credit memos listed on the order page in ascending order + Given the "#00000022" order's shipping cost already has a refund of "$2.50" with "Space money" payment + When I view the summary of the order "#00000022" + Then I should see the credit memo with "$10.00" total as 1st in the list + And I should see the credit memo with "$2.50" total as 2nd in the list diff --git a/features/viewing_details_of_credit_memo.feature b/features/viewing_details_of_credit_memo.feature index c51e3e06..88d61772 100644 --- a/features/viewing_details_of_credit_memo.feature +++ b/features/viewing_details_of_credit_memo.feature @@ -55,11 +55,3 @@ Feature: Viewing details of a credit memo And it should contain 1 "Galaxy Post" shipment with "4.50" gross value in "USD" currency And it should be issued in "United States" channel And its total should be "4.50" in "USD" currency - - @ui - Scenario: Having all credit memos listed on the order page in ascending order - Given the "#00000022" order's shipping cost already has a refund of "$4.50" with "Space money" payment - And the 1st "PHP T-Shirt" product from order "#00000022" has a refund of "$5.50" with "Space money" payment - When I view the summary of the order "#00000022" - Then I should see "4.50" credit memo as 1st in the list - And I should see "5.50" credit memo as 2nd in the list diff --git a/src/Doctrine/ORM/CreditMemoRepository.php b/src/Doctrine/ORM/CreditMemoRepository.php index b464c231..10eae04e 100644 --- a/src/Doctrine/ORM/CreditMemoRepository.php +++ b/src/Doctrine/ORM/CreditMemoRepository.php @@ -20,9 +20,9 @@ class CreditMemoRepository extends EntityRepository implements CreditMemoReposit { public function findByOrderId(string $orderId): array { - return $this->createQueryBuilder('c') - ->andWhere('c.order = :orderId') - ->addOrderBy('c.issuedAt', 'ASC') + return $this->createQueryBuilder('o') + ->andWhere('o.order = :orderId') + ->addOrderBy('o.issuedAt', 'ASC') ->setParameter('orderId', $orderId) ->getQuery() ->getResult() diff --git a/tests/Behat/Context/Ui/CreditMemoContext.php b/tests/Behat/Context/Ui/CreditMemoContext.php index 3221a077..b0ba62d4 100644 --- a/tests/Behat/Context/Ui/CreditMemoContext.php +++ b/tests/Behat/Context/Ui/CreditMemoContext.php @@ -287,10 +287,10 @@ public function pdfFileShouldBeSuccessfullyDownloaded(): void } /** - * @Then /^I should see "([^"]+)" credit memo as (\d+)(?:|st|nd|rd|th) in the list$/ + * @Then /^I should see the credit memo with "([^"]+)" total as (\d+)(?:|st|nd|rd|th) in the list$/ */ - public function iShouldCreditMemoOrderByAscInTheList(string $creditMemo, int $position): void + public function iShouldCreditMemoOrderByAscInTheList(string $creditMemoTotal, int $position): void { - Assert::true($this->creditMemoDetailsPage->isCreditMemoInPosition($creditMemo, $position)); + Assert::true($this->creditMemoDetailsPage->isCreditMemoInPosition($creditMemoTotal, $position)); } } diff --git a/tests/Behat/Page/Admin/CreditMemoDetailsPage.php b/tests/Behat/Page/Admin/CreditMemoDetailsPage.php index 87321c3c..706198bd 100644 --- a/tests/Behat/Page/Admin/CreditMemoDetailsPage.php +++ b/tests/Behat/Page/Admin/CreditMemoDetailsPage.php @@ -139,11 +139,11 @@ public function isCreditMemoInPosition(string $creditMemo, int $position): bool protected function getDefinedElements(): array { return array_merge(parent::getDefinedElements(), [ + 'credit_memo_in_given_position' => 'table tbody tr:nth-child(%position%) td:contains("%creditMemo%")', 'table' => 'table', 'tax_item_amount' => 'tr.tax-item:contains("%label%") .tax-item-amount', 'total' => '#credit-memo-total', 'total_currency_code' => '#credit-memo-total-currency-code', - 'credit_memo_in_given_position' => 'table tbody tr:nth-child(%position%) td:contains("%creditMemo%")', ]); } }