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

[BO] Fix bug when filter stores by name or address #10748

Closed
wants to merge 16 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions controllers/admin/AdminStoresController.php
Expand Up @@ -50,8 +50,8 @@ public function __construct()

$this->fields_list = array(
'id_store' => array('title' => $this->trans('ID', array(), 'Admin.Global'), 'align' => 'center', 'class' => 'fixed-width-xs'),
'name' => array('title' => $this->trans('Name', array(), 'Admin.Global'), 'filter_key' => 'a!name'),
'address1' => array('title' => $this->trans('Address', array(), 'Admin.Global'), 'filter_key' => 'a!address1'),
'name' => array('title' => $this->trans('Name', array(), 'Admin.Global'), 'filter_key' => 'sl!name'),
'address1' => array('title' => $this->trans('Address', array(), 'Admin.Global'), 'filter_key' => 'sl!address1'),
'city' => array('title' => $this->trans('City', array(), 'Admin.Global')),
'postcode' => array('title' => $this->trans('Zip/postal code', array(), 'Admin.Global')),
'state' => array('title' => $this->trans('State', array(), 'Admin.Global'), 'filter_key' => 'st!name'),
Expand Down
1 change: 1 addition & 0 deletions tests/E2E/package.json
Expand Up @@ -8,6 +8,7 @@
"start-selenium": "node_modules/selenium-standalone/bin/selenium-standalone start",
"high-test": "node_modules/mocha/bin/mocha test/campaigns/high/*",
"full-test": "node_modules/mocha/bin/mocha test/campaigns/full/*",
"selenium-test": "node_modules/mocha/bin/mocha test/campaigns/selenium/*",
"boom": "node_modules/mocha/bin/mocha test/campaigns/boom/*",
"test": "node_modules/mocha/bin/mocha test/campaigns/regular/*",
"install-upgrade-test": "node_modules/mocha/bin/mocha test/campaigns/install_upgrade/*",
Expand Down
155 changes: 155 additions & 0 deletions tests/E2E/prepare-shop.php
@@ -0,0 +1,155 @@
<?php
/**
* 2007-2018 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/OSL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2018 PrestaShop SA
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/

define('_PS_MODE_DEV_', false);
require(__DIR__.'/../../config/config.inc.php');

// useful variables

$language = Context::getContext()->language;
$shop = Context::getContext()->shop;
$dbPrefix = _DB_PREFIX_;

// Enable URL rewriting

function enableURLRewriting()
{
Configuration::updateValue('PS_REWRITING_SETTINGS', 1);
Tools::generateHtaccess();
}

if (!Configuration::get('PS_REWRITING_SETTINGS')) {
enableURLRewriting();
}

echo "- URL rewriting enabled\n";

//Enable returns

function enableReturns()
{
Configuration::updateValue('PS_ORDER_RETURN', 1);
}

if (!Configuration::get('PS_ORDER_RETURN')) {
enableReturns();
}

echo "- Returns enabled\n";

//Enable returns

function enableVouchers()
{
Configuration::updateValue('PS_CART_RULE_FEATURE_ACTIVE', 1);
}

if (!CartRule::isFeatureActive()) {
enableVouchers();
}

echo "- Vouchers enabled\n";

function enableGiftFeature()
{
Configuration::updateValue('PS_GIFT_WRAPPING', 1);
Configuration::updateValue('PS_GIFT_WRAPPING_PRICE', 5);
}

enableGiftFeature();


echo "- Gift feature display enabled\n";

// Setup modules

function disableModule($moduleName)
{
$module = Module::getInstanceByName($moduleName);
$module->disable();
echo "- module `$moduleName` disabled\n";
}

function hookModule($moduleName, $hookName)
{
$dbPrefix = _DB_PREFIX_;
$module = Module::getInstanceByName($moduleName);
$moduleId = $module->id;
Db::getInstance()->execute(
"DELETE FROM {$dbPrefix}hook_module WHERE id_module=$moduleId"
);
$module->registerHook($hookName);
echo "- module `$moduleName` hooked to `$hookName`\n";
}


// We need a customizable product: we add a single required text field to the product with id 1.

$customizableProduct = new Product(1, false, $language->id);

// Hijack the "_deleteOldLabels" method to remove existing labels
// (shouldn't be any but I want this script to be idempotent)
$refl = new ReflectionClass('Product');
$meth = $refl->getMethod('_deleteOldLabels');
$meth->setAccessible(true);
$meth->invoke($customizableProduct);

// First, create the label
$customizableProduct->createLabels(($fileFields = 0), ($textFields = 1));
$fields = $customizableProduct->getCustomizationFields();
$id_customization_field = current(current(current($fields)))['id_customization_field'];
// And inform the product that it has become customizable
$customizableProduct->customizable = 1;
$customizableProduct->text_fields = 1;
$customizableProduct->save();

// Then define it. There is unfortunately no API, so we encode the data in $_POST...
$_POST[implode('_', ['label', 1, $id_customization_field, $language->id, $shop->id])] = 'my field';
$_POST[implode('_', ['require', 1, $id_customization_field])] = true;
$customizableProduct->updateLabels();

echo "- added a required customizable text field to product #1\n";

// We need 2 languages for some tests
Language::checkAndAddLanguage('fr');
echo "- added French language just so that we have 2\n";
$languages = Language::getLanguages();
echo " Number of languages : ".count($languages)."\n";

$order = new Order(5);
$history = new OrderHistory();
$history->id_order = $order->id;
$history->id_employee = 1;

$use_existings_payment = false;
if (!$order->hasInvoice()) {
$use_existings_payment = true;
}
$history->changeIdOrderState(5, $order, $use_existings_payment);
$history->add();
echo "- Order number 5 is now delivered\n";

echo "Shop fixtures prepared for tests!\n";
165 changes: 165 additions & 0 deletions tests/E2E/test/campaigns/common_scenarios/combination.js
@@ -0,0 +1,165 @@
const {Menu} = require('../../selectors/BO/menu.js');
let promise = Promise.resolve();
const {AddProductPage} = require('../../selectors/BO/add_product_page');
let data = require('../../datas/product-data');

global.productVariations = [];

module.exports = {

createCombinations(client) {
test('should choose the size "S"', () => client.waitForExistAndClick(AddProductPage.combination_size_s));
test('should choose the size "M"', () => client.waitForExistAndClick(AddProductPage.combination_size_m));
test('should select the "Taupe" color ', () => client.waitForExistAndClick(AddProductPage.combination_color.replace('%ID', 6)));
test('should select the "Black" color ', () => client.waitForExistAndClick(AddProductPage.combination_color.replace('%ID', 11)));
test('should select the "Grey" color ', () => client.waitForExistAndClick(AddProductPage.combination_color.replace('%ID', 5)));
test('should select the "Orange" color ', () => client.waitForExistAndClick(AddProductPage.combination_color.replace('%ID', 13)));
test('should click on "Generate" button', () => client.waitForExistAndClick(AddProductPage.combination_generate_button));
/**
* This scenario is based on the bug described in this ticket
* http://forge.prestashop.com/browse/BOOM-4202
**/
test('should check the appearance of the generated combinations table ', () => client.waitForExist(AddProductPage.combination_table));
/**** END ****/
},

editCombinations(num) {
scenario('Edit the combinations quantity', client => {
for (let i = 1; i <= num; i++) {
test('should set the combination quantity to "10"', () => {
return promise
.then(() => client.getCombinationData(i))
.then(() => client.waitAndSetValue(AddProductPage.combination_attribute_quantity.replace('%NUMBER', global.combinationId), 10));
});
test('should set the price IT Value to "15"', () => {
return promise
.then(() => client.goToEditCombination())
.then(() => client.scrollTo((AddProductPage.combination_priceTI.replace('%NUMBER', global.combinationId))))
.then(() => client.waitAndSetValue(AddProductPage.combination_priceTI.replace('%NUMBER', global.combinationId), '15'));
});
if (i === 2) {
test('should click on "Set as default combination" button', () => client.scrollWaitForExistAndClick(AddProductPage.default_combination.replace('%NUMBER', combinationId)));
}
test('should go back to combination list', () => client.backToProduct());
if (i === 2) {
/**
* This scenario is based on the bug described in this ticket
* http://forge.prestashop.com/browse/BOOM-4827
**/
test('should check that the second combination is the default combination', () => client.isSelected(AddProductPage.combination_default_button.replace('%NUMBER', combinationId)));
}
test('should check that combination\'s quantity is equal to "10"', () => client.checkAttributeValue(AddProductPage.combination_attribute_quantity.replace('%NUMBER', combinationId), 'value', "10"));
test('should check that the "Impact on price (tax incl.) is equal to "15"', () => {
return promise
.then(() => client.goToEditCombination())
.then(() => client.checkAttributeValue(AddProductPage.combination_priceTI.replace('%NUMBER', combinationId), 'value', "15"));
});
test('should go back to combination list', () => client.backToProduct());
}
}, 'product/create_combinations');
},

editPricing() {
scenario('Edit product pricing', client => {
test('should click on "Pricing" tab', () => client.scrollWaitForExistAndClick(AddProductPage.product_pricing_tab, 50));
test('should set the "Price per unit (tax excl.)" input', () => client.waitAndSetValue(AddProductPage.unit_price, data.common.unitPrice));
test('should set the "Unit" input', () => client.waitAndSetValue(AddProductPage.unity, data.common.unity));
test('should set the "Price (tax excl.)" input', () => client.waitAndSetValue(AddProductPage.pricing_wholesale, data.common.wholesale));
test('should select the "Priority management"', () => client.selectPricingPriorities());
}, 'product/product')
},

editSeoInformations() {
scenario('Edit SEO information', client => {
test('should click on "SEO" tab', () => client.scrollWaitForExistAndClick(AddProductPage.product_SEO_tab, 50));
test('should set the "Meta title" input', () => client.waitAndSetValue(AddProductPage.SEO_meta_title, data.common.metatitle));
test('should set the "Meta description" input', () => client.waitAndSetValue(AddProductPage.SEO_meta_description, data.common.metadesc));
test('should set the "Friendly URL" input', () => client.waitAndSetValue(AddProductPage.SEO_friendly_url, data.common.shortlink));
}, 'product/product');
},

editProductOptions() {
scenario('Edit product options', client => {
test('should click on "Options" tab', () => client.scrollWaitForExistAndClick(AddProductPage.product_options_tab));
test('should select the "Visibility"', () => client.waitAndSelectByValue(AddProductPage.options_visibility, 'both'));
test('should click on "Web only (not sold in your retail store)" checkbox', () => client.waitForExistAndClick(AddProductPage.options_online_only));
test('should select the "Condition"', () => client.selectCondition());
test('should set the "ISBN" input', () => client.waitAndSetValue(AddProductPage.options_isbn, data.common.isbn));
test('should set the "EAN-13" input', () => client.waitAndSetValue(AddProductPage.options_ean13, data.common.ean13));
test('should set the "UPC" input', () => client.UPCEntry());
test('should click on "ADD A CUSTOMIZAITION" button', () => client.scrollWaitForExistAndClick(AddProductPage.options_add_customization_field_button, 50));
test('should set the customization field "Label"', () => client.waitAndSetValue(AddProductPage.options_first_custom_field_label, data.common.personalization.perso_text.name));
test('should select the customization field "Type" Text', () => client.waitAndSelectByValue(AddProductPage.options_first_custom_field_type, '1'));
test('should click on "Required" checkbox', () => client.waitForExistAndClick(AddProductPage.options_first_custom_field_require));
test('should click on "ADD A CUSTOMIZAITION" button', () => client.scrollWaitForExistAndClick(AddProductPage.options_add_customization_field_button, 50));
test('should set the second customization field "Label"', () => client.waitAndSetValue(AddProductPage.options_second_custom_field_label, data.common.personalization.perso_file.name));
test('should select the customization field "Type" File', () => client.waitAndSelectByValue(AddProductPage.options_second_custom_field_type, '0'));
test('should click on "ATTACH A NEW FILE" button', () => client.scrollWaitForExistAndClick(AddProductPage.options_add_new_file_button, 50));
test('should add a file', () => client.addFile(AddProductPage.options_select_file, 'image_test.jpg'), 50);
test('should set the file "Title" input', () => client.waitAndSetValue(AddProductPage.options_file_name, data.common.document_attach.name));
test('should set the file "Description" input', () => client.waitAndSetValue(AddProductPage.options_file_description, data.common.document_attach.desc));
test('should add the previous added file', () => client.scrollWaitForExistAndClick(AddProductPage.options_file_add_button, 50));
}, 'product/product');
},

editShipping() {
scenario('Edit product shipping', client => {
test('should click on "Shipping" tab', () => client.scrollWaitForExistAndClick(AddProductPage.product_shipping_tab, 50));
test('should set the "Width" input', () => client.waitAndSetValue(AddProductPage.shipping_width, data.common.cwidth));
test('should set the "Height" input', () => client.waitAndSetValue(AddProductPage.shipping_height, data.common.cheight));
test('should set the "Depth" input', () => client.waitAndSetValue(AddProductPage.shipping_depth, data.common.cdepth));
test('should set the "Weight" input', () => client.waitAndSetValue(AddProductPage.shipping_weight, data.common.cweight));
test('should set the "Does this product incur additional shipping costs?" input', () => client.waitAndSetValue(AddProductPage.shipping_fees, data.common.cadd_ship_coast));
test('should click on "My carrier (Delivery next day!)" button', () => client.scrollWaitForExistAndClick(AddProductPage.shipping_available_carriers, 50));
}, 'product/product');
},

checkProductCreationBO(AccessPageBO, numberCombinations) {
scenario('Check the product creation in the Back Office', client => {
test('should log in successfully in BO', () => client.signInBO(AccessPageBO));
test('should go to "Catalog" page', () => client.goToSubtabMenuPage(Menu.Sell.Catalog.catalog_menu, Menu.Sell.Catalog.products_submenu));
test('should search for product by name', () => client.searchProductByName(data.standard.name + 'C' + date_time));
test('should check the existence of product name', () => client.checkTextValue(AddProductPage.catalog_product_name, data.standard.name + 'C' + date_time));
test('should check the existence of product reference', () => client.checkTextValue(AddProductPage.catalog_product_reference, data.common.product_reference));
test('should check the existence of product category', () => client.checkTextValue(AddProductPage.catalog_product_category, data.standard.new_category_name + 'C' + date_time));
test('should check the existence of product price TE', () => client.checkProductPriceTE(data.common.priceTE));
test('should check the existence of product quantity Combination', () => client.checkTextValue(AddProductPage.catalog_product_quantity, (numberCombinations * 10).toString()));
test('should check the existence of product status', () => client.checkTextValue(AddProductPage.catalog_product_online, 'check'));
test('should click on "Reset" button', () => client.waitForExistAndClick(AddProductPage.catalog_reset_filter));
}, 'product/check_product', true);
},

/**
* This scenario is based on the bug described in this ticket
* http://forge.prestashop.com/browse/BOOM-3000
**/

checkCombinationProductFo(SearchProductPage, productPage, AccessPageFO) {
scenario('Check that the product with combination is well displayed in the Front Office', client => {
test('should set the shop language to "English"', () => client.changeLanguage());
test('should search for the product', () => client.searchByValue(SearchProductPage.search_input, SearchProductPage.search_button, data.standard.name + 'C' + date_time));
test('should go to the product page', () => client.waitForExistAndClick(SearchProductPage.product_result_name));
test('should check that the product name is equal to "' + (data.standard.name + 'C' + date_time).toUpperCase() + '"', () => client.checkTextValue(productPage.product_name, (data.standard.name + 'C' + date_time).toUpperCase()));
test('should check that the product price is equal to "€27.00"', () => client.checkTextValue(productPage.product_price, '€27.00'));
test('should set the product size to "S"', () => client.waitAndSelectByAttribute(productPage.product_size, 'title', 'S', 3000));
test('should check that the product color is equal to "Grey"', () => client.checkTextValue(productPage.product_color, 'Grey'));
test('should check that the product quantity us equal to "10"', () => client.checkAttributeValue(productPage.product_quantity, 'data-stock', '10'));
test('should check that the "summary" is equal to "' + data.common.summary + '"', () => client.checkTextValue(productPage.product_summary, data.common.summary));
test('should check that the "description" is equal to "' + data.common.description + '"', () => client.checkTextValue(productPage.product_description, data.common.description));
test('should check that the product reference is equal to "' + data.common.product_reference + '"', () => {
return promise
.then(() => client.waitForExistAndClick(productPage.product_tab_list.replace('%I', 2), 2000))
.then(() => client.scrollTo(productPage.product_tab_list.replace('%I', 2), 180))
.then(() => client.pause(2000))
.then(() => client.checkTextValue(productPage.product_reference, data.common.product_reference));
});
}, 'product/product');
scenario('Logout from the Front Office', client => {
test('should logout successfully from the Front Office', () => {
return promise
.then(() => client.scrollTo(AccessPageFO.sign_out_button))
.then(() => client.signOutFO(AccessPageFO));
});
}, 'product/product',true);
}
};