Skip to content

Commit

Permalink
Merge pull request #15630 from boubkerbribri/commonTestLogin
Browse files Browse the repository at this point in the history
Moving login test in a commonTests directory
  • Loading branch information
SimonGrn committed Sep 20, 2019
2 parents 6a27619 + 2e1272d commit 76ba692
Show file tree
Hide file tree
Showing 16 changed files with 558 additions and 567 deletions.
1 change: 1 addition & 0 deletions tests/puppeteer/.eslintrc.js
Expand Up @@ -17,6 +17,7 @@ module.exports = {
},
rules: {
'no-plusplus': [2, { allowForLoopAfterthoughts: true }],
"func-names": "off",
'max-len': [2, {code: 120}]
},
};
13 changes: 13 additions & 0 deletions tests/puppeteer/campaigns/commonTests/loginBO.js
@@ -0,0 +1,13 @@
const {expect} = require('chai');

module.exports = {
loginBO() {
it('should login in BO', async function () {
await this.pageObjects.loginPage.goTo(global.URL_BO);
await this.pageObjects.loginPage.login(global.EMAIL, global.PASSWD);
const pageTitle = await this.pageObjects.dashboardPage.getPageTitle();
await expect(pageTitle).to.contains(this.pageObjects.dashboardPage.pageTitle);
await this.pageObjects.boBasePage.closeOnboardingModal();
});
},
};
79 changes: 43 additions & 36 deletions tests/puppeteer/campaigns/sanity/01_installShop/01_installShop.js
Expand Up @@ -4,63 +4,70 @@ const InstallPage = require('../../../pages/Install/install');

let browser;
let page;
let installPage;

// Init objects needed
const init = async function () {
installPage = await (new InstallPage(page));
return {
installPage: new InstallPage(page),
};
};

describe('Install Prestashop', async () => {
// before and after functions
before(async () => {
before(async function () {
browser = await helper.createBrowser();
page = await browser.newPage();
await init();
page = await helper.newTab(browser);
this.pageObjects = await init();
});
after(async () => {
await browser.close();
await helper.closeBrowser(browser);
});
// Steps
it('should open the Install page', async () => {
await installPage.goTo(global.URL_INSTALL);
await installPage.checkStepTitle(installPage.firstStepPageTitle, installPage.firstStepFrTitle);
it('should open the Install page', async function () {
await this.pageObjects.installPage.goTo(global.URL_INSTALL);
await this.pageObjects.installPage.checkStepTitle(this.pageObjects.installPage.firstStepPageTitle,
this.pageObjects.installPage.firstStepFrTitle);
});
it('should change language to English and check title', async () => {
await installPage.setInstallLanguage();
await installPage.checkStepTitle(installPage.firstStepPageTitle, installPage.firstStepEnTitle);
it('should change language to English and check title', async function () {
await this.pageObjects.installPage.setInstallLanguage();
await this.pageObjects.installPage.checkStepTitle(this.pageObjects.installPage.firstStepPageTitle,
this.pageObjects.installPage.firstStepEnTitle);
});
it('should click on next and go to step \'License Agreements\'', async () => {
await installPage.nextStep();
await installPage.checkStepTitle(installPage.secondStepPageTitle, installPage.secondStepEnTitle);
it('should click on next and go to step \'License Agreements\'', async function () {
await this.pageObjects.installPage.nextStep();
await this.pageObjects.installPage.checkStepTitle(this.pageObjects.installPage.secondStepPageTitle,
this.pageObjects.installPage.secondStepEnTitle);
});
it('should agree to terms and conditions and go to step \'System compatibility\'', async () => {
await installPage.agreeToTermsAndConditions();
await installPage.nextStep();
if (!installPage.elementVisible(installPage.thirdStepFinishedListItem)) {
await installPage.checkStepTitle(installPage.thirdStepPageTitle, installPage.thirdStepEnTitle);
it('should agree to terms and conditions and go to step \'System compatibility\'', async function () {
await this.pageObjects.installPage.agreeToTermsAndConditions();
await this.pageObjects.installPage.nextStep();
if (!this.pageObjects.installPage.elementVisible(this.pageObjects.installPage.thirdStepFinishedListItem)) {
await this.pageObjects.installPage.checkStepTitle(this.pageObjects.installPage.thirdStepPageTitle,
this.pageObjects.installPage.thirdStepEnTitle);
}
});
it('should click on next and go to step \'shop Information\'', async () => {
if (!installPage.elementVisible(installPage.thirdStepFinishedListItem)) {
await installPage.nextStep();
it('should click on next and go to step \'shop Information\'', async function () {
if (!this.pageObjects.installPage.elementVisible(this.pageObjects.installPage.thirdStepFinishedListItem)) {
await this.pageObjects.installPage.nextStep();
}
await installPage.checkStepTitle(installPage.fourthStepPageTitle, installPage.fourthStepEnTitle);
await this.pageObjects.installPage.checkStepTitle(this.pageObjects.installPage.fourthStepPageTitle,
this.pageObjects.installPage.fourthStepEnTitle);
});
it('should fill shop Information form and go to step \'Database Configuration\'', async () => {
await installPage.fillInformationForm();
await installPage.nextStep();
await installPage.checkStepTitle(installPage.fifthStepPageTitle, installPage.fifthStepEnTitle);
it('should fill shop Information form and go to step \'Database Configuration\'', async function () {
await this.pageObjects.installPage.fillInformationForm();
await this.pageObjects.installPage.nextStep();
await this.pageObjects.installPage.checkStepTitle(this.pageObjects.installPage.fifthStepPageTitle,
this.pageObjects.installPage.fifthStepEnTitle);
});
it('should fill database configuration form and check database connection', async () => {
await installPage.fillDatabaseForm();
await installPage.checkDatabaseConnected();
it('should fill database configuration form and check database connection', async function () {
await this.pageObjects.installPage.fillDatabaseForm();
await this.pageObjects.installPage.checkDatabaseConnected();
});
it('should finish installation and check that installation is successful', async () => {
await installPage.nextStep();
await installPage.checkInstallationSuccessful();
it('should finish installation and check that installation is successful', async function () {
await this.pageObjects.installPage.nextStep();
await this.pageObjects.installPage.checkInstallationSuccessful();
});
it('should go to FO and check that Prestashop logo exists', async () => {
await installPage.goAndCheckFOAfterInstall();
it('should go to FO and check that Prestashop logo exists', async function () {
await this.pageObjects.installPage.goAndCheckFOAfterInstall();
});
});
86 changes: 41 additions & 45 deletions tests/puppeteer/campaigns/sanity/02_productsBO/01_filterProducts.js
@@ -1,6 +1,7 @@
// Using chai
const {expect} = require('chai');
const helper = require('../../utils/helpers');
const loginCommon = require('../../commonTests/loginBO');

// importing pages
const LoginPage = require('../../../pages/BO/login');
Expand All @@ -10,78 +11,73 @@ const ProductsPage = require('../../../pages/BO/products');

let browser;
let page;
let loginPage;
let dashboardPage;
let boBasePage;
let productsPage;
let numberOfProducts = 0;

// creating pages objects in a function
const init = async function () {
loginPage = await (new LoginPage(page));
dashboardPage = await (new DashboardPage(page));
boBasePage = await (new BOBasePage(page));
productsPage = await (new ProductsPage(page));
return {
loginPage: new LoginPage(page),
dashboardPage: new DashboardPage(page),
boBasePage: new BOBasePage(page),
productsPage: new ProductsPage(page),
};
};

// Test of filters in products page
describe('Filter in Products Page', async () => {
// before and after functions
before(async () => {
before(async function () {
browser = await helper.createBrowser();
page = await browser.newPage();
await init();
page = await helper.newTab(browser);
this.pageObjects = await init();
});
after(async () => {
await browser.close();
await helper.closeBrowser(browser);
});
// Steps
it('should login 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);
await boBasePage.closeOnboardingModal();
loginCommon.loginBO();
it('should go to Products page', async function () {
await this.pageObjects.boBasePage.goToSubMenu(this.pageObjects.boBasePage.productsParentLink,
this.pageObjects.boBasePage.productsLink);
const pageTitle = await this.pageObjects.productsPage.getPageTitle();
await expect(pageTitle).to.contains(this.pageObjects.productsPage.pageTitle);
});
it('should go to Products page', async () => {
await boBasePage.goToSubMenu(boBasePage.productsParentLink, boBasePage.productsLink);
const pageTitle = await productsPage.getPageTitle();
await expect(pageTitle).to.contains(productsPage.pageTitle);
});
it('should reset all filters and get Number of products in BO', async () => {
if (await productsPage.elementVisible(productsPage.filterResetButton, 2000)) await productsPage.resetFilter();
await productsPage.resetFilterCategory();
numberOfProducts = await productsPage.getNumberOfProductsFromList();
it('should reset all filters and get Number of products in BO', async function () {
if (await this.pageObjects.productsPage.elementVisible(this.pageObjects.productsPage.filterResetButton, 2000)) {
await this.pageObjects.productsPage.resetFilter();
}
await this.pageObjects.productsPage.resetFilterCategory();
numberOfProducts = await this.pageObjects.productsPage.getNumberOfProductsFromList();
await expect(numberOfProducts).to.be.above(0);
});
it('should filter list by Name and check result', async () => {
await productsPage.filterProducts('name', 'Customizable mug');
const numberOfProductsAfterFilter = await productsPage.getNumberOfProductsFromList();
it('should filter list by Name and check result', async function () {
await this.pageObjects.productsPage.filterProducts('name', 'Customizable mug');
const numberOfProductsAfterFilter = await this.pageObjects.productsPage.getNumberOfProductsFromList();
await expect(numberOfProductsAfterFilter).to.be.below(numberOfProducts);
});
it('should reset filter and check result', async () => {
await productsPage.resetFilter();
const numberOfProductsAfterReset = await productsPage.getNumberOfProductsFromList();
it('should reset filter and check result', async function () {
await this.pageObjects.productsPage.resetFilter();
const numberOfProductsAfterReset = await this.pageObjects.productsPage.getNumberOfProductsFromList();
await expect(numberOfProductsAfterReset).to.equal(numberOfProducts);
});
it('should filter by Reference and check result', async () => {
await productsPage.filterProducts('reference', 'demo_1');
const numberOfProductsAfterFilter = await productsPage.getNumberOfProductsFromList();
it('should filter by Reference and check result', async function () {
await this.pageObjects.productsPage.filterProducts('reference', 'demo_1');
const numberOfProductsAfterFilter = await this.pageObjects.productsPage.getNumberOfProductsFromList();
await expect(numberOfProductsAfterFilter).to.be.below(numberOfProducts);
});
it('should reset filter and check result', async () => {
await productsPage.resetFilter();
const numberOfProductsAfterReset = await productsPage.getNumberOfProductsFromList();
it('should reset filter and check result', async function () {
await this.pageObjects.productsPage.resetFilter();
const numberOfProductsAfterReset = await this.pageObjects.productsPage.getNumberOfProductsFromList();
await expect(numberOfProductsAfterReset).to.equal(numberOfProducts);
});
it('should filter by Category and check result', async () => {
await productsPage.filterProductsByCategory('Men');
const numberOfProductsAfterFilter = await productsPage.getNumberOfProductsFromList();
it('should filter by Category and check result', async function () {
await this.pageObjects.productsPage.filterProductsByCategory('Men');
const numberOfProductsAfterFilter = await this.pageObjects.productsPage.getNumberOfProductsFromList();
await expect(numberOfProductsAfterFilter).to.be.below(numberOfProducts);
});
it('should reset filter Category and check result', async () => {
await productsPage.resetFilterCategory();
const numberOfProductsAfterReset = await productsPage.getNumberOfProductsFromList();
it('should reset filter Category and check result', async function () {
await this.pageObjects.productsPage.resetFilterCategory();
const numberOfProductsAfterReset = await this.pageObjects.productsPage.getNumberOfProductsFromList();
await expect(numberOfProductsAfterReset).to.equal(numberOfProducts);
});
});

0 comments on commit 76ba692

Please sign in to comment.