Skip to content

Commit

Permalink
Merge pull request PrestaShop#36986 from Progi1984/migrateUITest_2024…
Browse files Browse the repository at this point in the history
…0919

Functional Tests : Migrate pages to `ui-testing-library`
  • Loading branch information
Progi1984 authored Sep 20, 2024
2 parents a55b4cf + afca13b commit d3b245c
Show file tree
Hide file tree
Showing 168 changed files with 2,208 additions and 6,003 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import testContext from '@utils/testContext';

// Import BO pages
import statsPage from '@pages/BO/stats';
import ordersPage from '@pages/BO/orders';
import {viewOrderBasePage} from '@pages/BO/orders/view/viewOrderBasePage';
import merchandiseReturnsPage from '@pages/BO/customerService/merchandiseReturns';
import monitoringPage from '@pages/BO/catalog/monitoring';
Expand All @@ -12,7 +11,6 @@ import customerServicePage from '@pages/BO/customerService/customerService';
import productCommentsPage from '@pages/BO/modules/productComments';

// Import FO pages
import {orderConfirmationPage} from '@pages/FO/classic/checkout/orderConfirmation';
import {orderHistoryPage} from '@pages/FO/classic/myAccount/orderHistory';
import {orderDetailsPage} from '@pages/FO/classic/myAccount/orderDetails';
import {merchandiseReturnsPage as foMerchandiseReturnsPage} from '@pages/FO/classic/myAccount/merchandiseReturns';
Expand All @@ -28,6 +26,7 @@ import {deleteCustomerTest} from '@commonTests/BO/customers/customer';
import {
boCustomersPage,
boDashboardPage,
boOrdersPage,
boProductsPage,
boShoppingCartsPage,
dataCustomers,
Expand All @@ -39,6 +38,7 @@ import {
FakerProduct,
foClassicCartPage,
foClassicCheckoutPage,
foClassicCheckoutOrderConfirmationPage,
foClassicHomePage,
foClassicLoginPage,
foClassicMyAccountPage,
Expand Down Expand Up @@ -188,15 +188,15 @@ describe('BO - Dashboard : Activity overview', async () => {
await foClassicCheckoutPage.choosePaymentAndOrder(page, dataPaymentMethods.wirePayment.moduleName);

// Check the confirmation message
const cardTitle = await orderConfirmationPage.getOrderConfirmationCardTitle(page);
expect(cardTitle).to.contains(orderConfirmationPage.orderConfirmationCardTitle);
const cardTitle = await foClassicCheckoutOrderConfirmationPage.getOrderConfirmationCardTitle(page);
expect(cardTitle).to.contains(foClassicCheckoutOrderConfirmationPage.orderConfirmationCardTitle);
});

it('should go back to BO', async function () {
await testContext.addContextItem(this, 'testIdentifier', 'goBackToBO2', baseContext);

// Close page and init page objects
page = await orderConfirmationPage.closePage(browserContext, page, 0);
page = await foClassicCheckoutOrderConfirmationPage.closePage(browserContext, page, 0);
await boShoppingCartsPage.reloadPage(page);

const pageTitle = await boDashboardPage.getPageTitle(page);
Expand Down Expand Up @@ -225,15 +225,15 @@ describe('BO - Dashboard : Activity overview', async () => {

await boDashboardPage.clickOnOrdersLink(page);

const pageTitle = await ordersPage.getPageTitle(page);
expect(pageTitle).to.contains(ordersPage.pageTitle);
const pageTitle = await boOrdersPage.getPageTitle(page);
expect(pageTitle).to.contains(boOrdersPage.pageTitle);
});

it('should change the first order status to Processing in progress', async function () {
await testContext.addContextItem(this, 'testIdentifier', 'changeOrderStatus1', baseContext);

const textResult = await ordersPage.setOrderStatus(page, 1, dataOrderStatuses.processingInProgress);
expect(textResult).to.equal(ordersPage.successfulUpdateMessage);
const textResult = await boOrdersPage.setOrderStatus(page, 1, dataOrderStatuses.processingInProgress);
expect(textResult).to.equal(boOrdersPage.successfulUpdateMessage);
});

it('should go back to dashboard page', async function () {
Expand Down Expand Up @@ -278,15 +278,15 @@ describe('BO - Dashboard : Activity overview', async () => {
boDashboardPage.ordersLink,
);

const pageTitle = await ordersPage.getPageTitle(page);
expect(pageTitle).to.contains(ordersPage.pageTitle);
const pageTitle = await boOrdersPage.getPageTitle(page);
expect(pageTitle).to.contains(boOrdersPage.pageTitle);
});

it('should change the first order status to Delivered', async function () {
await testContext.addContextItem(this, 'testIdentifier', 'changeOrderStatus2', baseContext);

const textResult = await ordersPage.setOrderStatus(page, 1, dataOrderStatuses.delivered);
expect(textResult).to.equal(ordersPage.successfulUpdateMessage);
const textResult = await boOrdersPage.setOrderStatus(page, 1, dataOrderStatuses.delivered);
expect(textResult).to.equal(boOrdersPage.successfulUpdateMessage);
});

it('should go back to dashboard page', async function () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@ import testContext from '@utils/testContext';
// Import commonTests
import loginCommon from '@commonTests/BO/loginBO';

// Import pages
import ordersPage from '@pages/BO/orders';

import {expect} from 'chai';
import type {BrowserContext, Page} from 'playwright';
import {
boDashboardPage,
boOrdersPage,
utilsPlaywright,
} from '@prestashop-core/ui-testing';

Expand Down Expand Up @@ -43,26 +41,26 @@ describe('BO - Orders : Help card in order page', async () => {
boDashboardPage.ordersParentLink,
boDashboardPage.ordersLink,
);
await ordersPage.closeSfToolBar(page);
await boOrdersPage.closeSfToolBar(page);

const pageTitle = await ordersPage.getPageTitle(page);
expect(pageTitle).to.contains(ordersPage.pageTitle);
const pageTitle = await boOrdersPage.getPageTitle(page);
expect(pageTitle).to.contains(boOrdersPage.pageTitle);
});

it('should open the help side bar and check the document language', async function () {
await testContext.addContextItem(this, 'testIdentifier', 'openHelpSidebar', baseContext);

const isHelpSidebarVisible = await ordersPage.openHelpSideBar(page);
const isHelpSidebarVisible = await boOrdersPage.openHelpSideBar(page);
expect(isHelpSidebarVisible).to.eq(true);

const documentURL = await ordersPage.getHelpDocumentURL(page);
const documentURL = await boOrdersPage.getHelpDocumentURL(page);
expect(documentURL).to.contains('country=en');
});

it('should close the help side bar', async function () {
await testContext.addContextItem(this, 'testIdentifier', 'closeHelpSidebar', baseContext);

const isHelpSidebarClosed = await ordersPage.closeHelpSideBar(page);
const isHelpSidebarClosed = await boOrdersPage.closeHelpSideBar(page);
expect(isHelpSidebarClosed).to.eq(true);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@ import testContext from '@utils/testContext';
// Import commonTests
import loginCommon from '@commonTests/BO/loginBO';

// Import pages
import ordersPage from '@pages/BO/orders';

import {expect} from 'chai';
import type {BrowserContext, Page} from 'playwright';
import {
boDashboardPage,
boOrdersPage,
dataOrders,
utilsDate,
utilsPlaywright,
Expand Down Expand Up @@ -52,14 +50,14 @@ describe('BO - Orders : Filter the Orders table', async () => {
boDashboardPage.ordersLink,
);

const pageTitle = await ordersPage.getPageTitle(page);
expect(pageTitle).to.contains(ordersPage.pageTitle);
const pageTitle = await boOrdersPage.getPageTitle(page);
expect(pageTitle).to.contains(boOrdersPage.pageTitle);
});

it('should reset all filters and get number of orders', async function () {
await testContext.addContextItem(this, 'testIdentifier', 'resetFiltersFirst', baseContext);

numberOfOrders = await ordersPage.resetAndGetNumberOfLines(page);
numberOfOrders = await boOrdersPage.resetAndGetNumberOfLines(page);
expect(numberOfOrders).to.be.above(0);
});

Expand Down Expand Up @@ -140,26 +138,26 @@ describe('BO - Orders : Filter the Orders table', async () => {
it(`should filter the Orders table by '${test.args.filterBy}' and check the result`, async function () {
await testContext.addContextItem(this, 'testIdentifier', test.args.identifier, baseContext);

await ordersPage.filterOrders(
await boOrdersPage.filterOrders(
page,
test.args.filterType,
test.args.filterBy,
test.args.filterValue,
);

const numberOfOrdersAfterFilter = await ordersPage.getNumberOfElementInGrid(page);
const numberOfOrdersAfterFilter = await boOrdersPage.getNumberOfElementInGrid(page);
expect(numberOfOrdersAfterFilter).to.be.at.most(numberOfOrders);

for (let row = 1; row <= numberOfOrdersAfterFilter; row++) {
const textColumn = await ordersPage.getTextColumn(page, test.args.filterBy, row);
const textColumn = await boOrdersPage.getTextColumn(page, test.args.filterBy, row);
expect(textColumn).to.equal(test.args.filterValue);
}
});

it('should reset all filters', async function () {
await testContext.addContextItem(this, 'testIdentifier', `${test.args.identifier}Reset`, baseContext);

const numberOfOrdersAfterReset = await ordersPage.resetAndGetNumberOfLines(page);
const numberOfOrdersAfterReset = await boOrdersPage.resetAndGetNumberOfLines(page);
expect(numberOfOrdersAfterReset).to.be.equal(numberOfOrders);
});
});
Expand All @@ -168,22 +166,22 @@ describe('BO - Orders : Filter the Orders table', async () => {
await testContext.addContextItem(this, 'testIdentifier', 'filterByDate', baseContext);

// Filter orders
await ordersPage.filterOrdersByDate(page, today, today);
await boOrdersPage.filterOrdersByDate(page, today, today);

// Check number of element
const numberOfOrdersAfterFilter = await ordersPage.getNumberOfElementInGrid(page);
const numberOfOrdersAfterFilter = await boOrdersPage.getNumberOfElementInGrid(page);
expect(numberOfOrdersAfterFilter).to.be.at.most(numberOfOrders);

for (let i = 1; i <= numberOfOrdersAfterFilter; i++) {
const textColumn = await ordersPage.getTextColumn(page, 'date_add', i);
const textColumn = await boOrdersPage.getTextColumn(page, 'date_add', i);
expect(textColumn).to.contains(dateToCheck);
}
});

it('should reset all filters', async function () {
await testContext.addContextItem(this, 'testIdentifier', 'resetFilter', baseContext);

const numberOfOrdersAfterReset = await ordersPage.resetAndGetNumberOfLines(page);
const numberOfOrdersAfterReset = await boOrdersPage.resetAndGetNumberOfLines(page);
expect(numberOfOrdersAfterReset).to.be.equal(numberOfOrders);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@ import testContext from '@utils/testContext';
// Import commonTests
import loginCommon from '@commonTests/BO/loginBO';

// Import pages
import ordersPage from '@pages/BO/orders';

import {expect} from 'chai';
import type {BrowserContext, Page} from 'playwright';
import {
boDashboardPage,
boOrdersPage,
utilsFile,
utilsPlaywright,
} from '@prestashop-core/ui-testing';
Expand Down Expand Up @@ -45,16 +43,16 @@ describe('BO - Orders : Export orders', async () => {
boDashboardPage.ordersParentLink,
boDashboardPage.ordersLink,
);
await ordersPage.closeSfToolBar(page);
await boOrdersPage.closeSfToolBar(page);

const pageTitle = await ordersPage.getPageTitle(page);
expect(pageTitle).to.contains(ordersPage.pageTitle);
const pageTitle = await boOrdersPage.getPageTitle(page);
expect(pageTitle).to.contains(boOrdersPage.pageTitle);
});

it('should export orders to a csv file', async function () {
await testContext.addContextItem(this, 'testIdentifier', 'exportOrders', baseContext);

filePath = await ordersPage.exportDataToCsv(page);
filePath = await boOrdersPage.exportDataToCsv(page);

const doesFileExist = await utilsFile.doesFileExist(filePath, 5000);
expect(doesFileExist, 'Export of data has failed').to.eq(true);
Expand All @@ -64,11 +62,11 @@ describe('BO - Orders : Export orders', async () => {
await testContext.addContextItem(this, 'testIdentifier', 'checkAllOrdersInCsvFile', baseContext);

// Get number of orders
const numberOfOrders = await ordersPage.getNumberOfElementInGrid(page);
const numberOfOrders = await boOrdersPage.getNumberOfElementInGrid(page);

// Check each order in file
for (let row = 1; row <= numberOfOrders; row++) {
const orderInCsvFormat = await ordersPage.getOrderInCsvFormat(page, row);
const orderInCsvFormat = await boOrdersPage.getOrderInCsvFormat(page, row);
const textExist = await utilsFile.isTextInFile(filePath, orderInCsvFormat, true, true);
expect(textExist, `${orderInCsvFormat} was not found in the file`).to.eq(true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,12 @@ import {createOrderByCustomerTest} from '@commonTests/FO/classic/order';
import {setupSmtpConfigTest, resetSmtpConfigTest} from '@commonTests/BO/advancedParameters/smtp';

// Import pages
// Import BO pages
import ordersPage from '@pages/BO/orders';
// Import FO pages
import {orderHistoryPage} from '@pages/FO/classic/myAccount/orderHistory';

import {
boDashboardPage,
boOrdersPage,
dataCustomers,
dataOrderStatuses,
dataPaymentMethods,
Expand Down Expand Up @@ -112,16 +111,16 @@ describe('BO - orders : Update order status', async () => {
boDashboardPage.ordersLink,
);

const pageTitle = await ordersPage.getPageTitle(page);
expect(pageTitle).to.contains(ordersPage.pageTitle);
const pageTitle = await boOrdersPage.getPageTitle(page);
expect(pageTitle).to.contains(boOrdersPage.pageTitle);
});

it('should reset filter and get the last order ID', async function () {
await testContext.addContextItem(this, 'testIdentifier', 'resetFilter', baseContext);

await ordersPage.resetFilter(page);
await boOrdersPage.resetFilter(page);

const result = await ordersPage.getTextColumn(page, 'id_order', 1);
const result = await boOrdersPage.getTextColumn(page, 'id_order', 1);
orderId = parseInt(result, 10);
expect(orderId).to.be.at.least(1);
});
Expand All @@ -140,14 +139,14 @@ describe('BO - orders : Update order status', async () => {
it('should update order status', async function () {
await testContext.addContextItem(this, 'testIdentifier', `updateOrderStatus${index}`, baseContext);

const textResult = await ordersPage.setOrderStatus(page, 1, test.args.orderStatus);
expect(textResult).to.equal(ordersPage.successfulUpdateMessage);
const textResult = await boOrdersPage.setOrderStatus(page, 1, test.args.orderStatus);
expect(textResult).to.equal(boOrdersPage.successfulUpdateMessage);
});

it('should check that the status is updated successfully', async function () {
await testContext.addContextItem(this, 'testIdentifier', `checkStatusBO${index}`, baseContext);

const orderStatus = await ordersPage.getTextColumn(page, 'osname', 1);
const orderStatus = await boOrdersPage.getTextColumn(page, 'osname', 1);
expect(orderStatus, 'Order status was not updated').to.equal(test.args.orderStatus.name);
});

Expand All @@ -161,7 +160,7 @@ describe('BO - orders : Update order status', async () => {
it('should download invoice', async function () {
await testContext.addContextItem(this, 'testIdentifier', 'downloadInvoice', baseContext);

filePath = await ordersPage.downloadInvoice(page, 1);
filePath = await boOrdersPage.downloadInvoice(page, 1);

const doesFileExist = await utilsFile.doesFileExist(filePath, 5000);
expect(doesFileExist, 'The file is not existing!').to.eq(true);
Expand All @@ -171,7 +170,7 @@ describe('BO - orders : Update order status', async () => {
await testContext.addContextItem(this, 'testIdentifier', 'checkInvoiceText', baseContext);

// Get order information
const orderInformation = await ordersPage.getOrderFromTable(page, 1);
const orderInformation = await boOrdersPage.getOrderFromTable(page, 1);

// Check Reference in pdf
const referenceExist = await utilsFile.isTextInPDF(filePath, orderInformation.reference);
Expand Down Expand Up @@ -199,7 +198,7 @@ describe('BO - orders : Update order status', async () => {
it('should download delivery slip', async function () {
await testContext.addContextItem(this, 'testIdentifier', 'downloadDeliverySlip', baseContext);

filePath = await ordersPage.downloadDeliverySlip(page, 1);
filePath = await boOrdersPage.downloadDeliverySlip(page, 1);

const doesFileExist = await utilsFile.doesFileExist(filePath, 5000);
expect(doesFileExist).to.eq(true);
Expand All @@ -209,7 +208,7 @@ describe('BO - orders : Update order status', async () => {
await testContext.addContextItem(this, 'testIdentifier', 'checkDeliverySlip', baseContext);

// Get delivery slip information
const orderInformation = await ordersPage.getOrderFromTable(page, 1);
const orderInformation = await boOrdersPage.getOrderFromTable(page, 1);

// Check Reference in pdf
const referenceExist = await utilsFile.isTextInPDF(filePath, orderInformation.reference);
Expand Down Expand Up @@ -239,7 +238,7 @@ describe('BO - orders : Update order status', async () => {
it('should go to FO page', async function () {
await testContext.addContextItem(this, 'testIdentifier', `goToFoToCheckStatus${index}`, baseContext);

page = await ordersPage.viewMyShop(page);
page = await boOrdersPage.viewMyShop(page);
await foClassicHomePage.changeLanguage(page, 'en');

const isHomePage = await foClassicHomePage.isHomePage(page);
Expand Down Expand Up @@ -303,8 +302,8 @@ describe('BO - orders : Update order status', async () => {

page = await orderHistoryPage.closePage(browserContext, page, 0);

const pageTitle = await ordersPage.getPageTitle(page);
expect(pageTitle).to.contains(ordersPage.pageTitle);
const pageTitle = await boOrdersPage.getPageTitle(page);
expect(pageTitle).to.contains(boOrdersPage.pageTitle);
});
});
});
Expand Down
Loading

0 comments on commit d3b245c

Please sign in to comment.