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

Sanity Tests - Refacto of all tests #16018

Merged
merged 10 commits into from Oct 23, 2019
1 change: 1 addition & 0 deletions tests/puppeteer/campaigns/data/FO/cart.js
Expand Up @@ -10,5 +10,6 @@ module.exports = {
quantity: '1',
price: '€34.46',
},
cartTotalTTC: 57.41,
},
};
2 changes: 1 addition & 1 deletion tests/puppeteer/campaigns/data/demo/orders.js
@@ -1,7 +1,7 @@
module.exports = {
Orders: {
firstOrder: {id: '1', ref: 'XKBKNABJK'},
secondOrder: {id: '2', ref: 'XKBKNABJK'},
secondOrder: {id: '2', ref: 'OHSATSERP'},
thirdOrder: {id: '3', ref: 'UOYEVOLI'},
fourthOrder: {id: '4', ref: 'FFATNOMMJ'},
},
Expand Down
Expand Up @@ -87,15 +87,18 @@ describe('Install Prestashop', async () => {
});
it('should fill database configuration form and check database connection', async function () {
await this.pageObjects.installPage.fillDatabaseForm();
await this.pageObjects.installPage.checkDatabaseConnected();
const result = await this.pageObjects.installPage.isDatabaseConnected();
await expect(result).to.be.true;
});
it('should finish installation and check that installation is successful', async function () {
await this.pageObjects.installPage.nextStep();
await this.pageObjects.installPage.checkInstallationSuccessful();
const result = await this.pageObjects.installPage.isInstallationSuccessful();
await expect(result).to.be.true;
});
it('should go to FO and check that Prestashop logo exists', async function () {
page = await this.pageObjects.installPage.goToFOAfterInstall();
this.pageObjects = await init();
await this.pageObjects.homePage.checkHomePage();
const result = await this.pageObjects.homePage.isHomePage();
await expect(result).to.be.true;
});
});
Expand Up @@ -40,8 +40,10 @@ describe('Filter in Products Page', async () => {
// Steps
loginCommon.loginBO();
it('should go to Products page', async function () {
await this.pageObjects.boBasePage.goToSubMenu(this.pageObjects.boBasePage.productsParentLink,
this.pageObjects.boBasePage.productsLink);
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);
});
Expand Down
Expand Up @@ -49,8 +49,10 @@ describe('Create, read, update and delete Standard product in BO', async () => {
// Steps
loginCommon.loginBO();
it('should go to Products page', async function () {
await this.pageObjects.boBasePage.goToSubMenu(this.pageObjects.boBasePage.productsParentLink,
this.pageObjects.boBasePage.productsLink);
await this.pageObjects.boBasePage.goToSubMenu(
this.pageObjects.boBasePage.productsParentLink,
this.pageObjects.boBasePage.productsLink,
);
await this.pageObjects.boBasePage.closeSfToolBar();
const pageTitle = await this.pageObjects.productsPage.getPageTitle();
await expect(pageTitle).to.contains(this.pageObjects.productsPage.pageTitle);
Expand All @@ -72,14 +74,15 @@ describe('Create, read, update and delete Standard product in BO', async () => {
page = await this.pageObjects.addProductPage.previewProduct();
this.pageObjects = await init();
const result = await this.pageObjects.foProductPage.checkProduct(productData);
page = await this.pageObjects.foProductPage.closePage(browser, 1);
this.pageObjects = await init();
// Check that all Product attribute are correct
await Promise.all([
expect(result.name).to.be.true,
expect(result.price).to.be.true,
expect(result.quantity_wanted).to.be.true,
expect(result.description).to.be.true,
]);
page = await this.pageObjects.foProductPage.closePage(browser, 1);
this.pageObjects = await init();
});
it('should edit Product', async function () {
const createProductMessage = await this.pageObjects.addProductPage.createEditProduct(editedProductData, false);
Expand All @@ -89,14 +92,15 @@ describe('Create, read, update and delete Standard product in BO', async () => {
page = await this.pageObjects.addProductPage.previewProduct();
this.pageObjects = await init();
const result = await this.pageObjects.foProductPage.checkProduct(editedProductData);
page = await this.pageObjects.foProductPage.closePage(browser, 1);
this.pageObjects = await init();
// Check that all Product attribute are correct
await Promise.all([
expect(result.name).to.be.true,
expect(result.price).to.be.true,
expect(result.quantity_wanted).to.be.true,
expect(result.description).to.be.true,
]);
page = await this.pageObjects.foProductPage.closePage(browser, 1);
this.pageObjects = await init();
});
it('should delete Product and be on product list page', async function () {
const testResult = await this.pageObjects.addProductPage.deleteProduct();
Expand Down
Expand Up @@ -49,8 +49,10 @@ describe('Create, read, update and delete Standard product with combinations in
// Steps
loginCommon.loginBO();
it('should go to Products page', async function () {
await this.pageObjects.boBasePage.goToSubMenu(this.pageObjects.boBasePage.productsParentLink,
this.pageObjects.boBasePage.productsLink);
await this.pageObjects.boBasePage.goToSubMenu(
this.pageObjects.boBasePage.productsParentLink,
this.pageObjects.boBasePage.productsLink,
);
await this.pageObjects.boBasePage.closeSfToolBar();
const pageTitle = await this.pageObjects.productsPage.getPageTitle();
await expect(pageTitle).to.contains(this.pageObjects.productsPage.pageTitle);
Expand All @@ -72,14 +74,15 @@ describe('Create, read, update and delete Standard product with combinations in
page = await this.pageObjects.addProductPage.previewProduct();
this.pageObjects = await init();
const result = await this.pageObjects.foProductPage.checkProduct(productWithCombinations);
page = await this.pageObjects.foProductPage.closePage(browser, 1);
this.pageObjects = await init();
// Check that all Product attribute are correct
await Promise.all([
expect(result.name).to.be.true,
expect(result.price).to.be.true,
expect(result.quantity_wanted).to.be.true,
expect(result.description).to.be.true,
]);
page = await this.pageObjects.foProductPage.closePage(browser, 1);
this.pageObjects = await init();
});
it('should edit Product', async function () {
const createProductMessage = await this.pageObjects.addProductPage.createEditProduct(editedProductWithCombinations,
Expand All @@ -90,14 +93,15 @@ describe('Create, read, update and delete Standard product with combinations in
page = await this.pageObjects.addProductPage.previewProduct();
this.pageObjects = await init();
const result = await this.pageObjects.foProductPage.checkProduct(editedProductWithCombinations);
page = await this.pageObjects.foProductPage.closePage(browser, 1);
this.pageObjects = await init();
// Check that all Product attribute are correct
await Promise.all([
expect(result.name).to.be.true,
expect(result.price).to.be.true,
expect(result.quantity_wanted).to.be.true,
expect(result.description).to.be.true,
]);
page = await this.pageObjects.foProductPage.closePage(browser, 1);
this.pageObjects = await init();
});
it('should delete Product and be on product list page', async function () {
const testResult = await this.pageObjects.addProductPage.deleteProduct();
Expand Down
Expand Up @@ -45,8 +45,10 @@ describe('Create Standard product in BO and Delete it with DropDown Menu', async
// Steps
loginCommon.loginBO();
it('should go to Products page', async function () {
await this.pageObjects.boBasePage.goToSubMenu(this.pageObjects.boBasePage.productsParentLink,
this.pageObjects.boBasePage.productsLink);
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);
});
Expand Down
Expand Up @@ -50,8 +50,10 @@ describe('Create Standard product in BO and Delete it with Bulk Actions', async
// Steps
loginCommon.loginBO();
it('should go to Products page', async function () {
await this.pageObjects.boBasePage.goToSubMenu(this.pageObjects.boBasePage.productsParentLink,
this.pageObjects.boBasePage.productsLink);
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);
});
Expand Down
74 changes: 53 additions & 21 deletions tests/puppeteer/campaigns/sanity/03_ordersBO/01_filterOrders.js
Expand Up @@ -8,9 +8,10 @@ const loginCommon = require('@commonTests/loginBO');
const LoginPage = require('@pages/BO/login');
const DashboardPage = require('@pages/BO/dashboard');
const BOBasePage = require('@pages/BO/BObasePage');
const OrderPage = require('@pages/BO/order');
const OrdersPage = require('@pages/BO/orders');
const {Orders, Statuses} = require('@data/demo/orders');

let numberOfOrders;
let browser;
let page;
// creating pages objects in a function
Expand All @@ -19,7 +20,7 @@ const init = async function () {
loginPage: new LoginPage(page),
dashboardPage: new DashboardPage(page),
boBasePage: new BOBasePage(page),
orderPage: new OrderPage(page),
ordersPage: new OrdersPage(page),
};
};

Expand All @@ -43,48 +44,79 @@ describe('Filter the Orders table by ID, REFERENCE, STATUS', async () => {
it('should go to the Orders page', async function () {
await this.pageObjects.boBasePage.goToSubMenu(
this.pageObjects.boBasePage.ordersParentLink,
this.pageObjects.orderPage.ordersLink,
this.pageObjects.boBasePage.ordersLink,
);
const pageTitle = await this.pageObjects.orderPage.getPageTitle();
await expect(pageTitle).to.contains(this.pageObjects.orderPage.pageTitle);
const pageTitle = await this.pageObjects.ordersPage.getPageTitle();
await expect(pageTitle).to.contains(this.pageObjects.ordersPage.pageTitle);
});
it('should reset all filters and get number of orders', async function () {
await this.pageObjects.ordersPage.resetFilter();
numberOfOrders = await parseInt(
await this.pageObjects.ordersPage.getTextContent(this.pageObjects.ordersPage.ordersNumberSpan),
10,
);
await expect(numberOfOrders).to.be.above(0);
});
it('should filter the Orders table by ID and check the result', async function () {
await this.pageObjects.orderPage.filterTableByInput(
this.pageObjects.orderPage.orderFilterIdInput,
await this.pageObjects.ordersPage.filterOrders(
'input',
'id_order',
Orders.firstOrder.id,
this.pageObjects.orderPage.searchButton,
);
const result = await this.pageObjects.boBasePage.checkTextValue(
this.pageObjects.orderPage.orderfirstLineIdTD,
const result = await this.pageObjects.ordersPage.checkTextValue(
this.pageObjects.ordersPage.orderfirstLineIdTD.replace('%ROW', '1'),
Orders.firstOrder.id,
);
await expect(result).to.be.true;
await this.pageObjects.orderPage.waitForSelectorAndClick(this.pageObjects.orderPage.resetButton);
});
it('should reset all filters', async function () {
await this.pageObjects.ordersPage.resetFilter();
const numberOfOrdersAfterReset = await parseInt(
await this.pageObjects.ordersPage.getTextContent(this.pageObjects.ordersPage.ordersNumberSpan),
10,
);
await expect(numberOfOrdersAfterReset).to.be.equal(numberOfOrders);
});
it('should filter the Orders table by REFERENCE and check the result', async function () {
await this.pageObjects.orderPage.filterTableByInput(
this.pageObjects.orderPage.orderFilterReferenceInput,
await this.pageObjects.ordersPage.filterOrders(
'input',
'reference',
Orders.fourthOrder.ref,
this.pageObjects.orderPage.searchButton,
);
const result = await this.pageObjects.boBasePage.checkTextValue(
this.pageObjects.orderPage.orderfirstLineReferenceTD,
this.pageObjects.ordersPage.orderfirstLineReferenceTD.replace('%ROW', '1'),
PierreRambaud marked this conversation as resolved.
Show resolved Hide resolved
Orders.fourthOrder.ref,
);
await expect(result).to.be.true;
await this.pageObjects.orderPage.waitForSelectorAndClick(this.pageObjects.orderPage.resetButton);
});
it('should reset all filters', async function () {
await this.pageObjects.ordersPage.resetFilter();
const numberOfOrdersAfterReset = await parseInt(
await this.pageObjects.ordersPage.getTextContent(this.pageObjects.ordersPage.ordersNumberSpan),
10,
);
await expect(numberOfOrdersAfterReset).to.be.equal(numberOfOrders);
});
it('should filter the Orders table by STATUS and check the result', async function () {
await this.pageObjects.orderPage.filterTableBySelect(
this.pageObjects.orderPage.orderFilterStatusSelect,
Statuses.paymentError.index,
await this.pageObjects.ordersPage.filterOrders(
'select',
'order_state',
Statuses.paymentError.status,
);
const result = await this.pageObjects.orderPage.checkTextValue(
this.pageObjects.orderPage.orderfirstLineStatusTD,
const result = await this.pageObjects.ordersPage.checkTextValue(
this.pageObjects.ordersPage.orderfirstLineStatusTD.replace('%ROW', '1'),
Statuses.paymentError.status,
);
await expect(result).to.be.true;
});
it('should reset all filters', async function () {
await this.pageObjects.ordersPage.resetFilter();
const numberOfOrdersAfterReset = await parseInt(
await this.pageObjects.ordersPage.getTextContent(this.pageObjects.ordersPage.ordersNumberSpan),
10,
);
await expect(numberOfOrdersAfterReset).to.be.equal(numberOfOrders);
});
it('should logout from the BO', async function () {
await this.pageObjects.boBasePage.logoutBO();
const pageTitle = await this.pageObjects.loginPage.getPageTitle();
Expand Down
16 changes: 10 additions & 6 deletions tests/puppeteer/campaigns/sanity/03_ordersBO/02_editOrder.js
Expand Up @@ -9,6 +9,7 @@ const LoginPage = require('@pages/BO/login');
const DashboardPage = require('@pages/BO/dashboard');
const BOBasePage = require('@pages/BO/BObasePage');
const OrderPage = require('@pages/BO/order');
const OrdersPage = require('@pages/BO/orders');
const {Statuses} = require('@data/demo/orders');

let browser;
Expand All @@ -20,6 +21,7 @@ const init = async function () {
dashboardPage: new DashboardPage(page),
boBasePage: new BOBasePage(page),
orderPage: new OrderPage(page),
ordersPage: new OrdersPage(page),
};
};

Expand All @@ -41,15 +43,17 @@ describe('Edit Order BO', async () => {
// Steps
loginCommon.loginBO();
it('should go to the Orders page', async function () {
await this.pageObjects.boBasePage.goToSubMenu(this.pageObjects.boBasePage.ordersParentLink,
this.pageObjects.orderPage.ordersLink);
const pageTitle = await this.pageObjects.orderPage.getPageTitle();
await expect(pageTitle).to.contains(this.pageObjects.orderPage.pageTitle);
await this.pageObjects.boBasePage.goToSubMenu(
this.pageObjects.boBasePage.ordersParentLink,
this.pageObjects.boBasePage.ordersLink,
);
const pageTitle = await this.pageObjects.ordersPage.getPageTitle();
await expect(pageTitle).to.contains(this.pageObjects.ordersPage.pageTitle);
});
it('should go to the first order page', async function () {
await this.pageObjects.boBasePage.waitForSelectorAndClick(this.pageObjects.orderPage.orderfirstLineIdTD);
await this.pageObjects.ordersPage.goToOrder('1');
PierreRambaud marked this conversation as resolved.
Show resolved Hide resolved
const pageTitle = await this.pageObjects.orderPage.getPageTitle();
await expect(pageTitle).to.contains(this.pageObjects.orderPage.orderPageTitle);
await expect(pageTitle).to.contains(this.pageObjects.orderPage.pageTitle);
});
it('should modify the product quantity and check the validation', async function () {
const result = await this.pageObjects.orderPage.modifyProductQuantity('1', '5');
Expand Down
Expand Up @@ -37,7 +37,8 @@ describe('Filter Products by categories in Home page', async () => {
// Steps
it('should open the shop page', async () => {
await this.pageObjects.homePage.goTo(global.FO.URL);
await this.pageObjects.homePage.checkHomePage();
const result = await this.pageObjects.homePage.isHomePage();
await expect(result).to.be.true;
});
it('should check and get the products number', async () => {
await this.pageObjects.homePage.waitForSelectorAndClick(this.pageObjects.homePage.allProductLink);
Expand Down
Expand Up @@ -38,10 +38,13 @@ describe('Check the Product page', async () => {
// Steps
it('should open the shop page', async function () {
await this.pageObjects.homePage.goTo(global.FO.URL);
await this.pageObjects.homePage.checkHomePage();
const result = await this.pageObjects.homePage.isHomePage();
await expect(result).to.be.true;
});
it('should go to the first product page', async function () {
await this.pageObjects.homePage.goToProductPage('1');
const pageTitle = await this.pageObjects.productPage.getPageTitle();
await expect(pageTitle.toUpperCase()).to.contains(ProductData.firstProductData.name);
});
it('should check the product page', async function () {
const result = await this.pageObjects.productPage.checkProduct(ProductData.firstProductData);
Expand Down