Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions test/campaigns/googleAnalytics/GoogleAnalytics.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
scenario('Test google analytics', client => {
scenario('Log in in Back Office', client => {
test('should open the browser', () => client.open());
test('should log in successfully in BO', () => client.signInBO());
}, "google-analytics/googleAnalytics-client");
scenario('Configure google analytics account', () => {
test('should go to the installed module page', () => client.goToModulePage());
test('should search the "ps_googleanalytics" module page', () => client.searchModule('ps_googleanalytics'));
test('should go to the module configuration page', () => client.goToModuleConfigurationPage());
test('should click on create account link', () => client.clickOnCreateAccountLink());
test('should log in successfully in google account', () => client.fillGoogleSignInForm());
test('should go to administration setting', () => client.clickOnAdministration());
test('should select the Property Settings', () => client.selectPropertySettings());
test('should check the existance of id ', () => client.checkId());
}, "google-analytics/googleAnalytics-client");
scenario('Configure the module in shop', client => {
test('should back to shop', () => client.backToShop());
test('should enter Google Analytics Tracking ID', () => client.addGoogleTrackingId());
test('should enable the user ID tracking', () => client.enableUserTrackingId());
test('should click on button Save', () => client.clickOnSaveButton());
test('should check the account ID', () => client.checkAccountId());
test('should check the user ID', () => client.checkUserId());
}, "google-analytics/googleAnalytics-client");
scenario('Logout from Back Office', client => {
test('should logout', () => client.signOutBO());
}, "google-analytics/googleAnalytics-client");
}, "google-analytics/googleAnalytics-client", true);
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ scenario('Test mailChimp-integration', client => {
test('should disconnect from list', () => client.disconnectFromList());
test('should select list', () => client.selectList());
}, "mailchimp-integration/mailChimpintegration-client");
scenario('Logout from Back Office', client => {
scenario('Logout from Back Office', client => {
test('should logout', () => client.signOutBO());
}, "mailchimp-integration/mailChimpintegration-client");
}, "mailchimp-integration/mailChimpintegration-client", true);
177 changes: 177 additions & 0 deletions test/clients/google-analytics/googleAnalytics-client.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
const {getClient} = require('../../common.webdriverio.js');
const {selector} = require('../../globals.webdriverio.js');
const {external} = require('../../external_globals.webdriverio.js');

class GoogleAnalytics {
constructor() {
this.client = getClient();
}

signInBO() {
return this.client.signinBO();
}

signOutBO() {
return this.client.signoutBO();
}

close() {
return this.client.end();
}

takeScreenshot() {
return this.client.saveScreenshot(`test/screenshots/${this.client.desiredCapabilities.browserName}_exception_${global.date_time}.png`);
}

open() {
return this.client.init().windowHandleMaximize();
}

goToModulePage() {

return this.client
.waitForExist(selector.BO.ModulesPage.modules_subtab, 90000)
.click(selector.BO.ModulesPage.modules_subtab)
.pause(5000);
}

goToModuleConfigurationPage() {

return this.client
.waitForExist(selector.BO.GoogleAnalyticsPage.config_module_button, 90000)
.click(selector.BO.GoogleAnalyticsPage.config_module_button)
}

fillGoogleSignInForm(login = "prestotests@gmail.com", password = "presto_tests") {

return this.client
.waitForExist(external.FO.GoogleAnalytics.connect_button, 90000)
.click(external.FO.GoogleAnalytics.connect_button)
.waitForExist(external.FO.GoogleAnalytics.google_analytics_choice, 9000)
.click(external.FO.GoogleAnalytics.google_analytics_choice)
.waitForExist(external.FO.Google.username_input, 90000)
.setValue(external.FO.Google.username_input, login)
.waitForExist(external.FO.Google.identifier_next_button, 90000)
.click(external.FO.Google.identifier_next_button)
.pause(5000)
.waitForVisible(external.FO.Google.password_input, 90000)
.setValue(external.FO.Google.password_input, password)
.waitForExist(external.FO.Google.password_next_button, 90000)
.click(external.FO.Google.password_next_button)
.pause(9000)
}

clickOnCreateAccountLink() {

return this.client
.moveToObject(selector.BO.GoogleAnalyticsPage.create_account_link, 9000)
.then(() => this.client.getAttribute(selector.BO.GoogleAnalyticsPage.create_account_link, 'href'))
.then((href) => {
this.client.newWindow(href)
})
.pause(3000)
.waitForVisible(external.FO.GoogleAnalytics.google_analytics_link, 90000)
.click(external.FO.GoogleAnalytics.google_analytics_link)
.then(() => this.client.getTabIds())
.then((ids) => this.client.switchTab(ids[ids.length - 1]))
}

backToShop() {

return this.client
.waitForExist(external.FO.GoogleAnalytics.reset_button, 90000)
.then(() => this.client.getTabIds())
.then((ids) => this.client.switchTab(ids[0]))
.pause(5000);
}

clickOnAdministration() {

return this.client
.waitForExist(external.FO.GoogleAnalytics.administration_button, 90000)
.click(external.FO.GoogleAnalytics.administration_button)
}

selectPropertySettings() {

return this.client
.waitForExist(external.FO.GoogleAnalytics.property_settings_button, 90000)
.click(external.FO.GoogleAnalytics.property_settings_button)
.pause(3000)
}

checkId() {

return this.client
.waitForExist(external.FO.GoogleAnalytics.google_analytics_id, 90000)
.getText(external.FO.GoogleAnalytics.google_analytics_id).then(function (id) {
global.tracking_id = id;
should(global.tracking_id).be.equal("UA-105026510-1");
})
.waitForExist(external.FO.GoogleAnalytics.google_analytics_url_input, 9000)
.setValue(external.FO.GoogleAnalytics.google_analytics_url_input, URL)
.waitForExist(external.FO.GoogleAnalytics.save_button, 3000)
.click(external.FO.GoogleAnalytics.save_button)
.pause(9000)
}

searchModule(moduleName) {

return this.client
.waitForExist(selector.BO.ModulesPage.search_input, 90000)
.setValue(selector.BO.ModulesPage.search_input, moduleName)
.waitForExist(selector.BO.ModulesPage.search_button, 3000)
.click(selector.BO.ModulesPage.search_button)
.pause(3000)
.waitForExist(selector.BO.ModulesPage.page_loaded, 90000)
.then(() => this.client.getText(selector.BO.ModulesPage.page_loaded))
.then((nbr) => {
global.nbr = parseInt(nbr[0].charAt(0))
})
.pause(3000);
}

addGoogleTrackingId() {

return this.client
.waitForExist(selector.BO.GoogleAnalyticsPage.googleanalytics_tracking_id, 90000)
.setValue(selector.BO.GoogleAnalyticsPage.googleanalytics_tracking_id, global.tracking_id)
}

enableUserTrackingId() {

return this.client
.waitForExist(selector.BO.GoogleAnalyticsPage.enable_user_id_tracking, 90000)
.click(selector.BO.GoogleAnalyticsPage.enable_user_id_tracking, 90000)
}

clickOnSaveButton() {

return this.client
.waitForExist(selector.BO.GoogleAnalyticsPage.googleanalytics_submit_btn, 90000)
.click(selector.BO.GoogleAnalyticsPage.googleanalytics_submit_btn, 90000)
}

checkAccountId() {

return this.client
.waitForExist(selector.BO.GoogleAnalyticsPage.account_id_green_block, 90000)
.then(() => this.client.getText(selector.BO.GoogleAnalyticsPage.account_id_green_block))
.then((value) => {
expect(value).to.eql('×\nAccount ID updated successfully')
})
}

checkUserId() {

return this.client
.waitForExist(selector.BO.GoogleAnalyticsPage.user_id_green_block, 90000)
.then(() => this.client.getText(selector.BO.GoogleAnalyticsPage.user_id_green_block))
.then((value) => {
expect(value).to.eql('×\nSettings for User ID updated successfully')
})
}

}

module.exports = GoogleAnalytics;
2 changes: 1 addition & 1 deletion test/common.webdriverio.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function initCommands(client) {
return client
.url('https://' + URL + '/backoffice/')
.waitForExist(this.selector.BO.LoginPage.login_input, 90000)
.setValue(this.selector.BO.LoginPage.login_input, 'remi.gaillard@prestashop.com')
.setValue(this.selector.BO.LoginPage.login_input,'remi.gaillard@prestashop.com')
.setValue(this.selector.BO.LoginPage.password_input, 'abcd1234')
.click(this.selector.BO.LoginPage.login_button)
.waitForExist(this.selector.BO.Common.menu, 90000)
Expand Down
51 changes: 29 additions & 22 deletions test/external_globals.webdriverio.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module.exports = {
username_input: '//*[@id="email"]',
password_input: '//*[@id="pass"]',
signin_button: '//*[@id="loginbutton"]',
app_link : '//*[@id="js_en"]/span',
app_link: '//*[@id="js_en"]/span',
customer_api_key: '//*[@id="u_0_5t"]/div[1]/div/table/tbody/tr[1]/td[1]/div/div',
show_secret_button: '//*[@id="u_0_5u"]/div/button',
customer_api_secret: '//*[@id="u_0_5u"]/div/span',
Expand All @@ -22,23 +22,21 @@ module.exports = {
},
Twitter: {
signein_button: '//*[@id="gaz-content-body"]/div[2]/div/a',
signein_login_input : '//*[@id="page-container"]/div/div[1]/form/fieldset/div[1]/input',
signein_password_input : '//*[@id="page-container"]/div/div[1]/form/fieldset/div[2]/input',
signein_connect_input : '//*[@id="page-container"]/div/div[1]/form/div[2]/button',
signein_login_input: '//*[@id="page-container"]/div/div[1]/form/fieldset/div[1]/input',
signein_password_input: '//*[@id="page-container"]/div/div[1]/form/fieldset/div[2]/input',
signein_connect_input: '//*[@id="page-container"]/div/div[1]/form/div[2]/button',

app_link : '//*[@id="gaz-content-body"]/div[3]/div/ul/li[1]/div/div[2]/h2/a',
settings_tab : '//*[@id="gaz-content-body"]/div[2]/ul/li[2]/a',
key_and_access_tokens_tab : '//*[@id="gaz-content-body"]/div[2]/ul/li[3]/a',
website_url_input : '//*[@id="edit-url"]',
callback_url_input : '//*[@id="edit-callback-url"]',
update_settings_button : '//*[@id="edit-submit"]',
app_link: '//*[@id="gaz-content-body"]/div[3]/div/ul/li[1]/div/div[2]/h2/a',
settings_tab: '//*[@id="gaz-content-body"]/div[2]/ul/li[2]/a',
key_and_access_tokens_tab: '//*[@id="gaz-content-body"]/div[2]/ul/li[3]/a',
website_url_input: '//*[@id="edit-url"]',
callback_url_input: '//*[@id="edit-callback-url"]',
update_settings_button: '//*[@id="edit-submit"]',
customer_api_key: '//*[@id="gaz-content-body"]/div[3]/div/div[2]/div[1]/span[2]',
customer_api_secret: '//*[@id="gaz-content-body"]/div[3]/div/div[2]/div[2]/span[2]'
},
//@TODO
Amazon: {

},
Amazon: {},
Google: {
username_input: '//*[@id="identifierId"]',
identifier_next_button: '//*[@id="identifierNext"]',
Expand Down Expand Up @@ -75,9 +73,7 @@ module.exports = {
save_button: '.small.primary.two.columns'
},
//@TODO
Yahoo: {

},
Yahoo: {},
Paypal: {
username_input: '//*[@id="email"]',
password_input: '//*[@id="password"]',
Expand Down Expand Up @@ -198,12 +194,12 @@ module.exports = {

signin_button: '//*[@id="signup_forms_submit"]/span[6]',
app_link: '//*[@id="dashboard_account_oauth_apps"]/div[4]/div/div/div[2]/a[2]',
website_url_input:'//*[@id="oac_url"]',
callback_url_input:'//*[@id="oac_default_callback_url"]',
save_button:'//*[@id="save_button"]',
customer_key:'//*[@id="dashboard_account_register_oauth_app"]/div[4]/div/div/span[1]',
customer_secret:'//*[@id="secret"]',
show_secret_button:'//*[@id="secret_toggle"]'
website_url_input: '//*[@id="oac_url"]',
callback_url_input: '//*[@id="oac_default_callback_url"]',
save_button: '//*[@id="save_button"]',
customer_key: '//*[@id="dashboard_account_register_oauth_app"]/div[4]/div/div/span[1]',
customer_secret: '//*[@id="secret"]',
show_secret_button: '//*[@id="secret_toggle"]'
},
Vkontakte: {
username_input: '//*[@id="email"]',
Expand All @@ -219,6 +215,17 @@ module.exports = {
delete_base_domain_icon: '//*[@id="apps_edit_domain_cont"]/div/div[1]/div[1]/div/a/div',
domain_input: '//*[@id="apps_edit_domain_cont"]/div/div[1]/div[2]/input',
save_button: '//*[@id="app_save_btn"]'
},
GoogleAnalytics: {
connect_button: '/html/body/header/nav/div/a',
google_analytics_choice: '/html/body/header/nav/div/div/ul/li[1]/a',
property_settings_button: '//*[@id="ID-m-propertyColumn"]/div[2]/div[3]/div[1]/a[1]/div',
administration_button: '//*[@id="bottomSectionAdmin"]/nav/div/div/ga-nav-link/div/a/ng-include/span',
google_analytics_id: '//*[@id="ID-m-content"]/div/div/div/div/div/div[2]/div/ui-view/form/section[1]/div[1]/div[2]',
google_analytics_url_input: '//*[@id="ID-m-content"]/div/div/div/div/div/div[2]/div/ui-view/form/section[1]/div[3]/div[2]/ga-url-selector/input',
save_button: '//*[@id="ID-m-content"]/div/div/div/div/div/div[2]/div/ui-view/form/ga-submit-buttons/div/button[1]',
google_analytics_link: '/html/body/div[2]/div[2]/section/div/article/section/div/ol/li[1]/ul/li[1]/a',
reset_button: '//*[@id="ID-m-content"]/div/div/div/div/div/div[2]/div/ui-view/form/ga-submit-buttons/div/button[2]'
}
}

Expand Down
19 changes: 14 additions & 5 deletions test/globals.webdriverio.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,12 @@ global.selenium_url = argv.SELENIUM;
global._projectdir = path.join(__dirname, '..', '..');
global.product_id = new Date().getTime();
global.new_customer_email = 'pub' + date_time + '@prestashop.com';

global.module_tech_name_mailchimp = 'mailchimpintegration';
global.listNameInput = 'Test_list_MailChimp' + date_time;
module.exports = {
selector: {

BO:{
BO: {
Common: {
menu: '#nav-sidebar',
close_validation_button: '.growl-close',
Expand All @@ -35,8 +34,8 @@ module.exports = {
page_loaded: '.module-search-result-wording',
installed_modules_tabs: '(//div[@class="page-head-tabs"]/a)[2]',
module_number_span: '[class="module-sorting-search-wording"]',
number_of_module_found:'//*[@id="main-div"]/div[3]/div/div/div[2]/div/div[7]/span[1]',
configuration_button:'//*[@id="modules-list-container-all"]/div/div/div/div[5]/div[2]/form/button',
number_of_module_found: '//*[@id="main-div"]/div[3]/div/div/div[2]/div/div[7]/span[1]',
configuration_button: '//*[@id="modules-list-container-all"]/div/div/div/div[5]/div[2]/form/button',
module_menu_button: '[class="btn btn-primary-outline dropdown-toggle"]',
enable_module_button: '[class="dropdown-item module_action_menu_enable"]'
},
Expand Down Expand Up @@ -183,6 +182,16 @@ module.exports = {
phone_input: '//*[@id="conf_id_PS_SHOP_PHONE"]/div/input',
fax_input: '//*[@id="conf_id_PS_SHOP_FAX"]/div/input',
save_button: '//*[@id="store_fieldset_contact"]/div[3]/button',
},

GoogleAnalyticsPage: {
config_module_button: '//*[@id="modules-list-container-native"]/div/div/div/div[5]/div[2]/form/button',
googleanalytics_tracking_id: '//*[@id="GA_ACCOUNT_ID"]',
enable_user_id_tracking: '//*[@id="ga_userid_enabled"]',
googleanalytics_submit_btn: '//*[@id="configuration_form_submit_btn"]',
account_id_green_block: '//*[@id="content"]/div[6]/div[@class="module_confirmation conf confirm alert alert-success"]',
user_id_green_block: '//*[@id="content"]/div[7]/div[@class="module_confirmation conf confirm alert alert-success"]',
create_account_link: '//*[@id="google_analytics_content"]/div/div[2]/p[2]/b/a'
}
},
//FO
Expand Down Expand Up @@ -368,7 +377,7 @@ module.exports = {

}
},
shouldExist: function(err, existing) {
shouldExist: function (err, existing) {
should(err).be.not.defined;
should(existing).be.true;
}
Expand Down