diff --git a/codeception/_support/Page/Admin/OrderManagePage.php b/codeception/_support/Page/Admin/OrderManagePage.php index 9d659a16a93..76f666d0146 100644 --- a/codeception/_support/Page/Admin/OrderManagePage.php +++ b/codeception/_support/Page/Admin/OrderManagePage.php @@ -280,4 +280,38 @@ public function 件数変更($num) return $this; } + + public function assertSortedStatusList($order) + { + $values = $this->tester->grabMultiple('.c-contentsArea__primaryCol tr > td:nth-child(4)'); + $expect = $values; + usort($expect, function ($a, $b) { + // order_status でソート + $statusList = ['新規受付', '入金済み', '対応中', '注文取消し', '発送済み', '決済処理中', '購入処理中', '返品']; + return array_search($a, $statusList) > array_search($b, $statusList); + }); + + if ($order === 'desc') { + $expect = array_reverse($expect); + } + + $this->tester->assertEquals($expect, $values); + } + + public function assertSortedPriceList($order) + { + $values = array_map(function($s) { + // 一覧の購入金額の文字列から金額だけを抽出 + return preg_replace('/\D/', '', $s); + }, $this->tester->grabMultiple('.c-contentsArea__primaryCol tr > td:nth-child(5)')); + + $expect = $values; + if ($order === 'asc') { + sort($expect); + } else { + rsort($expect); + } + + $this->tester->assertEquals($expect, $values); + } } diff --git a/codeception/acceptance/EA04OrderCest.php b/codeception/acceptance/EA04OrderCest.php index 36d6078ee88..d1746cbe1bd 100644 --- a/codeception/acceptance/EA04OrderCest.php +++ b/codeception/acceptance/EA04OrderCest.php @@ -244,6 +244,32 @@ public function order_受注削除(AcceptanceTester $I) $I->assertEquals($OrderNumForDontDel, $OrderListPage->一覧_注文番号(1)); } + public function order_一覧でのソート(AcceptanceTester $I) + { + $I->wantTo('EA0401-UC09-T01 一覧でのソート'); + $page = OrderManagePage::go($I); + + // 対応状況横の上矢印をクリック + $I->click('a[data-sortkey="order_status"]'); + $I->seeElement('.listSort-current[data-sortkey="order_status"] .fa-arrow-up'); + $page->assertSortedStatusList('asc'); + + // 対応状況横の下矢印をクリック + $I->click('a[data-sortkey="order_status"]'); + $I->seeElement('.listSort-current[data-sortkey="order_status"] .fa-arrow-down'); + $page->assertSortedStatusList('desc'); + + // 購入金額横の上矢印をクリック + $I->click('[data-sortkey="purchase_price"]'); + $I->seeElement('.listSort-current[data-sortkey="purchase_price"] .fa-arrow-up'); + $page->assertSortedPriceList('asc'); + + // 購入金額横の下矢印をクリック + $I->click('a[data-sortkey="purchase_price"]'); + $I->seeElement('.listSort-current[data-sortkey="purchase_price"] .fa-arrow-down'); + $page->assertSortedPriceList('desc'); + } + /** * @group vaddy */