From 79fdffbe72600ccfeb49b7e5b02ea864e6f3baf0 Mon Sep 17 00:00:00 2001 From: Eden Date: Sun, 20 Oct 2019 22:47:45 +0700 Subject: [PATCH 01/19] Add validation in catalog rule and shopping cart rule form --- .../ui_component/catalog_rule_form.xml | 4 ++++ .../ui_component/sales_rule_form.xml | 20 +++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/app/code/Magento/CatalogRule/view/adminhtml/ui_component/catalog_rule_form.xml b/app/code/Magento/CatalogRule/view/adminhtml/ui_component/catalog_rule_form.xml index 2af8bb0770b20..35fd7d8a192f4 100644 --- a/app/code/Magento/CatalogRule/view/adminhtml/ui_component/catalog_rule_form.xml +++ b/app/code/Magento/CatalogRule/view/adminhtml/ui_component/catalog_rule_form.xml @@ -208,6 +208,10 @@ + + true + true + text sort_order diff --git a/app/code/Magento/SalesRule/view/adminhtml/ui_component/sales_rule_form.xml b/app/code/Magento/SalesRule/view/adminhtml/ui_component/sales_rule_form.xml index 639e12006232b..63faf29afd769 100644 --- a/app/code/Magento/SalesRule/view/adminhtml/ui_component/sales_rule_form.xml +++ b/app/code/Magento/SalesRule/view/adminhtml/ui_component/sales_rule_form.xml @@ -297,6 +297,9 @@ + + true + text uses_per_coupon @@ -309,6 +312,9 @@ + + true + Usage limit enforced for logged in customers only. @@ -356,6 +362,10 @@ + + true + true + text sort_order @@ -422,6 +432,8 @@ true + true + true text @@ -435,6 +447,10 @@ + + true + true + text discount_qty @@ -447,6 +463,10 @@ + + true + true + text discount_step From 1b66fb468d52868e2c5708fbc6ec7def4acaffc6 Mon Sep 17 00:00:00 2001 From: Eden Date: Wed, 23 Oct 2019 23:23:38 +0700 Subject: [PATCH 02/19] cover issue 25172 with mftf test --- .../CatalogPriceRuleActionGroup.xml | 19 +++++++ .../Test/Mftf/Data/CatalogRuleData.xml | 15 ++++++ .../AdminNewCatalogPriceRuleSection.xml | 2 + .../Test/AdminCreateCatalogPriceRuleTest.xml | 23 ++++++++ .../ui_component/catalog_rule_form.xml | 3 +- .../Test/Mftf/Data/SalesRuleData.xml | 9 ++++ .../AdminCartPriceRulesFormSection.xml | 2 + .../Mftf/Test/AdminCreateInvalidRuleTest.xml | 53 +++++++++++++++++++ .../ui_component/sales_rule_form.xml | 3 +- 9 files changed, 125 insertions(+), 4 deletions(-) create mode 100644 app/code/Magento/SalesRule/Test/Mftf/Test/AdminCreateInvalidRuleTest.xml diff --git a/app/code/Magento/CatalogRule/Test/Mftf/ActionGroup/CatalogPriceRuleActionGroup.xml b/app/code/Magento/CatalogRule/Test/Mftf/ActionGroup/CatalogPriceRuleActionGroup.xml index 09053b5ad14a3..620f61b9ec27a 100644 --- a/app/code/Magento/CatalogRule/Test/Mftf/ActionGroup/CatalogPriceRuleActionGroup.xml +++ b/app/code/Magento/CatalogRule/Test/Mftf/ActionGroup/CatalogPriceRuleActionGroup.xml @@ -208,4 +208,23 @@ + + + + Goes to the Catalog Price Rule grid. Clicks on Add. Fills in the provided Catalog Rule details with invalid data. + + + + + + + + + + + + + + + diff --git a/app/code/Magento/CatalogRule/Test/Mftf/Data/CatalogRuleData.xml b/app/code/Magento/CatalogRule/Test/Mftf/Data/CatalogRuleData.xml index 75a7484324576..2920a895f607d 100644 --- a/app/code/Magento/CatalogRule/Test/Mftf/Data/CatalogRuleData.xml +++ b/app/code/Magento/CatalogRule/Test/Mftf/Data/CatalogRuleData.xml @@ -173,4 +173,19 @@ Free Shipping in conditions Free Shipping in conditions + + + CatalogPriceRule + Catalog Price Rule Description + 1 + + 0 + + + 1 + + by_percent + 10 + ten + diff --git a/app/code/Magento/CatalogRule/Test/Mftf/Section/AdminNewCatalogPriceRuleSection.xml b/app/code/Magento/CatalogRule/Test/Mftf/Section/AdminNewCatalogPriceRuleSection.xml index c736dd8dde2cb..61f2e7ac55ef7 100644 --- a/app/code/Magento/CatalogRule/Test/Mftf/Section/AdminNewCatalogPriceRuleSection.xml +++ b/app/code/Magento/CatalogRule/Test/Mftf/Section/AdminNewCatalogPriceRuleSection.xml @@ -37,6 +37,8 @@ + +
diff --git a/app/code/Magento/CatalogRule/Test/Mftf/Test/AdminCreateCatalogPriceRuleTest.xml b/app/code/Magento/CatalogRule/Test/Mftf/Test/AdminCreateCatalogPriceRuleTest.xml index 09b924603c54a..ee61af180d350 100644 --- a/app/code/Magento/CatalogRule/Test/Mftf/Test/AdminCreateCatalogPriceRuleTest.xml +++ b/app/code/Magento/CatalogRule/Test/Mftf/Test/AdminCreateCatalogPriceRuleTest.xml @@ -196,4 +196,27 @@ + + + + + + + <description value="Admin can not create catalog price rule with the invalid data"/> + <severity value="MAJOR"/> + <group value="CatalogRule"/> + </annotations> + <before> + <actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/> + </before> + <after> + <amOnPage url="{{AdminLogoutPage.url}}" stepKey="amOnLogoutPage"/> + </after> + + <actionGroup ref="newCatalogPriceRuleWithInvalidData" stepKey="createNewPriceRule"> + <argument name="catalogRule" value="catalogRuleWithInvalid"/> + </actionGroup> + + <see selector="{{AdminNewCatalogPriceRule.fieldError('sort_order')}}" userInput="Please enter a valid number in this field." stepKey="seeSortOrderError"/> + </test> </tests> diff --git a/app/code/Magento/CatalogRule/view/adminhtml/ui_component/catalog_rule_form.xml b/app/code/Magento/CatalogRule/view/adminhtml/ui_component/catalog_rule_form.xml index 35fd7d8a192f4..59e3c4668e8a4 100644 --- a/app/code/Magento/CatalogRule/view/adminhtml/ui_component/catalog_rule_form.xml +++ b/app/code/Magento/CatalogRule/view/adminhtml/ui_component/catalog_rule_form.xml @@ -209,8 +209,7 @@ </argument> <settings> <validation> - <rule name="validate-number" xsi:type="boolean">true</rule> - <rule name="validate-zero-or-greater" xsi:type="boolean">true</rule> + <rule name="validate-digits" xsi:type="boolean">true</rule> </validation> <dataType>text</dataType> <label translate="true">Priority</label> diff --git a/app/code/Magento/SalesRule/Test/Mftf/Data/SalesRuleData.xml b/app/code/Magento/SalesRule/Test/Mftf/Data/SalesRuleData.xml index c1ec728a6cfb9..8b1f27812b6cd 100644 --- a/app/code/Magento/SalesRule/Test/Mftf/Data/SalesRuleData.xml +++ b/app/code/Magento/SalesRule/Test/Mftf/Data/SalesRuleData.xml @@ -457,4 +457,13 @@ <requiredEntity type="SalesRuleLabel">SalesRuleLabelDefault</requiredEntity> <requiredEntity type="SalesRuleLabel">SalesRuleLabelStore1</requiredEntity> </entity> + + <entity name="TestSalesRuleWithInvalidData" type="SalesRule"> + <data key="userPerCustomer">one</data> + <data key="userPerCoupon">one</data> + <data key="priority">one</data> + <data key="discountStep">one</data> + <data key="discountAmount">one</data> + <data key="maximumQtyDiscount">one</data> + </entity> </entities> diff --git a/app/code/Magento/SalesRule/Test/Mftf/Section/AdminCartPriceRulesFormSection.xml b/app/code/Magento/SalesRule/Test/Mftf/Section/AdminCartPriceRulesFormSection.xml index 3849d153be465..a45baad7f0910 100644 --- a/app/code/Magento/SalesRule/Test/Mftf/Section/AdminCartPriceRulesFormSection.xml +++ b/app/code/Magento/SalesRule/Test/Mftf/Section/AdminCartPriceRulesFormSection.xml @@ -98,5 +98,7 @@ <element name="couponQty" type="input" selector="#coupons_qty"/> <element name="generateCouponsButton" type="button" selector="#coupons_generate_button" timeout="30"/> <element name="generatedCouponByIndex" type="text" selector="#couponCodesGrid_table > tbody > tr:nth-child({{var}}) > td.col-code" parameterized="true"/> + + <element name="fieldError" type="text" selector="//input[@name='{{fieldName}}']/following-sibling::label[@class='admin__field-error']" parameterized="true"/> </section> </sections> diff --git a/app/code/Magento/SalesRule/Test/Mftf/Test/AdminCreateInvalidRuleTest.xml b/app/code/Magento/SalesRule/Test/Mftf/Test/AdminCreateInvalidRuleTest.xml new file mode 100644 index 0000000000000..620112e323ff5 --- /dev/null +++ b/app/code/Magento/SalesRule/Test/Mftf/Test/AdminCreateInvalidRuleTest.xml @@ -0,0 +1,53 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> + <test name="AdminCreateInvalidRuleTest"> + <annotations> + <features value="SalesRule"/> + <stories value="Create cart price rule with invalid data"/> + <title value="Admin can not create rule with invalid data"/> + <description value="Admin can not create rule with invalid data"/> + <severity value="MAJOR"/> + <group value="SalesRule"/> + </annotations> + + <before> + <actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/> + </before> + + <after> + <actionGroup ref="logout" stepKey="adminLogout"/> + </after> + + <amOnPage url="{{AdminCartPriceRulesPage.url}}" stepKey="amOnCartPriceList"/> + <waitForPageLoad stepKey="waitForRulesPage"/> + <click selector="{{AdminCartPriceRulesSection.addNewRuleButton}}" stepKey="clickAddNewRule"/> + + <click selector="{{AdminCartPriceRulesFormSection.actionsHeader}}" stepKey="clickToExpandActions"/> + <selectOption selector="{{AdminCartPriceRulesFormSection.apply}}" userInput="Buy X get Y free (discount amount is Y)" stepKey="selectActionType"/> + <fillField selector="{{AdminCartPriceRulesFormSection.discountAmount}}" userInput="{{TestSalesRuleWithInvalidData.discountAmount}}" stepKey="fillDiscountAmount"/> + <fillField selector="{{AdminCartPriceRulesFormSection.maximumQtyDiscount}}" userInput="{{TestSalesRuleWithInvalidData.maximumQtyDiscount}}" stepKey="fillDiscountQty"/> + <fillField selector="{{AdminCartPriceRulesFormSection.discountStep}}" userInput="{{TestSalesRuleWithInvalidData.discountStep}}" stepKey="fillDiscountStep"/> + + <fillField selector="{{AdminCartPriceRulesFormSection.userPerCustomer}}" userInput="{{TestSalesRuleWithInvalidData.userPerCustomer}}" stepKey="fillUsePerCustomer"/> + <selectOption selector="{{AdminCartPriceRulesFormSection.coupon}}" userInput="Specific Coupon" stepKey="selectCouponType"/> + <fillField selector="{{AdminCartPriceRulesFormSection.userPerCoupon}}" userInput="{{TestSalesRuleWithInvalidData.userPerCoupon}}" stepKey="fillUsePerCoupon"/> + <fillField selector="{{AdminCartPriceRulesFormSection.priority}}" userInput="{{TestSalesRuleWithInvalidData.priority}}" stepKey="fillPriority"/> + + <click selector="{{AdminCartPriceRulesFormSection.save}}" stepKey="clickSaveButton"/> + + <see selector="{{AdminNewCatalogPriceRule.fieldError('uses_per_coupon')}}" userInput="Please enter a valid number in this field." stepKey="seePerCouponError"/> + <see selector="{{AdminNewCatalogPriceRule.fieldError('uses_per_customer')}}" userInput="Please enter a valid number in this field." stepKey="seePerCustomerError"/> + <see selector="{{AdminNewCatalogPriceRule.fieldError('sort_order')}}" userInput="Please enter a valid number in this field." stepKey="seePriorityError"/> + <see selector="{{AdminNewCatalogPriceRule.fieldError('discount_amount')}}" userInput="Please enter a valid number in this field." stepKey="seeDiscountAmountError"/> + <see selector="{{AdminNewCatalogPriceRule.fieldError('discount_qty')}}" userInput="Please enter a valid number in this field." stepKey="seeMaximumQtyError"/> + <see selector="{{AdminNewCatalogPriceRule.fieldError('discount_step')}}" userInput="Please enter a valid number in this field." stepKey="seeDiscountStepError"/> + </test> +</tests> diff --git a/app/code/Magento/SalesRule/view/adminhtml/ui_component/sales_rule_form.xml b/app/code/Magento/SalesRule/view/adminhtml/ui_component/sales_rule_form.xml index 63faf29afd769..e1c12f45012ee 100644 --- a/app/code/Magento/SalesRule/view/adminhtml/ui_component/sales_rule_form.xml +++ b/app/code/Magento/SalesRule/view/adminhtml/ui_component/sales_rule_form.xml @@ -363,8 +363,7 @@ </argument> <settings> <validation> - <rule name="validate-number" xsi:type="boolean">true</rule> - <rule name="validate-zero-or-greater" xsi:type="boolean">true</rule> + <rule name="validate-digits" xsi:type="boolean">true</rule> </validation> <dataType>text</dataType> <label translate="true">Priority</label> From a9f499ed76599deef689eaeb3d0cb9fb02498c49 Mon Sep 17 00:00:00 2001 From: Mauricio Agudelo <mauricio.agudelo@interactiv4.com> Date: Sun, 27 Oct 2019 14:17:08 +0100 Subject: [PATCH 03/19] feature/25312 Add Colombian regions --- .../Setup/Patch/Data/AddDataForColombia.php | 115 ++++++++++++++++++ 1 file changed, 115 insertions(+) create mode 100644 app/code/Magento/Directory/Setup/Patch/Data/AddDataForColombia.php diff --git a/app/code/Magento/Directory/Setup/Patch/Data/AddDataForColombia.php b/app/code/Magento/Directory/Setup/Patch/Data/AddDataForColombia.php new file mode 100644 index 0000000000000..38a9759828588 --- /dev/null +++ b/app/code/Magento/Directory/Setup/Patch/Data/AddDataForColombia.php @@ -0,0 +1,115 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + +declare(strict_types=1); + +namespace Magento\Directory\Setup\Patch\Data; + +use Magento\Directory\Setup\DataInstaller; +use Magento\Framework\Setup\ModuleDataSetupInterface; +use Magento\Framework\Setup\Patch\DataPatchInterface; + +/** + * Class AddDataForColombia + */ +class AddDataForColombia implements DataPatchInterface +{ + /** + * @var ModuleDataSetupInterface + */ + private $moduleDataSetup; + + /** + * @var \Magento\Directory\Setup\DataInstallerFactory + */ + private $dataInstallerFactory; + + /** + * @param ModuleDataSetupInterface $moduleDataSetup + * @param \Magento\Directory\Setup\DataInstallerFactory $dataInstallerFactory + */ + public function __construct( + ModuleDataSetupInterface $moduleDataSetup, + \Magento\Directory\Setup\DataInstallerFactory $dataInstallerFactory + ) { + $this->moduleDataSetup = $moduleDataSetup; + $this->dataInstallerFactory = $dataInstallerFactory; + } + + /** + * @inheritdoc + */ + public function apply() + { + /** @var DataInstaller $dataInstaller */ + $dataInstaller = $this->dataInstallerFactory->create(); + $dataInstaller->addCountryRegions( + $this->moduleDataSetup->getConnection(), + $this->getDataForColombia() + ); + } + + /** + * Colombia states data. + * + * @return array + */ + private function getDataForColombia() + { + return [ + ['CO', 'CO-AMA', 'Amazonas'], + ['CO', 'CO-ANT', 'Antioquia'], + ['CO', 'CO-ARA', 'Arauca'], + ['CO', 'CO-ATL', 'Atlántico'], + ['CO', 'CO-BOL', 'Bolívar'], + ['CO', 'CO-BOY', 'Boyacá'], + ['CO', 'CO-CAL', 'Caldas'], + ['CO', 'CO-CAQ', 'Caquetá'], + ['CO', 'CO-CAS', 'Casanare'], + ['CO', 'CO-CAU', 'Cauca'], + ['CO', 'CO-CES', 'Cesar'], + ['CO', 'CO-CHO', 'Chocó'], + ['CO', 'CO-COR', 'Córdoba'], + ['CO', 'CO-CUN', 'Cundinamarca'], + ['CO', 'CO-GUA', 'Guainía'], + ['CO', 'CO-GUV', 'Guaviare'], + ['CO', 'CO-HUL', 'Huila'], + ['CO', 'CO-LAG', 'La Guajira'], + ['CO', 'CO-MAG', 'Magdalena'], + ['CO', 'CO-MET', 'Meta'], + ['CO', 'CO-NAR', 'Nariño'], + ['CO', 'CO-NSA', 'Norte de Santander'], + ['CO', 'CO-PUT', 'Putumayo'], + ['CO', 'CO-QUI', 'Quindío'], + ['CO', 'CO-RIS', 'Risaralda'], + ['CO', 'CO-SAP', 'San Andrés y Providencia'], + ['CO', 'CO-SAN', 'Santander'], + ['CO', 'CO-SUC', 'Sucre'], + ['CO', 'CO-TOL', 'Tolima'], + ['CO', 'CO-VAC', 'Valle del Cauca'], + ['CO', 'CO-VAU', 'Vaupés'], + ['CO', 'CO-VID', 'Vichada'], + ]; + } + + /** + * @inheritdoc + */ + public static function getDependencies() + { + return [ + InitializeDirectoryData::class, + ]; + } + + /** + * @inheritdoc + */ + public function getAliases() + { + return []; + } +} From f070206da28f41814f6677ecee9ef4d84105338d Mon Sep 17 00:00:00 2001 From: Nazarn96 <nazarn96@gmail.com> Date: Tue, 12 Nov 2019 11:05:27 +0200 Subject: [PATCH 04/19] The image details are not hidden when click on same image in the search result --- .../Ui/view/base/web/js/grid/columns/image-preview.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/code/Magento/Ui/view/base/web/js/grid/columns/image-preview.js b/app/code/Magento/Ui/view/base/web/js/grid/columns/image-preview.js index 1ef2ebf6594fa..8a22b06d53dc5 100644 --- a/app/code/Magento/Ui/view/base/web/js/grid/columns/image-preview.js +++ b/app/code/Magento/Ui/view/base/web/js/grid/columns/image-preview.js @@ -100,6 +100,12 @@ define([ */ show: function (record) { var img; + + if (record._rowIndex === this.lastOpenedImage() + && this.isVisible(record)) { + this.hide(); + return; + } this.hide(); this.displayedRecord(record); From c23393d20e9e3e6493f6326a2cc80c4e36cdf86d Mon Sep 17 00:00:00 2001 From: Nazarn96 <nazarn96@gmail.com> Date: Tue, 12 Nov 2019 16:34:02 +0200 Subject: [PATCH 05/19] Fix error when open grid with opened preview --- .../Magento/Ui/view/base/web/js/grid/columns/image-preview.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Ui/view/base/web/js/grid/columns/image-preview.js b/app/code/Magento/Ui/view/base/web/js/grid/columns/image-preview.js index 8a22b06d53dc5..cc637d8a3c4d1 100644 --- a/app/code/Magento/Ui/view/base/web/js/grid/columns/image-preview.js +++ b/app/code/Magento/Ui/view/base/web/js/grid/columns/image-preview.js @@ -101,7 +101,7 @@ define([ show: function (record) { var img; - if (record._rowIndex === this.lastOpenedImage() + if (record._rowIndex === this.visibleRecord() && this.isVisible(record)) { this.hide(); return; From aa7195afb7fcab4a4984d9eb703643cc9d5a6be2 Mon Sep 17 00:00:00 2001 From: Nazarn96 <nazarn96@gmail.com> Date: Thu, 14 Nov 2019 10:34:46 +0200 Subject: [PATCH 06/19] Fix static tests --- .../Ui/view/base/web/js/grid/columns/image-preview.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/code/Magento/Ui/view/base/web/js/grid/columns/image-preview.js b/app/code/Magento/Ui/view/base/web/js/grid/columns/image-preview.js index cc637d8a3c4d1..1da19a3645e4a 100644 --- a/app/code/Magento/Ui/view/base/web/js/grid/columns/image-preview.js +++ b/app/code/Magento/Ui/view/base/web/js/grid/columns/image-preview.js @@ -100,10 +100,11 @@ define([ */ show: function (record) { var img; - - if (record._rowIndex === this.visibleRecord() - && this.isVisible(record)) { + + if (record._rowIndex === this.visibleRecord() && + this.isVisible(record)) { this.hide(); + return; } From e29914e4581d5f14c6a4dcd5fdf4f4799c8df64c Mon Sep 17 00:00:00 2001 From: Nazar Klovanych <nazarn96@gmail.com> Date: Thu, 14 Nov 2019 12:56:04 +0200 Subject: [PATCH 07/19] Update image-preview.js --- .../Magento/Ui/view/base/web/js/grid/columns/image-preview.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/code/Magento/Ui/view/base/web/js/grid/columns/image-preview.js b/app/code/Magento/Ui/view/base/web/js/grid/columns/image-preview.js index 1da19a3645e4a..cf597f8d3a543 100644 --- a/app/code/Magento/Ui/view/base/web/js/grid/columns/image-preview.js +++ b/app/code/Magento/Ui/view/base/web/js/grid/columns/image-preview.js @@ -101,8 +101,7 @@ define([ show: function (record) { var img; - if (record._rowIndex === this.visibleRecord() && - this.isVisible(record)) { + if (record._rowIndex === this.visibleRecord()) { this.hide(); return; From a565ee001e76ed3b5d53b7b21ed8dd637c1fb71b Mon Sep 17 00:00:00 2001 From: Nazar Klovanych <nazarn96@gmail.com> Date: Fri, 15 Nov 2019 15:57:23 +0200 Subject: [PATCH 08/19] Remove duplicated hide() method --- .../Ui/view/base/web/js/grid/columns/image-preview.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/app/code/Magento/Ui/view/base/web/js/grid/columns/image-preview.js b/app/code/Magento/Ui/view/base/web/js/grid/columns/image-preview.js index cf597f8d3a543..372ab0e093727 100644 --- a/app/code/Magento/Ui/view/base/web/js/grid/columns/image-preview.js +++ b/app/code/Magento/Ui/view/base/web/js/grid/columns/image-preview.js @@ -101,13 +101,12 @@ define([ show: function (record) { var img; + this.hide(); + if (record._rowIndex === this.visibleRecord()) { - this.hide(); - return; } - - this.hide(); + this.displayedRecord(record); this._selectRow(record.rowNumber || null); this.visibleRecord(record._rowIndex); From b30b855668313aa55c00156927e9392723795195 Mon Sep 17 00:00:00 2001 From: Nazarn96 <nazarn96@gmail.com> Date: Fri, 15 Nov 2019 16:33:16 +0200 Subject: [PATCH 09/19] Fix static test --- .../Magento/Ui/view/base/web/js/grid/columns/image-preview.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Ui/view/base/web/js/grid/columns/image-preview.js b/app/code/Magento/Ui/view/base/web/js/grid/columns/image-preview.js index 372ab0e093727..57f16dc0c1a02 100644 --- a/app/code/Magento/Ui/view/base/web/js/grid/columns/image-preview.js +++ b/app/code/Magento/Ui/view/base/web/js/grid/columns/image-preview.js @@ -102,11 +102,11 @@ define([ var img; this.hide(); - + if (record._rowIndex === this.visibleRecord()) { return; } - + this.displayedRecord(record); this._selectRow(record.rowNumber || null); this.visibleRecord(record._rowIndex); From a7ffbd6842a0e4e243a014b8ceb8d197fca83f2e Mon Sep 17 00:00:00 2001 From: Nazar Klovanych <nazarn96@gmail.com> Date: Mon, 18 Nov 2019 10:32:38 +0200 Subject: [PATCH 10/19] Move hide() method to if statement --- .../Ui/view/base/web/js/grid/columns/image-preview.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Ui/view/base/web/js/grid/columns/image-preview.js b/app/code/Magento/Ui/view/base/web/js/grid/columns/image-preview.js index 57f16dc0c1a02..cf597f8d3a543 100644 --- a/app/code/Magento/Ui/view/base/web/js/grid/columns/image-preview.js +++ b/app/code/Magento/Ui/view/base/web/js/grid/columns/image-preview.js @@ -101,12 +101,13 @@ define([ show: function (record) { var img; - this.hide(); - if (record._rowIndex === this.visibleRecord()) { + this.hide(); + return; } + this.hide(); this.displayedRecord(record); this._selectRow(record.rowNumber || null); this.visibleRecord(record._rowIndex); From 129771e606bcadca1b7cc7e5e698b8de9e37e35e Mon Sep 17 00:00:00 2001 From: Eden <eden@magestore.com> Date: Thu, 21 Nov 2019 21:30:34 +0700 Subject: [PATCH 11/19] Unit Test to cover class \Magento\Captcha\CustomerData\Captcha --- .../Test/Unit/CustomerData/CaptchaTest.php | 107 ++++++++++++++++++ 1 file changed, 107 insertions(+) create mode 100644 app/code/Magento/Captcha/Test/Unit/CustomerData/CaptchaTest.php diff --git a/app/code/Magento/Captcha/Test/Unit/CustomerData/CaptchaTest.php b/app/code/Magento/Captcha/Test/Unit/CustomerData/CaptchaTest.php new file mode 100644 index 0000000000000..0c2b1975e6cf4 --- /dev/null +++ b/app/code/Magento/Captcha/Test/Unit/CustomerData/CaptchaTest.php @@ -0,0 +1,107 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + +declare(strict_types=1); + +namespace Magento\Captcha\Test\Unit\CustomerData; + +use Magento\Captcha\Helper\Data as CaptchaHelper; +use Magento\Customer\Model\Session as CustomerSession; +use Magento\Captcha\CustomerData\Captcha; +use Magento\Captcha\Model\DefaultModel; +use Magento\Customer\Api\Data\CustomerInterface as CustomerData; +use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; + +/** + * Test class to cover \Magento\Captcha\CustomerData\Captcha + * + * Class \Magento\Captcha\Test\Unit\CustomerData\CaptchaTest + */ +class CaptchaTest extends \PHPUnit\Framework\TestCase +{ + /** + * @var CaptchaHelper | \PHPUnit_Framework_MockObject_MockObject + */ + private $helper; + + /** + * @var CustomerSession | \PHPUnit_Framework_MockObject_MockObject + */ + private $customerSession; + + /** + * @var CustomerData | \PHPUnit_Framework_MockObject_MockObject + */ + private $customerData; + + /** + * @var Captcha + */ + private $model; + + /** + * @var array + */ + private $formIds; + + /** + * @var ObjectManagerHelper + */ + protected $objectManagerHelper; + + /** + * Create mocks and model + */ + protected function setUp() + { + $this->helper = $this->createMock(CaptchaHelper::class); + $this->customerSession = $this->createMock(CustomerSession::class); + $this->formIds = [ + 'user_login' + ]; + $this->objectManagerHelper = new ObjectManagerHelper($this); + $this->model = $this->objectManagerHelper->getObject( + Captcha::class, + [ + 'helper' => $this->helper, + 'formIds' => $this->formIds, + 'customerSession' => $this->customerSession + ] + ); + } + + /** + * Test getSectionData() when user is login and require captcha + */ + public function testGetSectionData() + { + $emailLogin = 'test@localhost.com'; + + $userLoginModel = $this->createMock(DefaultModel::class); + $userLoginModel->expects($this->any())->method('isRequired')->with($emailLogin) + ->willReturn(true); + $this->helper->expects($this->any())->method('getCaptcha')->with('user_login')->willReturn($userLoginModel); + + $this->customerSession->expects($this->any())->method('isLoggedIn') + ->willReturn(true); + + $this->customerData = $this->createMock(CustomerData::class); + $this->customerData->expects($this->any())->method('getEmail')->willReturn($emailLogin); + $this->customerSession->expects($this->any())->method('getCustomerData') + ->willReturn($this->customerData); + + /* Assert to test */ + $this->assertEquals( + [ + "user_login" => [ + "isRequired" => true, + "timestamp" => time() + ] + ], + $this->model->getSectionData() + ); + } +} From 7534f33b2bbed6d1bb86e6b3fb22218d45c97158 Mon Sep 17 00:00:00 2001 From: Eden <eden@magestore.com> Date: Fri, 22 Nov 2019 13:01:32 +0700 Subject: [PATCH 12/19] Refactor to pass review --- .../Captcha/Test/Unit/CustomerData/CaptchaTest.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/code/Magento/Captcha/Test/Unit/CustomerData/CaptchaTest.php b/app/code/Magento/Captcha/Test/Unit/CustomerData/CaptchaTest.php index 0c2b1975e6cf4..b34de7778e176 100644 --- a/app/code/Magento/Captcha/Test/Unit/CustomerData/CaptchaTest.php +++ b/app/code/Magento/Captcha/Test/Unit/CustomerData/CaptchaTest.php @@ -23,17 +23,17 @@ class CaptchaTest extends \PHPUnit\Framework\TestCase { /** - * @var CaptchaHelper | \PHPUnit_Framework_MockObject_MockObject + * @var CaptchaHelper|\PHPUnit_Framework_MockObject_MockObject */ private $helper; /** - * @var CustomerSession | \PHPUnit_Framework_MockObject_MockObject + * @var CustomerSession|\PHPUnit_Framework_MockObject_MockObject */ private $customerSession; /** - * @var CustomerData | \PHPUnit_Framework_MockObject_MockObject + * @var CustomerData|\PHPUnit_Framework_MockObject_MockObject */ private $customerData; @@ -76,7 +76,7 @@ protected function setUp() /** * Test getSectionData() when user is login and require captcha */ - public function testGetSectionData() + public function testGetSectionDataWhenLoginAndRequireCaptcha() { $emailLogin = 'test@localhost.com'; From b423aaa869641e51b439b882b214f895b9996c9a Mon Sep 17 00:00:00 2001 From: Eden <eden@magestore.com> Date: Fri, 22 Nov 2019 21:48:49 +0700 Subject: [PATCH 13/19] [ImportExport] Cover Helper Data by Unit Test --- .../Test/Unit/Helper/DataTest.php | 139 ++++++++++++++++++ 1 file changed, 139 insertions(+) create mode 100644 app/code/Magento/ImportExport/Test/Unit/Helper/DataTest.php diff --git a/app/code/Magento/ImportExport/Test/Unit/Helper/DataTest.php b/app/code/Magento/ImportExport/Test/Unit/Helper/DataTest.php new file mode 100644 index 0000000000000..85630d2106b45 --- /dev/null +++ b/app/code/Magento/ImportExport/Test/Unit/Helper/DataTest.php @@ -0,0 +1,139 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\ImportExport\Test\Unit\Helper; + +use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; +use Magento\Framework\App\Helper\Context; +use Magento\Framework\File\Size as FileSize; +use Magento\Framework\App\Config\ScopeConfigInterface; +use Magento\ImportExport\Helper\Data as HelperData; +use PHPUnit\Framework\TestCase; + +/** + * Test class to cover Data Helper + * + * Class \Magento\ImportExport\Test\Unit\Helper\DataTest + */ +class DataTest extends TestCase +{ + /** + * @var ObjectManagerHelper + */ + private $objectManagerHelper; + + /** + * @var FileSize|PHPUnit_Framework_MockObject_MockObject + */ + private $fileSizeMock; + + /** + * @var Context|PHPUnit_Framework_MockObject_MockObject + */ + private $contextMock; + + /** + * @var ScopeConfigInterface|PHPUnit_Framework_MockObject_MockObject + */ + private $scopeConfigMock; + + /** + * @var HelperData|PHPUnit_Framework_MockObject_MockObject + */ + private $helperData; + + /** + * Set up environment + */ + protected function setUp() + { + $this->contextMock = $this->createMock(Context::class); + $this->fileSizeMock = $this->createMock(FileSize::class); + $this->scopeConfigMock = $this->createMock(ScopeConfigInterface::class); + $this->contextMock->expects($this->any())->method('getScopeConfig')->willReturn($this->scopeConfigMock); + + $this->objectManagerHelper = new ObjectManagerHelper($this); + $this->helperData = $this->objectManagerHelper->getObject( + HelperData::class, + [ + 'context' => $this->contextMock, + 'fileSize' => $this->fileSizeMock + ] + ); + } + + /** + * Test getMaxUploadSizeMessage() with data provider below + * + * @param float $maxImageSize + * @param string $expected + * @return void + * @dataProvider getMaxUploadSizeMessageDataProvider + */ + public function testGetMaxUploadSizeMessage($maxImageSize, $expected) + { + $this->fileSizeMock->expects($this->any())->method('getMaxFileSizeInMb')->willReturn($maxImageSize); + $this->assertEquals($expected, $this->helperData->getMaxUploadSizeMessage()); + } + + /** + * DataProvider for testGetMaxUploadSizeMessage() function + * + * @return array + */ + public function getMaxUploadSizeMessageDataProvider() + { + return [ + 'Test with max image size = 10Mb' => [ + 'maxImageSize' => 10, + 'expected' => 'Make sure your file isn\'t more than 10M.', + ], + 'Test with max image size = 0' => [ + 'maxImageSize' => 0, + 'expected' => 'We can\'t provide the upload settings right now.', + ] + ]; + } + + /** + * Test getLocalValidPaths() + * + * @return void + */ + public function testGetLocalValidPaths() + { + $paths = [ + 'available' => [ + 'export_xml' => 'var/export/*/*.xml', + 'export_csv' => 'var/export/*/*.csv', + 'import_xml' => 'var/import/*/*.xml', + 'import_csv' => 'var/import/*/*.csv', + ] + ]; + $this->scopeConfigMock->expects($this->any())->method('getValue') + ->with(HelperData::XML_PATH_EXPORT_LOCAL_VALID_PATH) + ->willReturn($paths); + + $this->assertEquals($paths, $this->helperData->getLocalValidPaths()); + } + + /** + * Test getBunchSize() + * + * @return void + */ + public function testGetBunchSize() + { + $bunchSize = '100'; + + $this->scopeConfigMock->expects($this->any())->method('getValue') + ->with(HelperData::XML_PATH_BUNCH_SIZE) + ->willReturn($bunchSize); + + $this->assertEquals(100, $this->helperData->getBunchSize()); + } +} From f61f1d9878a3bf4becb19e90b2e1332cdccec163 Mon Sep 17 00:00:00 2001 From: Eden <eden@magestore.com> Date: Sat, 23 Nov 2019 11:37:49 +0700 Subject: [PATCH 14/19] [Tax] Cover Tax CustomerData by Unit Test --- ...CheckoutTotalsJsLayoutDataProviderTest.php | 129 ++++++++++++++++++ 1 file changed, 129 insertions(+) create mode 100644 app/code/Magento/Tax/Test/Unit/CustomerData/CheckoutTotalsJsLayoutDataProviderTest.php diff --git a/app/code/Magento/Tax/Test/Unit/CustomerData/CheckoutTotalsJsLayoutDataProviderTest.php b/app/code/Magento/Tax/Test/Unit/CustomerData/CheckoutTotalsJsLayoutDataProviderTest.php new file mode 100644 index 0000000000000..d624a42c1e134 --- /dev/null +++ b/app/code/Magento/Tax/Test/Unit/CustomerData/CheckoutTotalsJsLayoutDataProviderTest.php @@ -0,0 +1,129 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Tax\Test\Unit\CustomerData; + +use PHPUnit\Framework\TestCase; +use Magento\Tax\CustomerData\CheckoutTotalsJsLayoutDataProvider; +use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; +use Magento\Tax\Model\Config as TaxConfig; + +/** + * Test class to cover CheckoutTotalsJsLayoutDataProvider + * + * Class \Magento\Tax\Test\Unit\CustomerData\CheckoutTotalsJsLayoutDataProviderTest + */ +class CheckoutTotalsJsLayoutDataProviderTest extends TestCase +{ + /** + * @var CheckoutTotalsJsLayoutDataProvider + */ + private $dataProvider; + + /** + * @var TaxConfig|PHPUnit_Framework_MockObject_MockObject + */ + private $taxConfigMock; + + /** + * Setup environment for test + */ + protected function setUp() + { + $this->taxConfigMock = $this->createMock(TaxConfig::class); + $objectManager = new ObjectManagerHelper($this); + + $this->dataProvider = $objectManager->getObject( + CheckoutTotalsJsLayoutDataProvider::class, + [ + 'taxConfig' => $this->taxConfigMock + ] + ); + } + + /** + * Test getData() with dataset getDataDataProvider + * + * @param int $displayCartSubtotalInclTax + * @param int $displayCartSubtotalExclTax + * @param array $expected + * @return void + * @dataProvider getDataDataProvider + */ + public function testGetData($displayCartSubtotalInclTax, $displayCartSubtotalExclTax, $expected) + { + $this->taxConfigMock->expects($this->any())->method('displayCartSubtotalInclTax') + ->willReturn($displayCartSubtotalInclTax); + $this->taxConfigMock->expects($this->any())->method('displayCartSubtotalExclTax') + ->willReturn($displayCartSubtotalExclTax); + + $this->assertEquals($expected, $this->dataProvider->getData()); + } + + /** + * Dataset for test getData() + * + * @return array + */ + public function getDataDataProvider() + { + return [ + 'Test with settings display cart incl and excl is Yes' => [ + '1' , + '1', + [ + 'components' => [ + 'minicart_content' => [ + 'children' => [ + 'subtotal.container' => [ + 'children' => [ + 'subtotal' => [ + 'children' => [ + 'subtotal.totals' => [ + 'config' => [ + 'display_cart_subtotal_incl_tax' => 1, + 'display_cart_subtotal_excl_tax' => 1 + ] + ], + ], + ], + ], + ], + ], + ], + ] + ] + ], + 'Test with settings display cart incl and excl is No' => [ + '0' , + '0', + [ + 'components' => [ + 'minicart_content' => [ + 'children' => [ + 'subtotal.container' => [ + 'children' => [ + 'subtotal' => [ + 'children' => [ + 'subtotal.totals' => [ + 'config' => [ + 'display_cart_subtotal_incl_tax' => 0, + 'display_cart_subtotal_excl_tax' => 0 + ] + ], + ], + ], + ], + ], + ], + ], + ] + ] + ] + ]; + } +} From 9992c0e30b4e368ca978be334c541996c66207cc Mon Sep 17 00:00:00 2001 From: Eden <eden@magestore.com> Date: Sat, 23 Nov 2019 22:41:29 +0700 Subject: [PATCH 15/19] refactor code to pass review --- .../Test/Unit/CustomerData/CaptchaTest.php | 37 +++++++------------ 1 file changed, 14 insertions(+), 23 deletions(-) diff --git a/app/code/Magento/Captcha/Test/Unit/CustomerData/CaptchaTest.php b/app/code/Magento/Captcha/Test/Unit/CustomerData/CaptchaTest.php index b34de7778e176..a791039fe27f9 100644 --- a/app/code/Magento/Captcha/Test/Unit/CustomerData/CaptchaTest.php +++ b/app/code/Magento/Captcha/Test/Unit/CustomerData/CaptchaTest.php @@ -14,28 +14,19 @@ use Magento\Captcha\Model\DefaultModel; use Magento\Customer\Api\Data\CustomerInterface as CustomerData; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; +use PHPUnit\Framework\TestCase; -/** - * Test class to cover \Magento\Captcha\CustomerData\Captcha - * - * Class \Magento\Captcha\Test\Unit\CustomerData\CaptchaTest - */ -class CaptchaTest extends \PHPUnit\Framework\TestCase +class CaptchaTest extends TestCase { /** * @var CaptchaHelper|\PHPUnit_Framework_MockObject_MockObject */ - private $helper; + private $helperMock; /** * @var CustomerSession|\PHPUnit_Framework_MockObject_MockObject */ - private $customerSession; - - /** - * @var CustomerData|\PHPUnit_Framework_MockObject_MockObject - */ - private $customerData; + private $customerSessionMock; /** * @var Captcha @@ -57,8 +48,8 @@ class CaptchaTest extends \PHPUnit\Framework\TestCase */ protected function setUp() { - $this->helper = $this->createMock(CaptchaHelper::class); - $this->customerSession = $this->createMock(CustomerSession::class); + $this->helperMock = $this->createMock(CaptchaHelper::class); + $this->customerSessionMock = $this->createMock(CustomerSession::class); $this->formIds = [ 'user_login' ]; @@ -66,9 +57,9 @@ protected function setUp() $this->model = $this->objectManagerHelper->getObject( Captcha::class, [ - 'helper' => $this->helper, + 'helper' => $this->helperMock, 'formIds' => $this->formIds, - 'customerSession' => $this->customerSession + 'customerSession' => $this->customerSessionMock ] ); } @@ -83,15 +74,15 @@ public function testGetSectionDataWhenLoginAndRequireCaptcha() $userLoginModel = $this->createMock(DefaultModel::class); $userLoginModel->expects($this->any())->method('isRequired')->with($emailLogin) ->willReturn(true); - $this->helper->expects($this->any())->method('getCaptcha')->with('user_login')->willReturn($userLoginModel); + $this->helperMock->expects($this->any())->method('getCaptcha')->with('user_login')->willReturn($userLoginModel); - $this->customerSession->expects($this->any())->method('isLoggedIn') + $this->customerSessionMock->expects($this->any())->method('isLoggedIn') ->willReturn(true); - $this->customerData = $this->createMock(CustomerData::class); - $this->customerData->expects($this->any())->method('getEmail')->willReturn($emailLogin); - $this->customerSession->expects($this->any())->method('getCustomerData') - ->willReturn($this->customerData); + $customerDataMock = $this->createMock(CustomerData::class); + $customerDataMock->expects($this->any())->method('getEmail')->willReturn($emailLogin); + $this->customerSessionMock->expects($this->any())->method('getCustomerData') + ->willReturn($customerDataMock); /* Assert to test */ $this->assertEquals( From ad17bd912b73c3afc6ad4192bc6cfdd1ad594a6b Mon Sep 17 00:00:00 2001 From: Benjamin Rosenberger <rosenberger@e-conomix.at> Date: Sun, 24 Nov 2019 11:40:27 +0100 Subject: [PATCH 16/19] add the id of the category to the category tree names --- app/code/Magento/Catalog/Block/Adminhtml/Category/Tree.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Category/Tree.php b/app/code/Magento/Catalog/Block/Adminhtml/Category/Tree.php index 9a4a9fa768006..929c181bf820c 100644 --- a/app/code/Magento/Catalog/Block/Adminhtml/Category/Tree.php +++ b/app/code/Magento/Catalog/Block/Adminhtml/Category/Tree.php @@ -407,6 +407,7 @@ protected function _getNodeJson($node, $level = 0) public function buildNodeName($node) { $result = $this->escapeHtml($node->getName()); + $result .= ' (ID: ' . $node->getId() . ')'; if ($this->_withProductCount) { $result .= ' (' . $node->getProductCount() . ')'; } From f307e2edce1d04e6e4cff145505d64dcc98047be Mon Sep 17 00:00:00 2001 From: Sergiy Zhovnir <s.zhovnir@atwix.com> Date: Sun, 24 Nov 2019 14:18:45 +0200 Subject: [PATCH 17/19] #issue-723 Fixed the issue Image preview should be closed when the page is changed --- .../Magento/Ui/view/base/web/js/grid/columns/image-preview.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/Ui/view/base/web/js/grid/columns/image-preview.js b/app/code/Magento/Ui/view/base/web/js/grid/columns/image-preview.js index 4f632df025ac8..bc21e9e21ff3b 100644 --- a/app/code/Magento/Ui/view/base/web/js/grid/columns/image-preview.js +++ b/app/code/Magento/Ui/view/base/web/js/grid/columns/image-preview.js @@ -30,7 +30,8 @@ define([ }, listens: { '${ $.provider }:params.filters': 'hide', - '${ $.provider }:params.search': 'hide' + '${ $.provider }:params.search': 'hide', + '${ $.provider }:params.paging': 'hide' }, exports: { height: '${ $.parentName }.thumbnail_url:previewHeight' From 353eaa884b9cb14fbd74978666a5a29c2881c3bd Mon Sep 17 00:00:00 2001 From: Benjamin Rosenberger <rosenberger@e-conomix.at> Date: Sun, 24 Nov 2019 13:25:43 +0100 Subject: [PATCH 18/19] add correct test category output to wait for --- .../AdminFilteringCategoryProductsUsingScopeSelectorTest.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminFilteringCategoryProductsUsingScopeSelectorTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminFilteringCategoryProductsUsingScopeSelectorTest.xml index 5c434ecabf80d..41b446b474078 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminFilteringCategoryProductsUsingScopeSelectorTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminFilteringCategoryProductsUsingScopeSelectorTest.xml @@ -131,7 +131,7 @@ userInput="$$createProduct1.name$$" stepKey="seeProductName4"/> <see selector="{{AdminCategoryProductsGridSection.productGridNameProduct($$createProduct12.name$$)}}" userInput="$$createProduct12.name$$" stepKey="seeProductName5"/> - <waitForText userInput="$$createCategory.name$$ (2)" stepKey="seeCorrectProductCount"/> + <waitForText userInput="$$createCategory.name$$ (ID: 6) (2)" stepKey="seeCorrectProductCount"/> <dontSee selector="{{AdminCategoryProductsGridSection.productGridNameProduct($$createProduct0.name$$)}}" userInput="$$createProduct0.name$$" stepKey="dontSeeProductName"/> <dontSee selector="{{AdminCategoryProductsGridSection.productGridNameProduct($$createProduct2.name$$)}}" @@ -151,7 +151,7 @@ userInput="$$createProduct2.name$$" stepKey="seeProductName6"/> <see selector="{{AdminCategoryProductsGridSection.productGridNameProduct($$createProduct12.name$$)}}" userInput="$$createProduct12.name$$" stepKey="seeProductName7"/> - <waitForText userInput="$$createCategory.name$$ (2)" stepKey="seeCorrectProductCount2"/> + <waitForText userInput="$$createCategory.name$$ (ID: 6) (2)" stepKey="seeCorrectProductCount2"/> <dontSee selector="{{AdminCategoryProductsGridSection.productGridNameProduct($$createProduct0.name$$)}}" userInput="$$createProduct0.name$$" stepKey="dontSeeProductName2"/> <dontSee selector="{{AdminCategoryProductsGridSection.productGridNameProduct($$createProduct2.name$$)}}" From e5d143d8d968bf5a71429677015be4ae36196a74 Mon Sep 17 00:00:00 2001 From: Nazar Klovanych <nazarn96@gmail.com> Date: Sun, 24 Nov 2019 18:59:53 +0200 Subject: [PATCH 19/19] Cover changes with jasmnine test --- .../js/grid/columns/image-preview.test.js | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/columns/image-preview.test.js diff --git a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/columns/image-preview.test.js b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/columns/image-preview.test.js new file mode 100644 index 0000000000000..b5c6e75248bfa --- /dev/null +++ b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/columns/image-preview.test.js @@ -0,0 +1,50 @@ +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +/* eslint-disable max-nested-callbacks, no-undef */ + +define([ + 'Magento_Ui/js/grid/columns/image-preview', + 'ko', + 'jquery' +], function (Preview, ko, $) { + 'use strict'; + + describe('Ui/js/grid/columns/image-preview', function () { + var record = { + _rowIndex: 1, + rowNumber: 1 + }, + imagePreview; + + beforeEach(function () { + imagePreview = new Preview(); + + /** + * @return {Object} + */ + function getThumbnail() { + return { + previewRowId: ko.observable() + }; + } + + imagePreview.thumbnailComponent = getThumbnail; + + imagePreview.visibleRecord = ko.observable(1); + }); + + describe('show method', function () { + it('show image', function () { + var mockImg = document.createElement('img'), + hide = spyOn(imagePreview, 'hide'); + + spyOn($.fn, 'get').and.returnValue(mockImg); + imagePreview.show(record); + expect(hide).toHaveBeenCalledTimes(1); + }); + + }); + }); +});