Skip to content

Commit

Permalink
会員一覧の根ソートのE2Eテスト
Browse files Browse the repository at this point in the history
  • Loading branch information
h.matsuo committed Feb 9, 2022
1 parent 2a84bec commit ddc5b0a
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
30 changes: 30 additions & 0 deletions codeception/_support/Page/Admin/CustomerManagePage.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
26 changes: 26 additions & 0 deletions codeception/acceptance/EA05CustomerCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down

0 comments on commit ddc5b0a

Please sign in to comment.