diff --git a/codeception/_support/Page/Admin/CustomerManagePage.php b/codeception/_support/Page/Admin/CustomerManagePage.php index e22aed39f8c..e12be80e1ff 100644 --- a/codeception/_support/Page/Admin/CustomerManagePage.php +++ b/codeception/_support/Page/Admin/CustomerManagePage.php @@ -132,4 +132,34 @@ 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/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 */