Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15156 from boubkerbribri/upgradeTest
Adding new Test UpgradeShop with puppeteer
- Loading branch information
Showing
9 changed files
with
365 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
// Using chai | ||
const {expect} = require('chai'); | ||
// importing pages | ||
const LoginPage = require('../../pages/BO/login'); | ||
const DashboardPage = require('../../pages/BO/dashboard'); | ||
const BOBasePage = require('../../pages/BO/BObasePage'); | ||
const ModuleCatalogPage = require('../../pages/BO/moduleCatalog'); | ||
const ModuleManagerPage = require('../../pages/BO/moduleManager'); | ||
const ShopParamsGeneralPage = require('../../pages/BO/shopParamsGeneral'); | ||
const ShopParamsMaintenancePage = require('../../pages/BO/shopParamsMaintenance'); | ||
const AutoUpgradePage = require('../../pages/BO/modulesPages/autoUpgrade'); | ||
const HomePage = require('../../pages/FO/home'); | ||
|
||
let page; | ||
let loginPage; | ||
let dashboardPage; | ||
let bOBasePage; | ||
let moduleCatalogPage; | ||
let moduleManagerPage; | ||
let shopParamsGeneralPage; | ||
let shopParamsMaintenancePage; | ||
let autoUpgradePage; | ||
let homePage; | ||
|
||
|
||
// creating pages objects in a function | ||
const init = async () => { | ||
page = await global.browser.newPage(); | ||
loginPage = await (new LoginPage(page)); | ||
dashboardPage = await (new DashboardPage(page)); | ||
bOBasePage = await (new BOBasePage(page)); | ||
moduleCatalogPage = await (new ModuleCatalogPage(page)); | ||
moduleManagerPage = await (new ModuleManagerPage(page)); | ||
shopParamsGeneralPage = await (new ShopParamsGeneralPage(page)); | ||
shopParamsMaintenancePage = await (new ShopParamsMaintenancePage(page)); | ||
autoUpgradePage = await (new AutoUpgradePage(page)); | ||
homePage = await (new HomePage(page)); | ||
}; | ||
|
||
// Upgrade shop from a version to the last stable one | ||
global.scenario('Upgrade Prestashop to last Stable', async () => { | ||
test('should login into BO', async () => { | ||
await loginPage.goTo(global.URL_BO); | ||
await loginPage.login(global.EMAIL, global.PASSWD); | ||
const pageTitle = await dashboardPage.getPageTitle(); | ||
await expect(pageTitle).to.contains(dashboardPage.pageTitle); | ||
await bOBasePage.closeOnboardingModal(); | ||
}); | ||
|
||
test('should go the Module Catalog page', async () => { | ||
await bOBasePage.goToSubMenu(bOBasePage.modulesParentLink, bOBasePage.moduleCatalogueLink); | ||
const pageTitle = await moduleCatalogPage.getPageTitle(); | ||
await expect(pageTitle).to.contains(moduleCatalogPage.pageTitle); | ||
}); | ||
|
||
test('should Install module \'1-Click Upgrade\'', async () => { | ||
await moduleCatalogPage.searchModule('autoupgrade', '1-Click Upgrade'); | ||
const installResultMessage = await moduleCatalogPage.installModule('1-Click Upgrade'); | ||
await expect(installResultMessage) | ||
.to.equal(moduleCatalogPage.installMessageSuccessful.replace('%MODULETAG', 'autoupgrade')); | ||
}); | ||
|
||
test('should disable Shop', async () => { | ||
await bOBasePage.goToSubMenu(bOBasePage.shopParametersParentLink, bOBasePage.shopParametersGeneralLink); | ||
let pageTitle = await shopParamsGeneralPage.getPageTitle(); | ||
await expect(pageTitle).to.contains(shopParamsGeneralPage.pageTitle); | ||
await shopParamsGeneralPage.goToSubTabMaintenance(); | ||
pageTitle = await shopParamsMaintenancePage.getPageTitle(); | ||
await expect(pageTitle).to.contains(shopParamsMaintenancePage.pageTitle); | ||
await shopParamsMaintenancePage.changeShopStatus(false); | ||
}); | ||
|
||
test('should Go to configuration module Page', async () => { | ||
await bOBasePage.goToSubMenu(bOBasePage.modulesParentLink, bOBasePage.moduleManagerLink); | ||
let pageTitle = await moduleManagerPage.getPageTitle(); | ||
await expect(pageTitle).to.contains(moduleManagerPage.pageTitle); | ||
await moduleManagerPage.searchModule('autoupgrade', '1-Click Upgrade'); | ||
await moduleManagerPage.goToConfigurationPage('1-Click Upgrade'); | ||
pageTitle = await autoUpgradePage.getPageTitle(); | ||
await expect(pageTitle).to.contains(autoUpgradePage.pageTitle); | ||
}); | ||
|
||
test('should upgrade Prestashop', async () => { | ||
await autoUpgradePage.upgradePrestashop('major'); | ||
}); | ||
|
||
test('should reload and check that user was automatically logged out', async () => { | ||
await bOBasePage.reloadPage(); | ||
const pageTitle = await loginPage.getPageTitle(); | ||
await expect(pageTitle).to.contains(loginPage.pageTitle); | ||
}); | ||
|
||
test('should login and verify version in BO', async () => { | ||
await loginPage.goTo(global.URL_BO); | ||
await loginPage.login(global.EMAIL, global.PASSWD); | ||
const pageTitle = await dashboardPage.getPageTitle(); | ||
await expect(pageTitle).to.contains(dashboardPage.pageTitle); | ||
const version = await bOBasePage.getTextContent(bOBasePage.shopVersionBloc); | ||
expect(version).to.be.equal('1.7.6.0'); | ||
}); | ||
|
||
test('should enable Shop', async () => { | ||
await bOBasePage.goToSubMenu(bOBasePage.shopParametersParentLink, bOBasePage.shopParametersGeneralLink); | ||
let pageTitle = await shopParamsGeneralPage.getPageTitle(); | ||
await expect(pageTitle).to.contains(shopParamsGeneralPage.pageTitle); | ||
await shopParamsGeneralPage.goToSubTabMaintenance(); | ||
pageTitle = await shopParamsMaintenancePage.getPageTitle(); | ||
await expect(pageTitle).to.contains(shopParamsMaintenancePage.pageTitle); | ||
await shopParamsMaintenancePage.changeShopStatus(true); | ||
}); | ||
|
||
test('should verify FO', async () => { | ||
page = await bOBasePage.viewMyShop(); | ||
await page.waitForSelector(homePage.userInfoLink, {visible: true}); | ||
await page.waitForSelector(homePage.contactLink, {visible: true}); | ||
}); | ||
}, init, true); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
const BOBasePage = require('../../pages/BO/BObasePage'); | ||
|
||
module.exports = class moduleCatalog extends BOBasePage { | ||
constructor(page) { | ||
super(page); | ||
|
||
this.pageTitle = 'Module Catalog •'; | ||
this.installMessageSuccessful = 'Install action on module %MODULETAG succeeded.'; | ||
|
||
// Selectors | ||
this.searchModuleTagInput = '#search-input-group input.pstaggerAddTagInput'; | ||
this.searchModuleButton = '#module-search-button'; | ||
this.moduleBloc = '#modules-list-container-all div[data-name=\'%MODULENAME\']:not([style])'; | ||
this.installModuleButton = `${this.moduleBloc} form>button.module_action_menu_install`; | ||
this.configureModuleButton = `${this.moduleBloc} div.module-actions>a`; | ||
} | ||
|
||
/* | ||
Methods | ||
*/ | ||
|
||
/** | ||
* Search Module in Page module Catalog | ||
* @param moduleTag, Tag of Module | ||
* @param moduleName, Name of module | ||
* @return {Promise<void>} | ||
*/ | ||
async searchModule(moduleTag, moduleName) { | ||
await this.page.type(this.searchModuleTagInput, moduleTag); | ||
await this.page.click(this.searchModuleButton); | ||
await this.page.waitForSelector(this.moduleBloc.replace('%MODULENAME', moduleName), {visible: true}); | ||
} | ||
|
||
/** | ||
* Install Module and waiting for Successful massage | ||
* @param moduleName, Name of module | ||
* @return {Promise<textContent>} | ||
*/ | ||
async installModule(moduleName) { | ||
await this.page.click(this.installModuleButton.replace('%MODULENAME', moduleName)); | ||
await this.page.waitForSelector(this.growlMessageBloc, {visible: true}); | ||
return this.getTextContent(this.growlMessageBloc); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
const BOBasePage = require('../../pages/BO/BObasePage'); | ||
|
||
module.exports = class moduleManager extends BOBasePage { | ||
constructor(page) { | ||
super(page); | ||
|
||
this.pageTitle = 'Module manager •'; | ||
|
||
// Selectors | ||
this.searchModuleTagInput = '#search-input-group input.pstaggerAddTagInput'; | ||
this.searchModuleButton = '#module-search-button'; | ||
this.moduleBloc = '.module-short-list .module-item-list[data-name=\'%MODULENAME\']'; | ||
this.configureModuleButton = `${this.moduleBloc} div.module-actions>a`; | ||
} | ||
|
||
/* | ||
Methods | ||
*/ | ||
|
||
/** | ||
* Search Module in Page module Catalog | ||
* @param moduleTag, Tag of Module | ||
* @param moduleName, Name of module | ||
* @return {Promise<void>} | ||
*/ | ||
async searchModule(moduleTag, moduleName) { | ||
await this.page.type(this.searchModuleTagInput, moduleTag); | ||
await this.page.click(this.searchModuleButton); | ||
await this.page.waitForSelector(this.moduleBloc.replace('%MODULENAME', moduleName), {visible: true}); | ||
} | ||
|
||
/** | ||
* Click on button configure of a module | ||
* @param moduleName, Name of module | ||
* @return {Promise<void>} | ||
*/ | ||
async goToConfigurationPage(moduleName) { | ||
await this.page.click(this.configureModuleButton.replace('%MODULENAME', moduleName)); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
const BOBasePage = require('../../BO/BObasePage'); | ||
|
||
module.exports = class autoUpgrade extends BOBasePage { | ||
constructor(page) { | ||
super(page); | ||
|
||
this.pageTitle = '1-Click Upgrade > 1-Click Upgrade •'; | ||
this.expectedStepsDoneForUpgradeTable = [ | ||
'backupFiles', | ||
'backupDb', | ||
'upgradeFiles', | ||
'upgradeDb', | ||
'upgradeModules', | ||
'upgradeComplete', | ||
]; | ||
this.actualStepsDoneForUpgradeTable = []; | ||
|
||
// Selectors | ||
this.showExpertModeButton = 'input[type=\'button\'][value=\'More options (Expert mode)\']'; | ||
this.channelSelect = '#channel'; | ||
this.updateChannelSaveButton = '#advanced input[type=\'button\'][value=\'Save\']'; | ||
this.upgradePrestashopNowButton = '#upgradeNow'; | ||
this.upgradeResultMessageBloc = '#upgradeResultCheck>p'; | ||
} | ||
|
||
/* | ||
Methods | ||
*/ | ||
|
||
/** | ||
* Select the channel from where to do the upgrade | ||
* @param upgradeChannelValue, value to select | ||
* @return {Promise<void>} | ||
*/ | ||
async chooseUpgradeChannel(upgradeChannelValue) { | ||
if (await this.elementVisible(this.showExpertModeButton)) { | ||
await this.page.click(this.showExpertModeButton); | ||
} | ||
await this.page.waitForSelector(this.channelSelect, {visible: true}); | ||
await this.page.select(this.channelSelect, upgradeChannelValue); | ||
await this.page.click(this.updateChannelSaveButton); | ||
await this.page.waitForNavigation({waitUntil: 'networkidle0'}); | ||
} | ||
|
||
/** | ||
* Select the channel from where to do the upgrade, | ||
* Upgrade Prestashop | ||
* And check successful message and that all steps are passed | ||
* @param upgradeChannelValue, value to select | ||
* @return {Promise<void>} | ||
*/ | ||
async upgradePrestashop(upgradeChannelValue) { | ||
await this.chooseUpgradeChannel(upgradeChannelValue); | ||
await this.page.waitForSelector(this.upgradePrestashopNowButton, {visible: true}); | ||
this.page.on('response', async (response) => { | ||
if (await response.url().endsWith('ajax-upgradetab.php') && await response.status() === 200) { | ||
const jsonResponse = await response.json(); | ||
await this.actualStepsDoneForUpgradeTable.push(jsonResponse.next); | ||
} | ||
}); | ||
await this.page.click(this.upgradePrestashopNowButton); | ||
await this.page.waitForSelector(this.upgradeResultMessageBloc, {visible: true, timeout: 300000}); | ||
await global.expect(this.actualStepsDoneForUpgradeTable).to.include.members(this.expectedStepsDoneForUpgradeTable); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
const BOBasePage = require('../../pages/BO/BObasePage'); | ||
|
||
module.exports = class shopParamsGeneral extends BOBasePage { | ||
constructor(page) { | ||
super(page); | ||
|
||
this.pageTitle = 'Preferences •'; | ||
|
||
// Selectors | ||
this.maintenanceNavItemLink = '#subtab-AdminMaintenance'; | ||
} | ||
|
||
/* | ||
Methods | ||
*/ | ||
|
||
/** | ||
* Change Tab to Maintenance in Shop Parameters General Page | ||
* @return {Promise<void>} | ||
*/ | ||
async goToSubTabMaintenance() { | ||
await this.page.click(this.maintenanceNavItemLink, {waitUntil: 'networkidle2'}); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
const BOBasePage = require('../../pages/BO/BObasePage'); | ||
|
||
module.exports = class shopParamsMaintenance extends BOBasePage { | ||
constructor(page) { | ||
super(page); | ||
|
||
this.pageTitle = 'Maintenance •'; | ||
|
||
// Selectors | ||
this.generalNavItemLink = '#subtab-AdminPreferences'; | ||
this.disableShopLabel = 'label[for=\'form_general_enable_shop_0\']'; | ||
this.enableShopLabel = 'label[for=\'form_general_enable_shop_1\']'; | ||
this.saveFormButton = 'form .card-footer button'; | ||
} | ||
|
||
/* | ||
Methods | ||
*/ | ||
|
||
/** | ||
* Change Tab to General in Shop Parameters Maintenance Page | ||
* @return {Promise<void>} | ||
*/ | ||
async goToSubTabGeneral() { | ||
await this.page.click(this.generalNavItemLink, {waitUntil: 'networkidle2'}); | ||
} | ||
|
||
/** | ||
* Enable / disable shop | ||
* @param toEnable, true to enable and false to disable | ||
* @return {Promise<void>} | ||
*/ | ||
async changeShopStatus(toEnable = true) { | ||
if (toEnable) await this.page.click(this.enableShopLabel); | ||
else await this.page.click(this.disableShopLabel); | ||
await this.page.click(this.saveFormButton); | ||
await this.page.waitForSelector(this.alertSuccessBloc); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.