Skip to content

Commit

Permalink
Merge pull request #6192 from dotani1111/dev/add_e2e_mail_template
Browse files Browse the repository at this point in the history
add:E2E test for create mail template.
  • Loading branch information
ji-eunsoo committed May 15, 2024
2 parents 7654034 + d2463fe commit 892d53e
Show file tree
Hide file tree
Showing 4 changed files with 119 additions and 0 deletions.
39 changes: 39 additions & 0 deletions codeception/_support/Page/Admin/MailSettingsPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,43 @@ public function 登録()

return $this;
}
public function 入力_新規テンプレート名(string $value)
{
$this->tester->fillField(['id' => 'mail_name'], $value);

return $this;
}

public function 入力_ファイル名(string $value)
{
$this->tester->fillField(['id' => 'mail_file_name'], $value);

return $this;
}

public function 入力_テキスト(string $value)
{
$this->tester->fillField('#editor > textarea', $value);

return $this;

}

public function 入力_HTML(string $value)
{
$this->tester->fillField('#html_editor > textarea', $value);

return $this;
}

public function 削除_テンプレート()
{
$this->tester->click('#form1 > div.c-contentsArea__cols > div > div > div > div.card-body > div:nth-child(1) > div:nth-child(3) > button');
$this->tester->wait(1);
$this->tester->click('#deleteModal > div > div > div.modal-footer > a > span.ladda-label');

return $this;
}


}
1 change: 1 addition & 0 deletions codeception/_support/Page/Admin/OrderEditPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class OrderEditPage extends AbstractAdminPageStyleGuide
public static $ポイント値引き額 = '//span[contains(text(), "ポイント")]/parent::div/following-sibling::div/span';
public static $利用ポイント = '#order_use_point';
public static $加算ポイント = '//span[contains(text(), "加算ポイント")]/parent::div/following-sibling::div/span';
public static $メール送信完了メッセージ = '#page_admin_order_edit > div.c-container > div.c-contentsArea > div.alert.alert-success.alert-dismissible.fade.show.m-3';

/**
* OrderRegisterPage constructor.
Expand Down
31 changes: 31 additions & 0 deletions codeception/_support/Page/Admin/OrderManagePage.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ public function PDFフォームを入力($elId, $value)
public function 一覧_編集($rowNum)
{
$this->tester->click("#search_result > tbody > tr:nth-child(${rowNum}) a.action-edit");

return $this;
}

public function 一覧_削除()
Expand Down Expand Up @@ -319,4 +321,33 @@ public function assertSortedPriceList($order)

$this->tester->assertEquals($expect, $values);
}

public function 遷移_メールを作成()
{
// メール履歴が多いと、フッターに隠れるため
$this->tester->wait(1);
$this->tester->scrollTo('#mailHistory > div > div > a');
$this->tester->wait(1);
$this->tester->seeElement('#mailHistory > div > div > a');
$this->tester->click('#mailHistory > div > div > a');
$this->tester->wait(1);
$this->tester->click('#confirmFormChangeModal > div > div > div.modal-footer > a.btn.btn-ec-sub');

return $this;
}

public function 選択_メールテンプレート($value)
{
$this->tester->selectOption('#template-change', $value);

return $this;
}

public function メール送信()
{
$this->tester->click("#order-mail-form > div.c-conversionArea > div > div > div:nth-child(2) > div > div > button");
$this->tester->click("#order-mail-form > div > div.c-conversionArea > div > div > div:nth-child(2) > div > div > button");

return $this;
}
}
48 changes: 48 additions & 0 deletions codeception/acceptance/EA07BasicinfoCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -860,6 +860,54 @@ public function basicinfo_メール設定(AcceptanceTester $I)
$I->seeInLastEmailSubject("[サンプルショップ] {$title}");
}

/**
* @group vaddy
* @group mailsetting
*/
public function basicinfo_メール設定_テンプレート新規作成_削除(AcceptanceTester $I)
{
$I->wantTo('EA0709-UC02-T02 メール設定_テンプレート新規作成_削除');

$id = uniqid();
$title = 'title'.$id;
$template_name = 'template'.$id;
$file_name = 'filename'.$id;
$text = 'text'.$id;
$html = '<p>HTML</p>'.$id;

/** テンプレート作成 */
MailSettingsPage::go($I)
->入力_新規テンプレート名($template_name)
->入力_ファイル名($file_name)
->入力_件名($title)
->入力_テキスト($text)
->入力_HTML($html)
->登録();

$I->waitForText('保存しました', 10, MailSettingsPage::$登録完了メッセージ);

/** 受注メールから送信して確認する */
$I->resetEmails();
OrderManagePage::go($I)->検索()
->一覧_編集(1)
->遷移_メールを作成()
->選択_メールテンプレート($template_name)
->メール送信();

// 送信メール確認
$I->waitForText('メールを送信しました。', 10, OrderEditPage::$メール送信完了メッセージ);
$message = $I->lastMessage();
$I->assertCount(2, $message->getRecipients(), 'Bcc で管理者にも送信するので宛先アドレスは2つ');
$I->seeEmailCount(1);

$baseinfo = Fixtures::get('baseinfo');
$I->seeInLastEmailSubjectTo('admin@example.com', $title);

/** メールテンプレート削除 */
MailSettingsPage::go($I)->入力_テンプレート($template_name)->削除_テンプレート();
$I->waitForText('削除しました',10,'#page_admin_setting_shop_mail > div.c-container > div.c-contentsArea > div.alert.alert-success.alert-dismissible.fade.show.m-3 > span');
}

/**
* @group vaddy
* @group csvsetting
Expand Down

0 comments on commit 892d53e

Please sign in to comment.