Skip to content

Commit

Permalink
Merge pull request #58 from Progi1984/uiTestBranchMain
Browse files Browse the repository at this point in the history
Functional Tests : Use `main` branch for `@prestashop-core/ui-testing`
  • Loading branch information
Progi1984 authored Sep 27, 2024
2 parents f73f331 + 414236c commit fe30238
Show file tree
Hide file tree
Showing 5 changed files with 4,945 additions and 674 deletions.
51 changes: 25 additions & 26 deletions tests/UI/campaigns/01_installation/04_resetModule.spec.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,24 @@
import {
// Import utils
testContext,
// Import BO pages
boDashboardPage,
boLoginPage,
boModuleManagerPage,
boModuleManagerUninstalledModulesPage,
// Import FO pages
foClassicCartPage,
foClassicHomePage,
foClassicLoginPage,
// Import data
dataCustomers,
dataModules,
foClassicCartPage,
foClassicCheckoutPage,
foClassicHomePage,
foClassicLoginPage,
foClassicModalBlockCartPage,
foClassicModalQuickViewPage,
utilsTest,
} from '@prestashop-core/ui-testing';

import { test, expect, Page, BrowserContext } from '@playwright/test';
import semver from 'semver';

const baseContext: string = 'modules_ps_cashondelivery_installation_resetModule';
const psVersion = testContext.getPSVersion();
const psVersion = utilsTest.getPSVersion();

test.describe('Cash on delivery (COD) module - Reset module', async () => {
let browserContext: BrowserContext;
Expand All @@ -35,7 +33,7 @@ test.describe('Cash on delivery (COD) module - Reset module', async () => {
});

test('should login in BO', async () => {
await testContext.addContextItem(test.info(), 'testIdentifier', 'loginBO', baseContext);
await utilsTest.addContextItem(test.info(), 'testIdentifier', 'loginBO', baseContext);

await boLoginPage.goTo(page, global.BO.URL);
await boLoginPage.successLogin(page, global.BO.EMAIL, global.BO.PASSWD);
Expand All @@ -46,7 +44,7 @@ test.describe('Cash on delivery (COD) module - Reset module', async () => {

if (semver.lt(psVersion, '8.0.0')) {
test('should go to \'Modules > Module Manager\' page for installing module', async () => {
await testContext.addContextItem(test.info(), 'testIdentifier', 'goToModuleManagerPageToInstall', baseContext);
await utilsTest.addContextItem(test.info(), 'testIdentifier', 'goToModuleManagerPageToInstall', baseContext);

await boDashboardPage.goToSubMenu(
page,
Expand All @@ -60,7 +58,7 @@ test.describe('Cash on delivery (COD) module - Reset module', async () => {
});

test('should install module', async () => {
await testContext.addContextItem(test.info(), 'testIdentifier', 'searchModuleToInstall', baseContext);
await utilsTest.addContextItem(test.info(), 'testIdentifier', 'searchModuleToInstall', baseContext);

await boModuleManagerUninstalledModulesPage.goToTabUninstalledModules(page);

Expand All @@ -70,7 +68,7 @@ test.describe('Cash on delivery (COD) module - Reset module', async () => {
}

test('should go to \'Modules > Module Manager\' page', async () => {
await testContext.addContextItem(test.info(), 'testIdentifier', 'goToModuleManagerPage', baseContext);
await utilsTest.addContextItem(test.info(), 'testIdentifier', 'goToModuleManagerPage', baseContext);

await boDashboardPage.goToSubMenu(
page,
Expand All @@ -84,14 +82,14 @@ test.describe('Cash on delivery (COD) module - Reset module', async () => {
});

test(`should search the module ${dataModules.psCashOnDelivery.name}`, async () => {
await testContext.addContextItem(test.info(), 'testIdentifier', 'searchModule', baseContext);
await utilsTest.addContextItem(test.info(), 'testIdentifier', 'searchModule', baseContext);

const isModuleVisible = await boModuleManagerPage.searchModule(page, dataModules.psCashOnDelivery);
expect(isModuleVisible).toEqual(true);
});

test('should display the reset modal and cancel it', async () => {
await testContext.addContextItem(test.info(), 'testIdentifier', 'resetModuleAndCancel', baseContext);
await utilsTest.addContextItem(test.info(), 'testIdentifier', 'resetModuleAndCancel', baseContext);

const textResult = await boModuleManagerPage.setActionInModule(page, dataModules.psCashOnDelivery, 'reset', true);
expect(textResult).toEqual('');
Expand All @@ -104,14 +102,14 @@ test.describe('Cash on delivery (COD) module - Reset module', async () => {
});

test('should reset the module', async () => {
await testContext.addContextItem(test.info(), 'testIdentifier', 'resetModule', baseContext);
await utilsTest.addContextItem(test.info(), 'testIdentifier', 'resetModule', baseContext);

const successMessage = await boModuleManagerPage.setActionInModule(page, dataModules.psCashOnDelivery, 'reset');
expect(successMessage).toEqual(boModuleManagerPage.resetModuleSuccessMessage(dataModules.psCashOnDelivery.tag));
});

test('should go to Front Office', async () => {
await testContext.addContextItem(test.info(), 'testIdentifier', 'goToFo', baseContext);
await utilsTest.addContextItem(test.info(), 'testIdentifier', 'goToFo', baseContext);

page = await boModuleManagerPage.viewMyShop(page);
await foClassicHomePage.changeLanguage(page, 'en');
Expand All @@ -121,7 +119,7 @@ test.describe('Cash on delivery (COD) module - Reset module', async () => {
});

test('should go to login page', async () => {
await testContext.addContextItem(test.info(), 'testIdentifier', 'goToLoginPageFO', baseContext);
await utilsTest.addContextItem(test.info(), 'testIdentifier', 'goToLoginPageFO', baseContext);

await foClassicHomePage.goToLoginPage(page);

Expand All @@ -130,7 +128,7 @@ test.describe('Cash on delivery (COD) module - Reset module', async () => {
});

test('should sign in with default customer', async () => {
await testContext.addContextItem(test.info(), 'testIdentifier', 'sighInFO', baseContext);
await utilsTest.addContextItem(test.info(), 'testIdentifier', 'sighInFO', baseContext);

await foClassicLoginPage.customerLogin(page, dataCustomers.johnDoe);

Expand All @@ -139,20 +137,21 @@ test.describe('Cash on delivery (COD) module - Reset module', async () => {
});

test('should add the first product to the cart', async () => {
await testContext.addContextItem(test.info(), 'testIdentifier', 'addProductToCart', baseContext);
await utilsTest.addContextItem(test.info(), 'testIdentifier', 'addProductToCart', baseContext);

await foClassicLoginPage.goToHomePage(page);

// Add first product to cart by quick view
await foClassicHomePage.addProductToCartByQuickView(page, 1);
await foClassicHomePage.proceedToCheckout(page);
await foClassicHomePage.quickViewProduct(page, 1);
await foClassicModalQuickViewPage.addToCartByQuickView(page);
await foClassicModalBlockCartPage.proceedToCheckout(page);

const pageTitle = await foClassicCartPage.getPageTitle(page);
expect(pageTitle).toEqual(foClassicCartPage.pageTitle);
});

test('should proceed to checkout and check Step Address', async () => {
await testContext.addContextItem(test.info(), 'testIdentifier', 'checkAddressStep', baseContext);
await utilsTest.addContextItem(test.info(), 'testIdentifier', 'checkAddressStep', baseContext);

await foClassicCartPage.clickOnProceedToCheckout(page);

Expand All @@ -167,21 +166,21 @@ test.describe('Cash on delivery (COD) module - Reset module', async () => {
});

test('should validate Step Address and go to Delivery Step', async () => {
await testContext.addContextItem(test.info(), 'testIdentifier', 'checkDeliveryStep', baseContext);
await utilsTest.addContextItem(test.info(), 'testIdentifier', 'checkDeliveryStep', baseContext);

const isStepAddressComplete = await foClassicCheckoutPage.goToDeliveryStep(page);
expect(isStepAddressComplete).toEqual(true);
});

test('should go to payment step', async () => {
await testContext.addContextItem(test.info(), 'testIdentifier', 'goToPaymentStep', baseContext);
await utilsTest.addContextItem(test.info(), 'testIdentifier', 'goToPaymentStep', baseContext);

const isStepDeliveryComplete = await foClassicCheckoutPage.goToPaymentStep(page);
expect(isStepDeliveryComplete, 'Step Address is not complete').toEqual(true);
});

test(`should check the '${dataModules.psCashOnDelivery.name}' payment module`, async () => {
await testContext.addContextItem(test.info(), 'testIdentifier', 'checkPaymentModule', baseContext);
await utilsTest.addContextItem(test.info(), 'testIdentifier', 'checkPaymentModule', baseContext);

// Payment step - Choose payment step
const isVisible = await foClassicCheckoutPage.isPaymentMethodExist(page, dataModules.psCashOnDelivery.tag);
Expand Down
43 changes: 21 additions & 22 deletions tests/UI/campaigns/02_configuration/01_placeOrderWithIt.spec.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
import {
// Import utils
testContext,
// Import BO pages
boDashboardPage,
boLoginPage,
boOrdersPage,
// Import FO pages
dataCustomers,
dataOrderStatuses,
dataPaymentMethods,
foClassicCartPage,
foClassicCheckoutPage,
foClassicCheckoutOrderConfirmationPage,
foClassicHomePage,
foClassicLoginPage,
// Import data
dataCustomers,
dataOrderStatuses,
dataPaymentMethods,
utilsTest,
foClassicModalBlockCartPage,
foClassicModalQuickViewPage,
} from '@prestashop-core/ui-testing';

import { test, expect, Page, BrowserContext } from '@playwright/test';
Expand All @@ -36,7 +34,7 @@ test.describe('Cash on delivery (COD) module - Place an order with it', async ()

test.describe('FO - Order a product with Cash on delivery payment', async () => {
test('should go to FO home page', async () => {
await testContext.addContextItem(test.info(), 'testIdentifier', 'goToFO', baseContext);
await utilsTest.addContextItem(test.info(), 'testIdentifier', 'goToFO', baseContext);

await foClassicHomePage.goToFo(page);

Expand All @@ -45,7 +43,7 @@ test.describe('Cash on delivery (COD) module - Place an order with it', async ()
});

test('should go to login page', async () => {
await testContext.addContextItem(test.info(), 'testIdentifier', 'goToLoginPageFO', baseContext);
await utilsTest.addContextItem(test.info(), 'testIdentifier', 'goToLoginPageFO', baseContext);

await foClassicHomePage.goToLoginPage(page);

Expand All @@ -54,7 +52,7 @@ test.describe('Cash on delivery (COD) module - Place an order with it', async ()
});

test('should sign in with default customer', async () => {
await testContext.addContextItem(test.info(), 'testIdentifier', 'sighInFO', baseContext);
await utilsTest.addContextItem(test.info(), 'testIdentifier', 'sighInFO', baseContext);

await foClassicLoginPage.customerLogin(page, dataCustomers.johnDoe);

Expand All @@ -63,20 +61,21 @@ test.describe('Cash on delivery (COD) module - Place an order with it', async ()
});

test('should add the first product to the cart', async () => {
await testContext.addContextItem(test.info(), 'testIdentifier', 'addProductToCart', baseContext);
await utilsTest.addContextItem(test.info(), 'testIdentifier', 'addProductToCart', baseContext);

await foClassicLoginPage.goToHomePage(page);

// Add first product to cart by quick view
await foClassicHomePage.addProductToCartByQuickView(page, 1);
await foClassicHomePage.proceedToCheckout(page);
await foClassicHomePage.quickViewProduct(page, 1);
await foClassicModalQuickViewPage.addToCartByQuickView(page);
await foClassicModalBlockCartPage.proceedToCheckout(page);

const pageTitle = await foClassicCartPage.getPageTitle(page);
expect(pageTitle).toEqual(foClassicCartPage.pageTitle);
});

test('should proceed to checkout and check Step Address', async () => {
await testContext.addContextItem(test.info(), 'testIdentifier', 'checkAddressStep', baseContext);
await utilsTest.addContextItem(test.info(), 'testIdentifier', 'checkAddressStep', baseContext);

await foClassicCartPage.clickOnProceedToCheckout(page);

Expand All @@ -91,21 +90,21 @@ test.describe('Cash on delivery (COD) module - Place an order with it', async ()
});

test('should validate Step Address and go to Delivery Step', async () => {
await testContext.addContextItem(test.info(), 'testIdentifier', 'checkDeliveryStep', baseContext);
await utilsTest.addContextItem(test.info(), 'testIdentifier', 'checkDeliveryStep', baseContext);

const isStepAddressComplete = await foClassicCheckoutPage.goToDeliveryStep(page);
expect(isStepAddressComplete).toEqual(true);
});

test('should go to payment step', async () => {
await testContext.addContextItem(test.info(), 'testIdentifier', 'goToPaymentStep', baseContext);
await utilsTest.addContextItem(test.info(), 'testIdentifier', 'goToPaymentStep', baseContext);

const isStepDeliveryComplete = await foClassicCheckoutPage.goToPaymentStep(page);
expect(isStepDeliveryComplete, 'Step Address is not complete').toEqual(true);
});

test('should choose payment method and confirm the order', async () => {
await testContext.addContextItem(test.info(), 'testIdentifier', 'confirmOrder', baseContext);
await utilsTest.addContextItem(test.info(), 'testIdentifier', 'confirmOrder', baseContext);

// Payment step - Choose payment step
await foClassicCheckoutPage.choosePaymentAndOrder(page, dataPaymentMethods.cashOnDelivery.moduleName);
Expand All @@ -121,7 +120,7 @@ test.describe('Cash on delivery (COD) module - Place an order with it', async ()

test.describe('BO - Check the last order', async () => {
test('should login in BO', async () => {
await testContext.addContextItem(test.info(), 'testIdentifier', 'loginBO', baseContext);
await utilsTest.addContextItem(test.info(), 'testIdentifier', 'loginBO', baseContext);

await boLoginPage.goTo(page, global.BO.URL);
await boLoginPage.successLogin(page, global.BO.EMAIL, global.BO.PASSWD);
Expand All @@ -131,7 +130,7 @@ test.describe('Cash on delivery (COD) module - Place an order with it', async ()
});

test('should go to \'Orders > Orders\' page', async () => {
await testContext.addContextItem(test.info(), 'testIdentifier', 'goToOrdersPage', baseContext);
await utilsTest.addContextItem(test.info(), 'testIdentifier', 'goToOrdersPage', baseContext);

await boDashboardPage.goToSubMenu(
page,
Expand All @@ -144,14 +143,14 @@ test.describe('Cash on delivery (COD) module - Place an order with it', async ()
});

test('should reset all filters and get number of orders', async () => {
await testContext.addContextItem(test.info(), 'testIdentifier', 'resetFiltersFirst', baseContext);
await utilsTest.addContextItem(test.info(), 'testIdentifier', 'resetFiltersFirst', baseContext);

const numberOfOrders = await boOrdersPage.resetAndGetNumberOfLines(page);
expect(numberOfOrders).toBeGreaterThan(0);
});

test('should check the last order', async () => {
await testContext.addContextItem(test.info(), 'testIdentifier', 'checkLastOrder', baseContext);
await utilsTest.addContextItem(test.info(), 'testIdentifier', 'checkLastOrder', baseContext);

const rowOrderReference = await boOrdersPage.getTextColumn(page, 'reference', 1);
expect(rowOrderReference).toEqual(orderReference);
Expand Down
Loading

0 comments on commit fe30238

Please sign in to comment.