Skip to content

Commit

Permalink
メンテナンス管理のE2Eテスト追加
Browse files Browse the repository at this point in the history
  • Loading branch information
nanasess committed Nov 25, 2021
1 parent c0121c0 commit a17039b
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 0 deletions.
41 changes: 41 additions & 0 deletions codeception/_support/Page/Admin/MaintenanceManagePage.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

/*
* This file is part of EC-CUBE
*
* Copyright(c) EC-CUBE CO.,LTD. All Rights Reserved.
*
* http://www.ec-cube.co.jp/
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Page\Admin;

class MaintenanceManagePage extends AbstractAdminPageStyleGuide
{
public static $完了メッセージ = '#page_admin_content_maintenance > div.c-container > div.c-contentsArea > div.alert.alert-success.alert-dismissible.fade.show.m-3 > span';

/**
* MaintenanceManagePage constructor.
*/
public function __construct(\AcceptanceTester $I)
{
parent::__construct($I);
}

public static function go($I)
{
$page = new self($I);

return $page->goPage('/content/maintenance', 'メンテナンス管理コンテンツ管理');
}

public function メンテナンス有効無効()
{
$this->tester->click('#page_admin_content_maintenance > div.c-container > div.c-contentsArea > form > div > div > div > div > div.card-body > div:nth-child(2) > div > button');

return $this;
}
}
45 changes: 45 additions & 0 deletions codeception/acceptance/EA06ContentsManagementCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@
use Page\Admin\LayoutManagePage;
use Page\Admin\NewsEditPage;
use Page\Admin\NewsManagePage;
use Page\Admin\MaintenanceManagePage;
use Page\Admin\PageEditPage;
use Page\Admin\PageManagePage;
use Page\Front\TopPage;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\Finder\Finder;

Expand Down Expand Up @@ -367,4 +369,47 @@ public function contentsmanagement_ブロック管理(AcceptanceTester $I)
$I->amOnPage('/');
$I->dontSeeElement(['id' => $block]);
}

public function contentsmanagement_メンテナンス管理(AcceptanceTester $I)
{
$I->wantTo('EA0607-UC08-T01_メンテナンス管理');

$I->expect('メンテナンスモードを有効にします');
MaintenanceManagePage::go($I)
->メンテナンス有効無効();
$I->see('メンテナンスモードを有効にしました。', MaintenanceManagePage::$完了メッセージ);

$I->expect('トップページを確認します');
$I->amOnPage('/');
$I->see('メンテナンスモードが有効になっています。', '#page_homepage > div.ec-maintenanceAlert > div');
$I->see('全ての商品', TopPage::$検索_カテゴリ選択);

$I->expect('ログアウトします');
$config = Fixtures::get('config');
$I->amOnPage('/'.$config['eccube_admin_route'].'/logout');

$I->expect('トップページを確認します');
$I->amOnPage('/');
$I->dontSee('メンテナンスモードが有効になっています。', '#page_homepage > div.ec-maintenanceAlert > div');
$I->see('ただいまメンテナンス中です。', 'body > div > div > div > div > p.ec-404Role__title.ec-reportHeading');

// 画面遷移がスムーズにいかない場合があるため、ログイン画面に遷移させておく
$account = Fixtures::get('admin_account');
$I->amOnPage('/'.$config['eccube_admin_route'].'/login');
$I->submitForm('#form1', [
'login_id' => $account['member'],
'password' => $account['password'],
]);

$I->expect('メンテナンスモードを無効にします');

MaintenanceManagePage::go($I)
->メンテナンス有効無効();
$I->see('メンテナンスモードを無効にしました。', MaintenanceManagePage::$完了メッセージ);

$I->expect('トップページを確認します');
$I->amOnPage('/');
$I->dontSee('メンテナンスモードが有効になっています。', '#page_homepage > div.ec-maintenanceAlert > div');
$I->see('全ての商品', TopPage::$検索_カテゴリ選択);
}
}

0 comments on commit a17039b

Please sign in to comment.