Skip to content

Commit

Permalink
Merge pull request PrestaShop#13588 from boubkerbribri/14_15_16_orders
Browse files Browse the repository at this point in the history
Fixing some tests orders
  • Loading branch information
mbadrani authored Apr 29, 2019
2 parents b0d0123 + 84a7db2 commit 7a5dcfb
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 17 deletions.
8 changes: 6 additions & 2 deletions tests/E2E/test/campaigns/common_scenarios/order.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ module.exports = {
test('should select product "color Black"', () => client.waitForExistAndClick(productPage.first_product_color));
test('should set the product "quantity"', () => {
return promise
.then(() => client.waitAndSetValue(productPage.first_product_quantity, "4"))
.then(() => client.setInputValue(productPage.first_product_quantity, "4"))
.then(() => client.getTextInVar(CheckoutOrderPage.product_current_price, "first_basic_price"));
});
if (checkAvailableQuantity === true) {
Expand All @@ -41,7 +41,7 @@ module.exports = {
* This scenario is based on the bug described in this ticket
* https://github.com/PrestaShop/PrestaShop/issues/9841
**/
test('should set the quantity to "4" using the keyboard', () => client.waitAndSetValue(CheckoutOrderPage.quantity_input.replace('%NUMBER', 1), '4'));
test('should set the quantity to "4" using the keyboard', () => client.setInputValue(CheckoutOrderPage.quantity_input.replace('%NUMBER', 1), '4'));
test('should click on proceed to checkout button 2', () => client.waitForExistAndClick(CheckoutOrderPage.proceed_to_checkout_button));

if (authentication === "create_account" || authentication === "guest") {
Expand Down Expand Up @@ -267,6 +267,10 @@ module.exports = {
test('should go to the orders list', () => client.goToSubtabMenuPage(Menu.Sell.Orders.orders_menu, Menu.Sell.Orders.orders_submenu));
test('should go to the created order', () => client.waitForExistAndClick(OrderPage.order_view_button.replace('%ORDERNumber', 1)));
test('should change order state to "Payment accepted"', () => client.changeOrderState(OrderPage, 'Payment accepted'));
/**
* should refresh the page, to pass the error
*/
test('should refresh the page', () => client.refresh());
test('should click on "Partial refund" button', () => client.waitForExistAndClick(OrderPage.partial_refund));
test('should set the "quantity refund" to "2"', () => client.waitAndSetValue(OrderPage.quantity_refund, refundedValue));
test('should click on "Re-stock products" CheckBox', () => client.waitForExistAndClick(OrderPage.re_stock_product));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ scenario('Generate a PDF by date', () => {
for (let i = 1; i <= 2; i++) {
test('should go the order n°' + i, () => client.waitForExistAndClick(OrderPage.order_view_button.replace("%ORDERNumber", i)));
test('should change order state to "payment accepted"', () => client.changeOrderState(OrderPage, 'Payment accepted'));
/**
* should refresh the page, to pass the error
*/
test('should refresh the page', () => client.refresh());
test('should get all order information', () => {
return promise
.then(() => client.getTextInVar(OrderPage.order_date, "invoiceDate"))
Expand Down Expand Up @@ -142,8 +146,8 @@ scenario('Generate a PDF by date', () => {
}, 'order');
}, 'order');
scenario('Change the date', client => {
test('should set the "From" date', () => client.waitAndSetValue(Invoices.from_input, '2020-08-04'));
test('should set the "To" date', () => client.waitAndSetValue(Invoices.from_input, '2020-08-10'));
test('should set the "From" date', () => client.setInputValue(Invoices.from_input, '2020-08-04'));
test('should set the "To" date', () => client.setInputValue(Invoices.from_input, '2020-08-10'));
test('should click on "Generate PDF file by date"', () => client.waitForExistAndClick(Invoices.generate_pdf_button));
test('should check that no invoice has been found', () => client.checkTextValue(Invoices.no_invoice_alert, 'No invoice has been found for this period.', 'contain'));
}, 'order');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ scenario('Generate a PDF by status', () => {
test('should go to "Product settings" page', () => client.goToSubtabMenuPage(Menu.Sell.Orders.orders_menu, Menu.Sell.Orders.orders_submenu));
for (let i = 1; i <= 2; i++) {
test('should go the order n°' + i, () => client.waitForExistAndClick(OrderPage.order_view_button.replace("%ORDERNumber", i)));
/**
* should refresh the page, to pass the error
*/
test('should refresh the page', () => client.refresh());
test('should go to "Documents" tab', () => client.waitForExistAndClick(OrderPage.documents_tab));
test('should click on "Generate invoice" button', () => client.waitForExistAndClick(OrderPage.generate_invoice_button));
test('should verify the success message', () => client.waitForVisible(OrderPage.success_msg));
Expand Down Expand Up @@ -140,6 +144,10 @@ scenario('Generate a PDF by status', () => {
} else {
test('should change order state to "Canceled"', () => client.changeOrderState(OrderPage, 'Canceled'));
}
/**
* should refresh the page, to pass the error
*/
test('should refresh the page', () => client.refresh());
test('should go to "Documents" tab', () => client.waitForExistAndClick(OrderPage.documents_tab));
test('should click on "Generate invoice" button', () => client.waitForExistAndClick(OrderPage.generate_invoice_button));
test('should verify the success message', () => client.waitForVisible(OrderPage.success_msg));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ scenario('Print the invoice of an order', () => {
test('should select "Tax excluded" option for "Price display method"', () => client.waitAndSelectByValue(CustomerSettings.groups.price_display_method, "1"));
test('should click on "Save" button', () => client.waitForExistAndClick(CustomerSettings.groups.save_button));
test('should go to "International > Taxes" page', () => client.goToSubtabMenuPage(Menu.Improve.International.international_menu, Menu.Improve.International.taxes_submenu));
test('should display tax in the shopping cart', () => client.waitForExistAndClick(Taxes.taxes.display_tax.replace('%D', 'on')));
test('should click on "Save" button', () => client.waitForExistAndClick(Taxes.taxes.save_button));
test('should display tax in the shopping cart', () => client.waitForExistAndClickJs(Taxes.taxes.display_tax.replace('%D', '1')));
test('should click on "Save" button', () => client.waitForExistAndClickJs(Taxes.taxes.save_button,false));
}, 'order');

for (let i = 0; i <= 2; i++) {
Expand All @@ -106,7 +106,7 @@ scenario('Print the invoice of an order', () => {
test('should select product "size M"', () => client.waitAndSelectByValue(productPage.first_product_size, '2'));
test('should set the product "quantity"', () => {
return promise
.then(() => client.waitAndSetValue(productPage.first_product_quantity, "4"))
.then(() => client.setInputValue(productPage.first_product_quantity, "4"))
.then(() => client.getTextInVar(CheckoutOrderPage.product_current_price, "basic_price_" + i));
});
test('should click on "ADD TO CART" button', () => client.waitForExistAndClick(CheckoutOrderPage.add_to_cart_button));
Expand All @@ -117,7 +117,7 @@ scenario('Print the invoice of an order', () => {
test('should click on "PROCEED TO CHECKOUT" button 1', () => client.waitForVisibleAndClick(CheckoutOrderPage.proceed_to_checkout_modal_button));
}
}
test('should set the quantity to "4" using the keyboard', () => client.waitAndSetValue(CheckoutOrderPage.quantity_input.replace('%NUMBER', 1), '4'));
test('should set the quantity to "4" using the keyboard', () => client.setInputValue(CheckoutOrderPage.quantity_input.replace('%NUMBER', 1), '4'));
test('should click on "PROCEED TO CHECKOUT" button 2', () => client.waitForExistAndClick(CheckoutOrderPage.proceed_to_checkout_button));
test('should click on confirm address button', () => client.waitForExistAndClick(CheckoutOrderPage.checkout_step2_continue_button));
test('should choose shipping method my carrier', () => client.waitForExistAndClick(CheckoutOrderPage.shipping_method_option, 2000));
Expand Down Expand Up @@ -171,6 +171,10 @@ scenario('Print the invoice of an order', () => {
test('should check that the status is "Awaiting bank wire payment"', () => client.checkTextValue(OrderPage.order_status, 'Awaiting bank wire payment'));
test('should set order status to "Payment accepted"', () => client.updateStatus('Payment accepted'));
test('should click on "UPDATE STATUS" button', () => client.waitForExistAndClick(OrderPage.update_status_button));
/**
* should refresh the page, to pass the error
*/
test('should refresh the page', () => client.refresh());
test('should check that the status is "Payment accepted"', () => client.checkTextValue(OrderPage.order_status, 'Payment accepted'));
}, 'order');

Expand Down Expand Up @@ -250,7 +254,7 @@ scenario('Print the invoice of an order', () => {
test('should select "Tax included" option for "Price display method"', () => client.waitAndSelectByValue(CustomerSettings.groups.price_display_method, "0"));
test('should click on "Save" button', () => client.waitForExistAndClick(CustomerSettings.groups.save_button));
test('should go to "International > Taxes" page', () => client.goToSubtabMenuPage(Menu.Improve.International.international_menu, Menu.Improve.International.taxes_submenu));
test('should in display tax in the shopping cart', () => client.waitForExistAndClick(Taxes.taxes.display_tax.replace('%D', 'off')));
test('should click on "Save" button', () => client.waitForExistAndClick(Taxes.taxes.save_button));
test('should in display tax in the shopping cart', () => client.waitForExistAndClickJs(Taxes.taxes.display_tax.replace('%D', '0')));
test('should click on "Save" button', () => client.waitForExistAndClickJs(Taxes.taxes.save_button,false));
}, 'order');
}, 'order', true);
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ scenario('Print the delivery slips of an order', () => {
test('should check status to be equal to "Awaiting check payment"', () => client.checkTextValue(OrderPage.order_status, 'Awaiting check payment'));
test('should set order status to "Shipped"', () => client.updateStatus('Shipped'));
test('should click on "UPDATE STATUS" button', () => client.waitForExistAndClick(OrderPage.update_status_button));
/**
* should refresh the page, to pass the error
*/
test('should refresh the page', () => client.refresh());
test('should check that the status is "Shipped"', () => client.checkTextValue(OrderPage.order_status, 'Shipped'));
}, 'order');
commonOrder.getDeliveryInformation(0);
Expand Down
37 changes: 32 additions & 5 deletions tests/E2E/test/clients/common_client.js
Original file line number Diff line number Diff line change
Expand Up @@ -814,17 +814,44 @@ class CommonClient {
});
}
/**
* perform a javascript click
* perform a javascript click, function waitForExistAndClick sometimes clicks on the wrong element so we rely on JS
* click rather than a screen click
* @param selector, xpath of the element
* @param pause
* @return true, if click works, false otherwise
*/
waitForExistAndClickJs(selector, pause = 0) {
waitForExistAndClickJs(selector, isXpath = true, pause = 0) {
return this.client
.pause(pause)
.execute(function (selector) {
return document.evaluate(selector,document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue.click();
}, selector);
.execute(function (selector,isXpath) {
if(isXpath) return document.evaluate(selector,document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue.click();
else return document.querySelector(selector).click();
}, selector,isXpath);
}


/**
* set input javascript method, function waitAndSetValue don't delete value before set the new value so we used this
* to be sure that the input is empty before setting the new value
* @param selector, the input
* @param value, value to set
* @param isXpath, selector is xpath or css selector
* @param pause
* @return {*}
*/
setInputValue(selector, value, isXpath = true, pause = 0) {
return this.client
.pause(pause)
.execute(function (selector, value, isXpath) {
if(isXpath) {
document.evaluate(selector,document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue.value = '';
document.evaluate(selector,document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue.value = value;
}
else {
document.querySelector(selector).value = '';
document.querySelector(selector).value = value;
}
}, selector, value, isXpath);
}
}

Expand Down
4 changes: 2 additions & 2 deletions tests/E2E/test/selectors/BO/international/taxes.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ module.exports = {
filter_name_input: '//input[@id="tax_name"]',
filter_search_button: '//button[@name="tax[actions][search]"]',
tax_field_column: '//*[@id="tax_grid_table"]//tr[%L]//td[%C]',
display_tax: '//*[@id="conf_id_PS_TAX_DISPLAY"]//label[@for="PS_TAX_DISPLAY_%D"]',
save_button: '//*[@id="tax_fieldset_general"]/div[3]/button',
display_tax: '//*[@id="form_options_display_tax_in_cart_%D"]',
save_button: '.card .card-footer button',

}
}
Expand Down

0 comments on commit 7a5dcfb

Please sign in to comment.