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

規格・規格分類:「CSV登録」作成, 「CSVダウンロード・CSV出力項目設定」追加 #5043

Merged
merged 9 commits into from Apr 12, 2024
78 changes: 78 additions & 0 deletions app/DoctrineMigrations/Version20220603074035.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<?php declare(strict_types=1);

namespace DoctrineMigrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20220603074035 extends AbstractMigration
{
public function up(Schema $schema) : void
{
// this up() migration is auto-generated, please modify it to your needs

$statusExists = $this->connection->fetchColumn(
'SELECT COUNT(*) FROM mtb_csv_type WHERE id = 6'
);
if ($statusExists == 0) {
$this->addSql("INSERT INTO mtb_csv_type ('id', 'name', 'sort_no', 'discriminator_type') VALUES (6, 'Class NameCSV', 6, 'csvtype');");
}
$statusExists = $this->connection->fetchColumn(
'SELECT COUNT(*) FROM mtb_csv_type WHERE id = 7'
);
if ($statusExists == 0) {
$this->addSql("INSERT INTO mtb_csv_type ('id', 'name', 'sort_no', 'discriminator_type') VALUES (7, 'Class Category CSV', 7, 'csvtype');");
}
$statusExists = $this->connection->fetchColumn(
'SELECT COUNT(*) FROM dtb_csv WHERE id = 206'
);
if ($statusExists == 0) {
$this->addSql("INSERT INTO dtb_csv ('id','csv_type_id','creator_id','entity_name','field_name','reference_field_name','disp_name','sort_no','enabled','create_date','update_date','discriminator_type') VALUES ('206','6',,'Eccube\\Entity\\ClassName','id',,'規格ID','1','1','2021-05-18 01:26:41','2021-05-18 01:26:41','csv');");
}
$statusExists = $this->connection->fetchColumn(
'SELECT COUNT(*) FROM dtb_csv WHERE id = 207'
);
if ($statusExists == 0) {
$this->addSql("INSERT INTO dtb_csv ('id','csv_type_id','creator_id','entity_name','field_name','reference_field_name','disp_name','sort_no','enabled','create_date','update_date','discriminator_type') VALUES ('207','6',,'Eccube\\Entity\\ClassName','name',,'規格名','2','1','2021-05-18 01:26:41','2021-05-18 01:26:41','csv');");
}
$statusExists = $this->connection->fetchColumn(
'SELECT COUNT(*) FROM dtb_csv WHERE id = 208'
);
if ($statusExists == 0) {
$this->addSql("INSERT INTO dtb_csv ('id','csv_type_id','creator_id','entity_name','field_name','reference_field_name','disp_name','sort_no','enabled','create_date','update_date','discriminator_type') VALUES ('208','6',,'Eccube\\Entity\\ClassName','backend_name',,'管理名','3','1','2021-05-18 01:26:41','2021-05-18 01:26:41','csv');");
}
$statusExists = $this->connection->fetchColumn(
'SELECT COUNT(*) FROM dtb_csv WHERE id = 209'
);
if ($statusExists == 0) {
$this->addSql("INSERT INTO dtb_csv ('id','csv_type_id','creator_id','entity_name','field_name','reference_field_name','disp_name','sort_no','enabled','create_date','update_date','discriminator_type') VALUES ('209','7',,'Eccube\\Entity\\ClassCategory','id',,'規格分類ID','1','1','2021-05-18 01:26:41','2021-05-18 01:26:41','csv');");
}
$statusExists = $this->connection->fetchColumn(
'SELECT COUNT(*) FROM dtb_csv WHERE id = 210'
);
if ($statusExists == 0) {
$this->addSql("INSERT INTO dtb_csv ('id','csv_type_id','creator_id','entity_name','field_name','reference_field_name','disp_name','sort_no','enabled','create_date','update_date','discriminator_type') VALUES ('210','7',,'Eccube\\Entity\\ClassCategory','ClassName','id','規格ID','2','1','2021-05-18 01:26:41','2021-05-18 01:26:41','csv');");
}
$statusExists = $this->connection->fetchColumn(
'SELECT COUNT(*) FROM dtb_csv WHERE id = 211'
);
if ($statusExists == 0) {
$this->addSql("INSERT INTO dtb_csv ('id','csv_type_id','creator_id','entity_name','field_name','reference_field_name','disp_name','sort_no','enabled','create_date','update_date','discriminator_type') VALUES ('211','7',,'Eccube\\Entity\\ClassCategory','name',,'規格分類名','3','1','2021-05-18 01:26:41','2021-05-18 01:26:41','csv');");
}
$statusExists = $this->connection->fetchColumn(
'SELECT COUNT(*) FROM dtb_csv WHERE id = 212'
);
if ($statusExists == 0) {
$this->addSql("INSERT INTO dtb_csv ('id','csv_type_id','creator_id','entity_name','field_name','reference_field_name','disp_name','sort_no','enabled','create_date','update_date','discriminator_type') VALUES ('212','7',,'Eccube\\Entity\\ClassCategory','backend_name',,'分類管理名','4','1','2021-05-18 01:26:41','2021-05-18 01:26:41','csv');");
}
}

public function down(Schema $schema) : void
{
// this down() migration is auto-generated, please modify it to your needs

}
}
6 changes: 6 additions & 0 deletions app/config/eccube/packages/eccube_nav.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ parameters:
product_csv_import:
name: admin.product.product_csv_upload
url: admin_product_csv_import
class_name_csv_import:
name: admin.product.class_name_csv_upload
url: admin_product_class_name_csv_import
class_category_csv_import:
name: admin.product.class_category_csv_upload
url: admin_product_class_category_csv_import
category_csv_import:
name: admin.product.category_csv_upload
url: admin_product_category_csv_import
Expand Down
4 changes: 4 additions & 0 deletions codeception/_data/class_category.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
規格ID,規格分類ID,規格分類名,規格分類管理名,規格分類削除フラグ
1,,アップロード規格分類1,,
1,,アップロード規格分類2,,
1,,アップロード規格分類3,,
4 changes: 4 additions & 0 deletions codeception/_data/class_name.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
規格ID,規格名,管理名,規格削除フラグ
,アップロード規格1,,
,アップロード規格2,,
,アップロード規格3,,
55 changes: 55 additions & 0 deletions codeception/_support/Page/Admin/ClassCategoryCsvUploadPage.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?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 ClassCategoryCsvUploadPage extends AbstractAdminPageStyleGuide
{
public static $完了メッセージ = '.c-container div.c-contentsArea > div.alert-success';

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

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

return $page->goPage('/product/class_category_csv_upload', '規格分類CSV登録商品管理');
}

public function 入力_CSVファイル($fileName)
{
$this->tester->attachFile(['id' => 'admin_csv_import_import_file'], $fileName);

return $this;
}

public function CSVアップロード()
{
$this->tester->click(['id' => 'upload-button']);

return $this;
}

public function 雛形ダウンロード()
{
$this->tester->click('#download-button');

return $this;
}
}
17 changes: 17 additions & 0 deletions codeception/_support/Page/Admin/ClassCategoryManagePage.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,18 @@ public function acceptModal()
return $this;
}

public function CSVダウンロード実行()
{
$this->tester->click('body > div > div.c-contentsArea > div.c-outsideBlock > div > div > div.col-6.text-end > div > a:nth-child(1)');

return $this;
}

public function CSV出力項目設定()
{
$this->tester->click('body > div > div.c-contentsArea > div.c-outsideBlock > div > div > div.col-6.text-end > div > a:nth-child(2)');
}

public function 一覧_上に($rowNum)
{
$this->tester->dragAndDropBy("ul.list-group > li:nth-child(${rowNum})", 0, -60);
Expand All @@ -103,4 +115,9 @@ public function 一覧_名称($rowNum)
{
return "ul.list-group > li:nth-child(${rowNum}) > div > div.col.d-flex.align-items-center";
}

public static function XPathでタグを取得する($textEl)
{
return '//*[@id="page_admin_product_class_category"]/div[1]/div[3]/div[2]/div[1]/div/div[3]/div[2]/div/ul/li/div/div[3][contains(text(), "'.$textEl.'")]';
}
}
55 changes: 55 additions & 0 deletions codeception/_support/Page/Admin/ClassNameCsvUploadPage.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?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 ClassNameCsvUploadPage extends AbstractAdminPageStyleGuide
{
public static $完了メッセージ = '.c-container div.c-contentsArea > div.alert-success';

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

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

return $page->goPage('/product/class_name_csv_upload', '規格CSV登録商品管理');
}

public function 入力_CSVファイル($fileName)
{
$this->tester->attachFile(['id' => 'admin_csv_import_import_file'], $fileName);

return $this;
}

public function CSVアップロード()
{
$this->tester->click(['id' => 'upload-button']);

return $this;
}

public function 雛形ダウンロード()
{
$this->tester->click('#download-button');

return $this;
}
}
24 changes: 24 additions & 0 deletions codeception/_support/Page/Admin/ClassNameManagePage.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,13 @@ public function 一覧_分類登録($rowNum)
return $this;
}

public function 一覧_分類登録2()
{
$this->tester->click("ul.list-group > li:last-child > div > div.col.d-flex.align-items-center > a");

return $this;
}

public function 一覧_編集($rowNum)
{
$this->tester->click("ul.list-group > li:nth-child(${rowNum}) > div > div.col-auto.text-end > a.action-edit");
Expand All @@ -103,6 +110,18 @@ public function acceptModal()
return $this;
}

public function CSVダウンロード実行()
{
$this->tester->click('body > div > div.c-contentsArea > div.c-outsideBlock > div > div > div.col-6.text-end > div > a:nth-child(1)');

return $this;
}

public function CSV出力項目設定()
{
$this->tester->click('body > div > div.c-contentsArea > div.c-outsideBlock > div > div > div.col-6.text-end > div > a:nth-child(2)');
}

public function 一覧_上に($rowNum)
{
$this->tester->dragAndDropBy("ul.list-group > li:nth-child(${rowNum})", 0, -60);
Expand All @@ -116,4 +135,9 @@ public function 一覧_下に($rowNum)

return $this;
}

public static function XPathでタグを取得する($textEl)
{
return '//*[@id="page_admin_product_class_name"]/div[1]/div[3]/div[3]/div[1]/div/div/div/div/ul/li/div/div[3]/a[contains(text(), "'.$textEl.'")]';
}
}
88 changes: 88 additions & 0 deletions codeception/acceptance/EA03ProductCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
use Doctrine\DBAL\Connection;
use Doctrine\ORM\EntityManager;
use Page\Admin\CategoryCsvUploadPage;
use Page\Admin\ClassNameCsvUploadPage;
use Page\Admin\ClassCategoryCsvUploadPage;
use Page\Admin\CategoryManagePage;
use Page\Admin\ClassCategoryManagePage;
use Page\Admin\ClassNameManagePage;
Expand Down Expand Up @@ -872,6 +874,92 @@ public function product_カテゴリCSV登録雛形ファイルダウンロー
$I->assertEquals(1, count(file($CategoryTemplateCSV)), 'ヘッダ行だけのファイル');
}

public function product_規格CSV登録(AcceptanceTester $I)
{
$I->wantTo('EA0307-UC02-T01 規格CSV登録');

ClassNameManagePage::go($I);
$I->dontSeeElement(['xpath' => '//div[@id="sortable_list_box"]//a[contains(text(), "アップロード規格")]']);

ClassNameCsvUploadPage::go($I)
->入力_CSVファイル('class_name.csv')
->CSVアップロード();

$I->see('CSVファイルをアップロードしました', ClassNameCsvUploadPage::$完了メッセージ);

ClassNameManagePage::go($I);

$I->seeElement(['xpath' => ClassNameManagePage::XPathでタグを取得する('アップロード規格1')]);
$I->seeElement(['xpath' => ClassNameManagePage::XPathでタグを取得する('アップロード規格2')]);
$I->seeElement(['xpath' => ClassNameManagePage::XPathでタグを取得する('アップロード規格3')]);

// アップロード失敗 (フォーマットの異なるcsvをアップロードする)
ClassNameCsvUploadPage::go($I)
->入力_CSVファイル('product.csv')
->CSVアップロード();
$I->see('CSVのフォーマットが一致しません', '#upload-form');
}

/**
* @env firefox
* @env chrome
*/
public function product_規格CSV登録雛形ファイルダウンロード(AcceptanceTester $I)
{
$I->wantTo('EA0307-UC02-T02 規格CSV登録雛形ファイルダウンロード');

// 雛形のダウンロード
ClassNameCsvUploadPage::go($I)->雛形ダウンロード();
$ClassNameTemplateCSV = $I->getLastDownloadFile('/^class_name\.csv$/');
$I->assertEquals(1, count(file($ClassNameTemplateCSV)), 'ヘッダ行だけのファイル');
}

public function product_規格分類CSV登録(AcceptanceTester $I)
{
$I->wantTo('EA0307-UC03-T01 規格分類CSV登録');

ClassNameManagePage::go($I)
->一覧_分類登録(3);

ClassCategoryManagePage::at($I);
$I->dontSeeElement(['xpath' => '//div[@id="sortable_list_box"]//a[contains(text(), "アップロード規格分類")]']);

ClassCategoryCsvUploadPage::go($I)
->入力_CSVファイル('class_category.csv')
->CSVアップロード();

$I->see('CSVファイルをアップロードしました', ClassCategoryCsvUploadPage::$完了メッセージ);

ClassNameManagePage::go($I)
->一覧_分類登録2();

ClassCategoryManagePage::at($I);

$I->seeElement(['xpath' => ClassCategoryManagePage::XPathでタグを取得する('アップロード規格分類1')]);
$I->seeElement(['xpath' => ClassCategoryManagePage::XPathでタグを取得する('アップロード規格分類2')]);
$I->seeElement(['xpath' => ClassCategoryManagePage::XPathでタグを取得する('アップロード規格分類3')]);

// アップロード失敗 (フォーマットの異なるcsvをアップロードする)
ClassCategoryCsvUploadPage::go($I)
->入力_CSVファイル('product.csv')
->CSVアップロード();
$I->see('CSVのフォーマットが一致しません', '#upload-form');
}

/**
* @env firefox
* @env chrome
*/
public function product_規格分類CSV登録雛形ファイルダウンロード(AcceptanceTester $I)
{
$I->wantTo('EA0307-UC03-T02 規格分類CSV登録雛形ファイルダウンロード');

// 雛形のダウンロード
ClassCategoryCsvUploadPage::go($I)->雛形ダウンロード();
$ClassCategoryTemplateCSV = $I->getLastDownloadFile('/^class_category\.csv$/');
$I->assertEquals(1, count(file($ClassCategoryTemplateCSV)), 'ヘッダ行だけのファイル');
}

public function product_タグ登録(AcceptanceTester $I)
{
$I->wantTo('EA0308-UC01-T01 / UC01-T02 タグ登録');
Expand Down
Loading
Loading