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

Create Order with account #9423

Merged
merged 1 commit into from Sep 19, 2018
Merged
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
47 changes: 39 additions & 8 deletions tests/E2E/test/campaigns/common_scenarios/order.js
Expand Up @@ -10,10 +10,10 @@ let data = require('../../datas/customer_and_address_data');
let promise = Promise.resolve();

module.exports = {
createOrderFO: function (authentication = "connected") {
createOrderFO: function (authentication = "connected", login = 'pub@prestashop.com', password = '123456789') {
scenario('Create order in the Front Office', client => {
test('should set the language of shop to "English"', () => client.changeLanguage());
test('should go to the first product page', () => client.waitForExistAndClick(productPage.first_product));
test('should go to the first product page', () => client.waitForExistAndClick(productPage.first_product, 2000));
test('should select product "size M" ', () => client.waitAndSelectByValue(productPage.first_product_size, '2'));
test('should select product "color Black"', () => client.waitForExistAndClick(productPage.first_product_color));
test('should set the product "quantity"', () => {
Expand Down Expand Up @@ -50,24 +50,55 @@ module.exports = {

if (authentication === "connect") {
scenario('Login with existing customer', client => {
test('should choose shipping method my carrier', () => client.waitForExistAndClick(accountPage.sign_tab));
test('should set the "Email" input', () => client.waitAndSetValue(accountPage.signin_email_input, 'pub@prestashop.com'));
test('should set the "Password" input', () => client.waitAndSetValue(accountPage.signin_password_input, '123456789'));
test('should click on "Sign in"', () => client.waitForExistAndClick(accountPage.sign_tab));
test('should set the "Email" input', () => client.waitAndSetValue(accountPage.signin_email_input, login));
test('should set the "Password" input', () => client.waitAndSetValue(accountPage.signin_password_input, password));
test('should click on "CONTINUE" button', () => client.waitForExistAndClick(accountPage.continue_button));
}, 'common_client');
}

if (authentication === "connected" || authentication === "connect") {
scenario('Choose the personal and delivery address ', client => {
test('should click on confirm address button', () => client.waitForExistAndClick(CheckoutOrderPage.checkout_step2_continue_button));
if (login !== 'pub@prestashop.com') {
scenario('Add new address', client => {
test('should set the "company" input', () => client.waitAndSetValue(CheckoutOrderPage.company_input, 'prestashop'));
test('should set "VAT number" input', () => client.waitAndSetValue(CheckoutOrderPage.vat_number_input, '0123456789'));
test('should set "Address" input', () => client.waitAndSetValue(CheckoutOrderPage.address_input, '12 rue d\'amsterdam'));
test('should set "Second address" input', () => client.waitAndSetValue(CheckoutOrderPage.address_second_input, 'RDC'));
test('should set "Postal code" input', () => client.waitAndSetValue(CheckoutOrderPage.zip_code_input, '75009'));
test('should set "City" input', () => client.waitAndSetValue(CheckoutOrderPage.city_input, 'Paris'));
test('should set "Pays" input', () => client.waitAndSelectByVisibleText(CheckoutOrderPage.country_input, 'France'));
test('should set "Home phone" input', () => client.waitAndSetValue(CheckoutOrderPage.phone_input, '0123456789'));
test('should click on "Use this address for invoice too', () => client.waitForExistAndClick(CheckoutOrderPage.use_address_for_facturation_input));
test('should click on "CONTINUE', () => client.waitForExistAndClick(accountPage.new_address_btn));

scenario('Add Invoice Address', client => {
test('should set the "company" input', () => client.waitAndSetValue(CheckoutOrderPage.invoice_company_input, 'prestashop'));
test('should set "VAT number" input', () => client.waitAndSetValue(CheckoutOrderPage.invoice_vat_number_input, '0123456789'));
test('should set "Address" input', () => client.waitAndSetValue(CheckoutOrderPage.invoice_address_input, '12 rue d\'amsterdam'));
test('should set "Second address" input', () => client.waitAndSetValue(CheckoutOrderPage.invoice_address_second_input, 'RDC'));
test('should set "Postal code" input', () => client.waitAndSetValue(CheckoutOrderPage.invoice_zip_code_input, '75009'));
test('should set "City" input', () => client.waitAndSetValue(CheckoutOrderPage.invoice_city_input, 'Paris'));
test('should set "Pays" input', () => client.waitAndSelectByVisibleText(CheckoutOrderPage.invoice_country_input, 'France'));
test('should set "Home phone" input', () => client.waitAndSetValue(CheckoutOrderPage.invoice_phone_input, '0123456789'));
test('should click on "CONTINUE" button', () => client.waitForExistAndClick(accountPage.new_address_btn));
}, 'order');

}, 'common_client');
}

if (authentication === "connected" || authentication === "connect") {
if (login === 'pub@prestashop.com') {
scenario('Choose the personal and delivery address ', client => {
test('should click on confirm address button', () => client.waitForExistAndClick(CheckoutOrderPage.checkout_step2_continue_button));
}, 'common_client');
}
}

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 click on "confirm delivery" button', () => client.waitForExistAndClick(CheckoutOrderPage.checkout_step3_continue_button));
}, 'common_client');

scenario('Choose "PAYMENT" method', client => {
test('should set the payment type "Payment by bank wire"', () => client.waitForExistAndClick(CheckoutOrderPage.checkout_step4_payment_radio));
test('should set "the condition to approve"', () => client.waitForExistAndClick(CheckoutOrderPage.condition_check_box));
Expand Down
Expand Up @@ -51,7 +51,7 @@ scenario('Delete shopping carts', () => {
return promise
.then(() => client.switchWindow(1))
});
commonOrder.createOrderFO();
commonOrder.createOrderFO("connected");
}, 'order');
scenario('Delete a shopping cart related to an order', client => {
test('should go back to the Back office', () => {
Expand Down
Expand Up @@ -16,7 +16,7 @@ scenario('Create order in the Front Office', () => {
test('should login successfully in the Front Office', () => client.signInFO(AccessPageFO));
}, 'order');

commonOrder.createOrderFO();
commonOrder.createOrderFO("connected");

scenario('Logout from the Front Office', client => {
test('should logout successfully from the Front Office', () => client.signOutFO(AccessPageFO));
Expand Down
@@ -0,0 +1,61 @@
const {AccessPageFO} = require('../../../selectors/FO/access_page');
const {AccessPageBO} = require('../../../selectors/BO/access_page');
const {AddProductPage} = require('../../../selectors/BO/add_product_page');
const {SearchProductPage} = require('../../../selectors/FO/search_product_page');
const {productPage} = require('../../../selectors/FO/product_page');
const {CheckoutOrderPage} = require('../../../selectors/FO/order_page');
const {Menu} = require('../../../selectors/BO/menu.js');
const {accountPage} = require('../../../selectors/FO/add_account_page');
const {ProductSettings} = require('../../../selectors/BO/shopParameters/product_settings');
const commonOrder = require('../../common_scenarios/order');
const commonProduct = require('../../common_scenarios/product');
let promise = Promise.resolve();

const customer_common_scenarios = require('../../common_scenarios/customer');

let customerData = {
first_name: 'John',
last_name: 'DOE',
email_address: 'test@prestashop.com',
password: '123456789',
birthday: {
day: '18',
month: '12',
year: '1991'
}
};

scenario('Create Order with account', () => {
scenario('Login in the Back Office', client => {
test('should open the browser', () => client.open());
test('should login successfully in the Back Office', () => client.signInBO(AccessPageBO));
}, 'customer');

customer_common_scenarios.createCustomer(customerData);

scenario('Logout from the Back Office', client => {
test('should logout successfully from the Back Office', () => client.signOutBO());
}, 'customer');

scenario('Create order in the Front Office', () => {
scenario('Open the browser and connect to the Front Office', client => {
test('should login successfully in the Front Office', () => client.linkAccess(global.URL));
}, 'order');

commonOrder.createOrderFO('connect', date_time + customerData.email_address, customerData.password);

}, 'order');
}, 'order', true);

scenario('Check the created order in the Back Office', () => {
scenario('Open the browser and connect to the Back Office', client => {
test('should open the browser', () => client.open());
test('should login successfully in the Back Office', () => client.signInBO(AccessPageBO));
}, 'order');

commonOrder.checkOrderInBO();

scenario('Logout from the Back Office', client => {
test('should logout successfully from the Back Office', () => client.signOutBO());
}, 'order');
}, 'order', true);
27 changes: 26 additions & 1 deletion tests/E2E/test/campaigns/install_upgrade/02_autoupgrade.js
Expand Up @@ -53,6 +53,18 @@ scenario('The shop installation', () => {
});
}, 'installation');

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

scenario('Install "Top-sellers block" and "New products block" modules From Cross selling', client => {
moduleCommonScenarios.installModule(client, ModulePage, AddProductPage, "ps_bestsellers");
moduleCommonScenarios.installModule(client, ModulePage, AddProductPage, "ps_newproducts");
}, 'installation');

/****** END *****/

scenario('Install " 1-Click Upgrade " From Cross selling and configure it', client => {
moduleCommonScenarios.installModule(client, ModulePage, AddProductPage, "autoupgrade");
test('should click on "configure" button', () => client.waitForExistAndClick(ModulePage.configure_module_button.split('%moduleTechName').join("autoupgrade")));
Expand Down Expand Up @@ -101,7 +113,20 @@ scenario('The shop installation', () => {
test('should login successfully in the Front Office', () => client.signInFO(AccessPageFO, UrlLastStableVersion));
}, 'installation');

orderCommonScenarios.createOrderFO();
/**
* This scenario is based on the bug described in this ticket
* http://forge.prestashop.com/browse/BOOM-3195
**/

scenario('Check the existence of "Top sellers block" and "New products block"', client => {
test('should set the language of shop to "English"', () => client.changeLanguage());
test('should check the existence of "Top sellers" block', () => client.waitForVisible(AccessPageFO.top_sellers_block));
test('should check the existence of "New products" block', () => client.waitForVisible(AccessPageFO.new_products_block));
}, 'installation');

/****** END *****/

orderCommonScenarios.createOrderFO("connected");

scenario('Logout from the back office', client => {
test('should logout successfully from the Front Office', () => client.signOutFO(AccessPageFO));
Expand Down
2 changes: 1 addition & 1 deletion tests/E2E/test/campaigns/install_upgrade/03_rollback.js
Expand Up @@ -59,7 +59,7 @@ scenario('The shop installation', () => {
test('should login successfully in the Front Office', () => client.signInFO(AccessPageFO, UrlLastStableVersion));
}, 'installation');

orderCommonScenarios.createOrderFO();
orderCommonScenarios.createOrderFO("connected");

scenario('Logout from the back office', client => {
test('should logout successfully from the Front Office', () => client.signOutFO(AccessPageFO));
Expand Down
6 changes: 3 additions & 3 deletions tests/E2E/test/clients/common_client.js
Expand Up @@ -101,8 +101,8 @@ class CommonClient {

changeLanguage(language = 'en') {
return this.client
.waitForExistAndClick(languageFO.language_selector)
.pause(1000)
.waitForExistAndClick(languageFO.language_selector, 2000)
.pause(2000)
.isVisible(languageFO.language_option.replace('%LANG', language))
.then((isVisible) => {
expect(isVisible, "This language is not existing").to.be.true;
Expand Down Expand Up @@ -536,7 +536,7 @@ class CommonClient {
}

middleClick(selector, globalVisibility = true, pause = 2000) {
if(visibility){
if(globalVisibility){
return this.client
.moveToObject(selector)
.pause(pause)
Expand Down
2 changes: 1 addition & 1 deletion tests/E2E/test/selectors/FO/index.js
@@ -1,7 +1,7 @@
module.exports = Object.assign({
languageFO: {
language_selector: '//*[@id="_desktop_language_selector"]/div/div/button',
language_option: '//*[@id="_desktop_language_selector"]//a[contains(@href, "/%LANG/")]',
language_option: '//*[@id="_desktop_language_selector"]//a[contains(@href, "%LANG")]',
selected_language_button: '//*[@id="_desktop_language_selector"]//span[@class="expand-more"]'
}
},
Expand Down
18 changes: 18 additions & 0 deletions tests/E2E/test/selectors/FO/order_page.js
Expand Up @@ -36,6 +36,24 @@ module.exports = {
product_name: '//*[@id="main"]//li[%NUMBER]//div[@class="product-line-info"]/a',
product_unit_price: '//*[@id="main"]//li[%NUMBER]//div[@class="current-price"]/span',
arrow_button_up: '//*[@id="main"]//li[%NUMBER]//button[contains(@class, "touchspin-up")]',
add_new_address: '//*[@id="checkout-addresses-step"]//p[contains(@class,"add-address")]',
company_input: '//*[@id="delivery-address"]//input[@name="company"]',
vat_number_input: '//*[@id="delivery-address"]//input[@name="vat_number"]',
address_input: '//*[@id="delivery-address"]//input[@name="address1"]',
address_second_input: '//*[@id="delivery-address"]//input[@name="address2"]',
zip_code_input: '//*[@id="delivery-address"]//input[@name="postcode"]',
city_input: '//*[@id="delivery-address"]//input[@name="city"]',
country_input: '//*[@id="delivery-address"]//select[@name="id_country"]',
phone_input: '//*[@id="delivery-address"]//input[@name="phone"]',
invoice_company_input: '//*[@id="invoice-address"]//input[@name="company"]',
invoice_vat_number_input: '//*[@id="invoice-address"]//input[@name="vat_number"]',
invoice_address_input: '//*[@id="invoice-address"]//input[@name="address1"]',
invoice_address_second_input: '//*[@id="invoice-address"]//input[@name="address2"]',
invoice_zip_code_input: '//*[@id="invoice-address"]//input[@name="postcode"]',
invoice_city_input: '//*[@id="invoice-address"]//input[@name="city"]',
invoice_country_input: '//*[@id="invoice-address"]//select[@name="id_country"]',
invoice_phone_input: '//*[@id="invoice-address"]//input[@name="phone"]',
use_address_for_facturation_input: '//*[@id="use_same_address"]',
product_current_price: '//*[@class="current-price"]/span[@itemprop="price"]',
display_after_carrier_link_widget: '//*[@id="hook-display-after-carrier"]//p[contains(text(),"%NAME")]',
display_after_carrier_second_link_widget: '//*[@id="hook-display-after-carrier"]//div[2]/p',
Expand Down
5 changes: 2 additions & 3 deletions tests/E2E/test/selectors/FO/product_page.js
Expand Up @@ -22,7 +22,6 @@ module.exports = {
current_page: '//*[@id="js-product-list"]//ul[contains(@class, "page-list")]/li[@class="current"]/a',
product_discount_details: '//*[@id="main"]//span[contains(@class, "discount")]',
quick_view_add_to_cart: '//*[@id="add-to-cart-or-refresh"]//button[contains(@data-button-action, "add-to-cart")]',
//Get the number of products in front office after clicking on "SEE ALL PRODUCTS" link
products_number: '//*[@id="js-product-list-top"]//p',
offline_warning_message: '//div[contains(@class, "alert-warning")]//p',
product_discounts_table: '//*[@id="add-to-cart-or-refresh"]//tbody/tr[%R]/td[%D]',
Expand All @@ -34,7 +33,6 @@ module.exports = {
product_detail_tab: '//*[@role="tablist"]//li[2]',
attachments_tab: '//*[@id="main"]//div[@class="product-information"]//a[@aria-controls="attachments"]',
product_footer_linkwidget:'//*[@id="main"]/div[2]//p[contains(text(),"%DISPLAYFOOTERPRODUCT")]',
filename_link: '(//*[@id="attachments"]//a)[1]',
second_product_footer_linkwidget:'//*[@id="main"]/div[2]/div/div[2]/p',
widget_after_product_thumbs: '//*[@id="content"]//div[contains(@class,"links")]//p[contains(text(),"%NAME")]',
second_widget_after_product_thumbs:'//*[@id="content"]//div[contains(@class,"links")]//div[2]/p',
Expand All @@ -45,6 +43,7 @@ module.exports = {
product_section: '//*[@id="main"]/div[1]/div[%I]',
category_page: '//*[@id="category"]',
left_column_block: '//*[@id="left-column"]',
pagination_block: '//*[@id="js-product-list"]/nav'
pagination_block: '//*[@id="js-product-list"]/nav',
filename_link: '(//*[@id="attachments"]//a)[1]'
}
};