diff --git a/codeception/_support/Page/Admin/CustomerManagePage.php b/codeception/_support/Page/Admin/CustomerManagePage.php index e22aed39f8c..d3997d42ab6 100644 --- a/codeception/_support/Page/Admin/CustomerManagePage.php +++ b/codeception/_support/Page/Admin/CustomerManagePage.php @@ -132,4 +132,35 @@ public function 一覧_会員ID($rowNum) { return $this->tester->grabTextFrom("#search_form > div.c-contentsArea__cols > div > div > div.card.rounded.border-0.mb-4 > div > table > tbody > tr:nth-child(${rowNum}) > td.align-middle.pl-3"); } + + public function assertSortedIdList($order) + { + $values = $this->tester->grabMultiple('.c-contentsArea__primaryCol tr > td:nth-child(1)'); + + $expect = $values; + if ($order === 'asc') { + sort($expect); + } else { + rsort($expect); + } + + $this->tester->assertEquals($expect, $values); + } + + public function assertSortedNameList($order) + { + $values = array_map(function($s) { + // 一覧の会員名の文字列から姓だけを抽出 + return preg_replace('/ .*$/', '', $s); + }, $this->tester->grabMultiple('.c-contentsArea__primaryCol tr > td:nth-child(2)')); + + $expect = $values; + if ($order === 'asc') { + sort($expect); + } else { + rsort($expect); + } + + $this->tester->assertEquals($expect, $values); + } } diff --git a/codeception/_support/Page/Admin/OrderManagePage.php b/codeception/_support/Page/Admin/OrderManagePage.php index 9d659a16a93..4df3e345d52 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 (int)preg_replace('/(\n.*|\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/_support/Page/Admin/ProductManagePage.php b/codeception/_support/Page/Admin/ProductManagePage.php index 310778d3cb8..06f1ebddcd3 100644 --- a/codeception/_support/Page/Admin/ProductManagePage.php +++ b/codeception/_support/Page/Admin/ProductManagePage.php @@ -277,4 +277,18 @@ public function 一括削除完了() return $this; } + + public function assertSortedList($index, $order) + { + $values = $this->tester->grabMultiple('.c-contentsArea__primaryCol tr > td:nth-child('.$index.')'); + + $expect = $values; + if ($order === 'asc') { + sort($expect); + } else { + rsort($expect); + } + + $this->tester->assertEquals($expect, $values); + } } diff --git a/codeception/acceptance/EA03ProductCest.php b/codeception/acceptance/EA03ProductCest.php index 731e6b27e0e..ee7b1ee000b 100644 --- a/codeception/acceptance/EA03ProductCest.php +++ b/codeception/acceptance/EA03ProductCest.php @@ -186,6 +186,32 @@ public function product_CSV出力項目設定(AcceptanceTester $I) $I->assertNotContains('フリーエリア', $csvHeader); } + public function product_一覧でのソート(AcceptanceTester $I) + { + $I->wantTo('EA0301-UC03-T01 一覧でのソート'); + $page = ProductManagePage::go($I); + + // 商品一覧・ID横の上矢印をクリック + $I->click('[data-sortkey="product_id"]'); + $I->seeElement('.listSort-current[data-sortkey="product_id"] .fa-arrow-up'); + $page->assertSortedList(2, 'asc'); + + // ID横の下矢印をクリック + $I->click('[data-sortkey="product_id"]'); + $I->seeElement('.listSort-current[data-sortkey="product_id"] .fa-arrow-down'); + $page->assertSortedList(2, 'desc'); + + // 更新日横の上矢印をクリック + $I->click('[data-sortkey="update_date"]'); + $I->seeElement('.listSort-current[data-sortkey="update_date"] .fa-arrow-up'); + $page->assertSortedList(10, 'asc'); + + // 更新日横の下矢印をクリック + $I->click('[data-sortkey="update_date"]'); + $I->seeElement('.listSort-current[data-sortkey="update_date"] .fa-arrow-down'); + $page->assertSortedList(10, 'desc'); + } + public function product_一覧からの規格編集規格なし失敗(AcceptanceTester $I) { $I->wantTo('EA0310-UC01-T02 一覧からの規格編集 規格なし 失敗'); 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 */ diff --git a/codeception/acceptance/EA05CustomerCest.php b/codeception/acceptance/EA05CustomerCest.php index 51ac2c561dd..eb9032377d2 100644 --- a/codeception/acceptance/EA05CustomerCest.php +++ b/codeception/acceptance/EA05CustomerCest.php @@ -70,6 +70,32 @@ public function customer_検索エラー(AcceptanceTester $I) $I->see('検索条件に誤りがあります', CustomerManagePage::$検索結果_エラーメッセージ); } + public function customer_一覧でのソート(AcceptanceTester $I) + { + $I->wantTo('EA0501-UC07-T01 一覧でのソート'); + $page = CustomerManagePage::go($I); + + // ID横の上矢印をクリック + $I->click('a[data-sortkey="customer_id"]'); + $I->seeElement('.listSort-current[data-sortkey="customer_id"] .fa-arrow-up'); + $page->assertSortedIdList('asc'); + + // ID横の下矢印をクリック + $I->click('a[data-sortkey="customer_id"]'); + $I->seeElement('.listSort-current[data-sortkey="customer_id"] .fa-arrow-down'); + $page->assertSortedIdList('desc'); + + // 名前横の上矢印をクリック + $I->click('[data-sortkey="name"]'); + $I->seeElement('.listSort-current[data-sortkey="name"] .fa-arrow-up'); + $page->assertSortedNameList('asc'); + + // 名前横の下矢印をクリック + $I->click('a[data-sortkey="name"]'); + $I->seeElement('.listSort-current[data-sortkey="name"] .fa-arrow-down'); + $page->assertSortedNameList('desc'); + } + /** * @group vaddy */