Skip to content

Commit

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

0 comments on commit 2a84bec

Please sign in to comment.