Skip to content

Commit

Permalink
TE: add delivery slip test
Browse files Browse the repository at this point in the history
  • Loading branch information
YosraAk committed Jan 3, 2019
1 parent 5853927 commit e5f4062
Show file tree
Hide file tree
Showing 17 changed files with 359 additions and 82 deletions.
4 changes: 2 additions & 2 deletions tests/E2E/test/campaigns/common_scenarios/attribute.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ module.exports = {
});
test('should click on "Add new value" button', () => client.waitForExistAndClick(AttributeSubMenu.add_value_button));
Object.keys(data.values).forEach(function (key) {
test('should set the "Value" input', () => client.waitAndSetValue(AttributeSubMenu.value_input, data.values[key].value));
test('should set the "Value" input', () => client.waitAndSetValue(AttributeSubMenu.value_input, data.values[key].value), 2000);
if (data.values[key].hasOwnProperty('color')) {
test('should set the "Color" input', () => client.waitAndSetValue(AttributeSubMenu.color_input, data.values[key].color));
}
Expand Down Expand Up @@ -90,7 +90,7 @@ module.exports = {
test('should select the attribute', () => client.waitForExistAndClick(AttributeSubMenu.attribute_name));
Object.keys(data.values).forEach(function (key) {
test('should click on "Edit" action', () => client.waitForExistAndClick(AttributeSubMenu.update_value_button.replace('%POS', key)));
test('should set the "Value" input', () => client.waitAndSetValue(AttributeSubMenu.value_input, data.values[key].value));
test('should set the "Value" input', () => client.waitAndSetValue(AttributeSubMenu.value_input, data.values[key].value, 2000));
test('should click on "Save" button', () => client.waitForExistAndClick(AttributeSubMenu.save_value_button));
});
test('should verify the appearance of the green validation', () => client.checkTextValue(CatalogPage.success_panel, '×\nSuccessful update.'));
Expand Down
104 changes: 87 additions & 17 deletions tests/E2E/test/campaigns/common_scenarios/order.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ const {MerchandiseReturns} = require('../../selectors/BO/Merchandise_returns');
let dateFormat = require('dateformat');
let data = require('../../datas/customer_and_address_data');
let promise = Promise.resolve();

global.orderInformation = [];

module.exports = {
Expand All @@ -30,6 +29,10 @@ module.exports = {
});
test('should click on "Add to cart" button ', () => client.waitForExistAndClick(CheckoutOrderPage.add_to_cart_button));
test('should click on proceed to checkout button 1', () => client.waitForVisibleAndClick(CheckoutOrderPage.proceed_to_checkout_modal_button));
/**
* 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 click on proceed to checkout button 2', () => client.waitForExistAndClick(CheckoutOrderPage.proceed_to_checkout_button));

Expand Down Expand Up @@ -101,8 +104,8 @@ module.exports = {
}

scenario('Choose "SHIPPING METHOD"', client => {
test('should choose shipping method my carrier', () => client.waitForExistAndClick(CheckoutOrderPage.shipping_method_option));
test('should create message', () => client.waitAndSetValue(CheckoutOrderPage.message_textarea, 'Order message test'));
test('should choose shipping method my carrier', () => client.waitForExistAndClick(CheckoutOrderPage.shipping_method_option, 2000));
test('should create message', () => client.waitAndSetValue(CheckoutOrderPage.message_textarea, 'Order message test', 1000));
test('should click on "confirm delivery" button', () => client.waitForExistAndClick(CheckoutOrderPage.checkout_step3_continue_button));
}, 'common_client');

Expand Down Expand Up @@ -172,17 +175,25 @@ module.exports = {
},

getShoppingCartsInfo: async function (client) {
let idColumn;
await client.isVisible(ShoppingCart.checkbox_input);

if (isVisible) {
idColumn = 2;
} else {
idColumn = 1;
}
for (let i = 1; i <= global.shoppingCartsNumber; i++) {
await client.getTextInVar(ShoppingCart.id.replace('%NUMBER', i), "id");
await client.getTextInVar(ShoppingCart.order_id.replace('%NUMBER', i), "order_id");
await client.getTextInVar(ShoppingCart.customer.replace('%NUMBER', i), "customer");
await client.getTextInVar(ShoppingCart.total.replace('%NUMBER', i), "total");
await client.getTextInVar(ShoppingCart.carrier.replace('%NUMBER', i), "carrier");
await client.getTextInVar(ShoppingCart.date.replace('%NUMBER', i), "date");
await client.getTextInVar(ShoppingCart.customer_online.replace('%NUMBER', i), "customer_online");
await parseInt(global.tab["order_id"]) ? global.tab["order_id"] = parseInt(global.tab["order_id"]) : global.tab["order_id"] = '"' + global.tab["order_id"] + '"';
await global.tab["carrier"] === '--' ? global.tab["carrier"] = '' : global.tab["carrier"] = '"' + global.tab["carrier"] + '"';
await global.tab["customer_online"] === 'Yes' ? global.tab["customer_online"] = 1 : global.tab["customer_online"] = 0;
await client.getTextInVar(ShoppingCart.id.replace('%NUMBER', i).replace('%COL', idColumn), "id");
await client.getTextInVar(ShoppingCart.order_id.replace('%NUMBER', i).replace('%COL', idColumn + 1), "order_id");
await client.getTextInVar(ShoppingCart.customer.replace('%NUMBER', i).replace('%COL', idColumn + 2), "customer");
await client.getTextInVar(ShoppingCart.total.replace('%NUMBER', i).replace('%COL', idColumn + 3), "total");
await client.getTextInVar(ShoppingCart.carrier.replace('%NUMBER', i).replace('%COL', idColumn + 4), "carrier");
await client.getTextInVar(ShoppingCart.date.replace('%NUMBER', i).replace('%COL', idColumn + 5), "date");
await client.getTextInVar(ShoppingCart.customer_online.replace('%NUMBER', i).replace('%COL', idColumn + 6), "customer_online");
await parseInt(global.tab["order_id"]) ? global.tab["order_id"] = parseInt(global.tab["order_id"]) : global.tab["order_id"] = '"' + global.tab["order_id"] + '"';
await global.tab["carrier"] === '--' ? global.tab["carrier"] = '' : global.tab["carrier"] = '"' + global.tab["carrier"] + '"';
await global.tab["customer_online"] === 'Yes' ? global.tab["customer_online"] = 1 : global.tab["customer_online"] = 0;
global.tab["date"] = await dateFormat(global.tab["date"], "yyyy-mm-dd HH:MM:ss");
await global.orders.push(parseInt(global.tab["id"]) + ';' + global.tab["order_id"] + ';' + '"' + global.tab["customer"] + '"' + ';' + global.tab["total"] + ';' + global.tab["carrier"] + ';' + '"' + global.tab["date"] + '"' + ';' + global.tab["customer_online"]);
}
Expand Down Expand Up @@ -270,7 +281,7 @@ 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 click on "DOCUMENTS" subtab', () => client.scrollWaitForExistAndClick(OrderPage.document_submenu));
test('should get the credit slip name', () => client.getDocumentName(OrderPage.credit_slip_document_name));
test('should get the credit slip name', () => client.getCreditSlipDocumentName(OrderPage.credit_slip_document_name));
test('should go to "Credit slip" page', () => client.goToSubtabMenuPage(Menu.Sell.Orders.orders_menu, Menu.Sell.Orders.credit_slips_submenu));
test('should click on "Download credit slip" button', () => {
return promise
Expand All @@ -290,7 +301,7 @@ module.exports = {
});
test('should check the "Name & Last name" ', () => client.checkDocument(global.downloadsFolderPath, global.creditSlip, global.tab['accountName']));
test('should check the "Invoice date Reference"', () => client.checkDocument(global.downloadsFolderPath, global.creditSlip, global.orderInformation[i].invoiceDate));
test('should check the "Invoice order Reference"', () => client.checkDocument(global.downloadsFolderPath, global.creditSlip, global.orderInformation[i].orderRef, 5000));
test('should check the "Invoice order Reference"', () => client.checkDocument(global.downloadsFolderPath, global.creditSlip, global.orderInformation[i].orderRef));
test('should check the "Product combination" ', () => client.checkDocument(global.downloadsFolderPath, global.creditSlip, global.orderInformation[i].productCombination));
test('should check the "Product quantity" ', () => client.checkDocument(global.downloadsFolderPath, global.creditSlip, global.orderInformation[i].productQuantity));
test('should check the "Product name" ', () => client.checkDocument(global.downloadsFolderPath, global.creditSlip, global.orderInformation[i].productName));
Expand All @@ -302,7 +313,6 @@ module.exports = {
test('should check the "Tax detail" ', () => {
return promise
.then(() => client.checkDocument(global.downloadsFolderPath, global.creditSlip, 'Products'))
.then(() => client.deleteDownloadedDocument(global.creditSlip));
});
}, 'order');
},
Expand Down Expand Up @@ -336,5 +346,65 @@ module.exports = {
test('should check the "Total" of the product n°' + i, () => client.checkDocument(global.downloadsFolderPath, 'invoices', global.orderInfo[i - 1].Total));
test('should check the "Total Tax" of the product n°' + i, () => client.checkDocument(global.downloadsFolderPath, 'invoices', global.orderInfo[i - 1].TotalTax));
test('should check the "Carrier" name of the product n°' + i, () => client.checkDocument(global.downloadsFolderPath, 'invoices', global.orderInfo[i - 1].Carrier));
}
},
updateStatus: function (status) {
scenario('Change the order state to "' + status + '"', client => {
test('should go to "Orders" page', () => 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 "' + status + '"', () => client.updateStatus(status));
test('should click on "Update state" button', () => client.waitForExistAndClick(OrderPage.update_status_button));
test('should check that the status was updated', () => client.waitForVisible(OrderPage.status.replace('%STATUS', status)));
}, 'order');
},
getDeliveryInformation: function (index) {
scenario('Get all the order information', client => {
test('should get all order information', () => {
return promise
.then(() => client.getTextInVar(OrderPage.order_id, "OrderID"))
.then(() => client.getTextInVar(OrderPage.order_date, "invoiceDate"))
.then(() => client.getTextInVar(OrderPage.order_ref, "OrderRef"))
.then(() => {
client.getTextInVar(OrderPage.product_information, "ProductRef").then(() => {
global.tab['ProductRef'] = global.tab['ProductRef'].split('\n')[1];
global.tab['ProductRef'] = global.tab['ProductRef'].substring(18);
})
})
.then(() => client.pause(2000))
.then(() => {
client.getTextInVar(OrderPage.product_information, "ProductCombination").then(() => {
global.tab['ProductCombination'] = global.tab['ProductCombination'].split('\n')[0];
global.tab['ProductCombination'] = global.tab['ProductCombination'].split(':')[1];
})
})
.then(() => client.pause(2000))
.then(() => client.getTextInVar(OrderPage.product_quantity, "ProductQuantity"))
.then(() => {
client.getTextInVar(OrderPage.product_name_tab, "ProductName").then(() => {
global.tab['ProductName'] = global.tab['ProductName'].substring(0, 25);
})
})
.then(() => client.getTextInVar(OrderPage.product_total_price, "ProductTotal"))
.then(() => {
global.orderInformation[index] = {
"OrderId": global.tab['OrderID'].replace("#", ''),
"invoiceDate": global.tab['invoiceDate'],
"OrderRef": global.tab['OrderRef'],
"ProductRef": global.tab['ProductRef'],
"ProductCombination": global.tab['ProductCombination'],
"ProductQuantity": global.tab['ProductQuantity'],
"ProductName": global.tab['ProductName'],
"ProductTotal": global.tab['ProductTotal']
}
});
});
}, 'order');
},
disableMerchandise: function () {
scenario('Disable Merchandise Returns', client => {
test('should go to "Merchandise Returns" page', () => client.goToSubtabMenuPage(Menu.Sell.CustomerService.customer_service_menu, Menu.Sell.CustomerService.merchandise_returns_submenu));
test('should disable "Merchandise Returns"', () => client.waitForExistAndClick(MerchandiseReturns.disableReturns));
test('should click on "Save" button', () => client.waitForExistAndClick(MerchandiseReturns.save_button));
test('should check the success message', () => client.checkTextValue(MerchandiseReturns.success_msg, 'The settings have been successfully updated.', 'contain'));
}, 'order');
},
};
2 changes: 1 addition & 1 deletion tests/E2E/test/campaigns/common_scenarios/product.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ module.exports = {
client.pause(0);
}
})
.then(() => client.getCombinationData(1, 5000));
.then(() => client.getCombinationData(1, 7000));
});
test('should select all the generated variations', () => client.waitForVisibleAndClick(AddProductPage.var_selected, 2000));
test('should set the "Variations quantity" input', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ scenario('Export shopping carts in the Back Office', () => {
test('should get the "Shopping Carts" number', () => client.getShoppingCartNumber(ShoppingCart.id_shopping_carts));
test('should get the "Shopping Carts" info', () => orderCommonScenarios.getShoppingCartsInfo(client));
test('should export the "Shopping Carts" then check the exported file information', () => orderCommonScenarios.checkExportedFile(client));
test('should delete the downloaded file', () => client.deleteFile(global.downloadsFolderPath, global.exportCartFileName, "", 2000));
}, 'order');
}, 'order', true);
Loading

0 comments on commit e5f4062

Please sign in to comment.