Skip to content

Commit

Permalink
Merge pull request #5297 from chihiro-adachi/add-e2e-tests
Browse files Browse the repository at this point in the history
タグ検索のe2eテストを追加
  • Loading branch information
matsuoshi authored Feb 10, 2022
2 parents 1a871a2 + 032066f commit 710b64c
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 2 deletions.
30 changes: 30 additions & 0 deletions codeception/_support/Page/Admin/ProductManagePage.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,35 @@ public function 詳細検索_ステータス($value)
return $this;
}

public function 検索_入力_フリー検索($value)
{
$this->tester->fillField(self::$検索条件_プロダクト, $value);

return $this;
}

public function 詳細検索_入力_タグ($value)
{
$this->tester->selectOption(['id' => 'admin_search_product_tag_id'], 1);

return $this;
}

public function 詳細検索ボタンをクリック()
{
$this->tester->click(self::$詳細検索ボタン);

return $this;
}

public function 検索を実行()
{
$this->tester->click(self::$検索ボタン);
$this->tester->see('商品一覧商品管理', '.c-pageTitle');

return $this;
}

/**
* 検索結果の指定した行の規格設定に遷移。
*
Expand Down Expand Up @@ -251,6 +280,7 @@ public function CSVヘッダ取得()
{
$this->tester->wait(5);
$csv = $this->tester->getLastDownloadFile('/^product_\d{14}\.csv$/');

return mb_convert_encoding(file($csv)[0], 'UTF-8', 'SJIS-win');
}

Expand Down
53 changes: 51 additions & 2 deletions codeception/acceptance/EA03ProductCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -864,7 +864,7 @@ public function product_タグ登録(AcceptanceTester $I)
// タグが作成されていないことを確認
$I->dontSee('保存しました', ProductTagPage::$アラートメッセージ);

$tagName = 'new-tag ' . uniqid();
$tagName = 'new-tag '.uniqid();

ProductTagPage::go($I)
->入力_タグ名($tagName)
Expand All @@ -878,7 +878,7 @@ public function product_タグ編集(AcceptanceTester $I)
{
$I->wantTo('EA0308-UC02-T01 タグ編集');

$tagName = 'edit-tag ' . uniqid();
$tagName = 'edit-tag '.uniqid();

ProductTagPage::go($I)
->タグ編集_開始(1)
Expand Down Expand Up @@ -949,4 +949,53 @@ public function product_商品編集からの商品確認_非公開(AcceptanceTe
$I->switchToNewWindow();
$I->seeInCurrentUrl('/products/detail/');
}

public function product_詳細検索_タグ(AcceptanceTester $I)
{
$I->wantTo('EA0311-UC01-T01 詳細検索 (タグ)');

$name = uniqid();
$entityManager = Fixtures::get('entityManager');
$createProduct = Fixtures::get('createProduct');
/** @var \Eccube\Entity\Product $Product */
$Product = $createProduct($name);
foreach ($Product->getProductTag() as $ProductTag) {
$Product->removeProductTag($ProductTag);
$entityManager->remove($ProductTag);
}
$entityManager->flush();

// タグを指定して検索 -> 0
ProductManagePage::go($I)
->検索_入力_フリー検索($name)
->詳細検索ボタンをクリック()
->詳細検索_入力_タグ(1)
->検索を実行();

$I->see('検索結果:0件が該当しました', ProductManagePage::$検索結果_メッセージ);

// 編集画面へ移動
ProductManagePage::go($I)
->検索($name)
->検索結果_選択(1);

// タグ登録
(new ProductEditPage($I))
->クリックして開くタグリスト()
->クリックして選択タグ(2)
->クリックして選択タグ(3)
->クリックして選択タグ(4)
->登録();

$I->see('保存しました', 'div.c-container > div.c-contentsArea > div.alert');

// タグを指定して検索 -> 1
ProductManagePage::go($I)
->検索_入力_フリー検索($name)
->詳細検索ボタンをクリック()
->詳細検索_入力_タグ(1)
->検索を実行();

$I->see('検索結果:1件が該当しました', ProductManagePage::$検索結果_メッセージ);
}
}

0 comments on commit 710b64c

Please sign in to comment.