Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

E2Eテスト追加 商品一覧/受注一覧/会員一覧ページのソート機能 #5296

Merged
merged 4 commits into from
Feb 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions codeception/_support/Page/Admin/CustomerManagePage.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
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 (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);
}
}
14 changes: 14 additions & 0 deletions codeception/_support/Page/Admin/ProductManagePage.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
26 changes: 26 additions & 0 deletions codeception/acceptance/EA03ProductCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 一覧からの規格編集 規格なし 失敗');
Expand Down
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
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