Skip to content

Commit

Permalink
Add some fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
nesrineabdmouleh committed Aug 2, 2024
1 parent 80069c9 commit 06221be
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 55 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ import loginCommon from '@commonTests/BO/loginBO';

// Import pages
// Import BO pages
import currenciesPage from '@pages/BO/international/currencies';
import languagesPage from '@pages/BO/international/languages';

import {
boDashboardPage,
boLocalizationPage,
boCurrenciesPage,
dataCurrencies,
dataLanguages,
foClassicHomePage,
Expand Down Expand Up @@ -83,7 +83,7 @@ describe('BO - International - Localization : Import a localization pack', async
await testContext.addContextItem(this, 'testIdentifier', 'goToFo', baseContext);

// View my shop and int pages
page = await currenciesPage.viewMyShop(page);
page = await boCurrenciesPage.viewMyShop(page);

const isHomePage = await foClassicHomePage.isHomePage(page);
expect(isHomePage).to.eq(true);
Expand Down Expand Up @@ -161,30 +161,30 @@ describe('BO - International - Localization : Import a localization pack', async

await boLocalizationPage.goToSubTabCurrencies(page);

const pageTitle = await currenciesPage.getPageTitle(page);
expect(pageTitle).to.contains(currenciesPage.pageTitle);
const pageTitle = await boCurrenciesPage.getPageTitle(page);
expect(pageTitle).to.contains(boCurrenciesPage.pageTitle);
});

it(`should filter by iso code of currency '${dataCurrencies.chileanPeso.isoCode}'`, async function () {
await testContext.addContextItem(this, 'testIdentifier', 'filterCurrencies', baseContext);

await currenciesPage.filterTable(page, 'input', 'iso_code', dataCurrencies.chileanPeso.isoCode);
await boCurrenciesPage.filterTable(page, 'input', 'iso_code', dataCurrencies.chileanPeso.isoCode);

const textColumn = await currenciesPage.getTextColumnFromTableCurrency(page, 1, 'iso_code');
const textColumn = await boCurrenciesPage.getTextColumnFromTableCurrency(page, 1, 'iso_code');
expect(textColumn).to.contains(dataCurrencies.chileanPeso.isoCode);
});

it('should delete currency', async function () {
await testContext.addContextItem(this, 'testIdentifier', 'deleteCurrency', baseContext);

const result = await currenciesPage.deleteCurrency(page, 1);
expect(result).to.be.equal(currenciesPage.successfulDeleteMessage);
const result = await boCurrenciesPage.deleteCurrency(page, 1);
expect(result).to.be.equal(boCurrenciesPage.successfulDeleteMessage);
});

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

const numberOfCurrenciesAfterReset = await currenciesPage.resetAndGetNumberOfLines(page);
const numberOfCurrenciesAfterReset = await boCurrenciesPage.resetAndGetNumberOfLines(page);
expect(numberOfCurrenciesAfterReset).to.be.at.least(1);
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ import loginCommon from '@commonTests/BO/loginBO';

// Import pages
// Import BO pages
import currenciesPage from '@pages/BO/international/currencies';
import languagesPage from '@pages/BO/international/languages';

import {
boDashboardPage,
boLocalizationPage,
boCurrenciesPage,
dataCurrencies,
dataLanguages,
foClassicHomePage,
Expand Down Expand Up @@ -157,30 +157,30 @@ describe('BO - International - Localization : Update default currency', async ()

await boLocalizationPage.goToSubTabCurrencies(page);

const pageTitle = await currenciesPage.getPageTitle(page);
expect(pageTitle).to.contains(currenciesPage.pageTitle);
const pageTitle = await boCurrenciesPage.getPageTitle(page);
expect(pageTitle).to.contains(boCurrenciesPage.pageTitle);
});

it(`should filter by iso code of currency '${dataCurrencies.chileanPeso.isoCode}'`, async function () {
await testContext.addContextItem(this, 'testIdentifier', 'filterCurrencies', baseContext);

await currenciesPage.filterTable(page, 'input', 'iso_code', dataCurrencies.chileanPeso.isoCode);
await boCurrenciesPage.filterTable(page, 'input', 'iso_code', dataCurrencies.chileanPeso.isoCode);

const textColumn = await currenciesPage.getTextColumnFromTableCurrency(page, 1, 'iso_code');
const textColumn = await boCurrenciesPage.getTextColumnFromTableCurrency(page, 1, 'iso_code');
expect(textColumn).to.contains(dataCurrencies.chileanPeso.isoCode);
});

it('should delete currency', async function () {
await testContext.addContextItem(this, 'testIdentifier', 'deleteCurrency', baseContext);

const result = await currenciesPage.deleteCurrency(page, 1);
expect(result).to.be.equal(currenciesPage.successfulDeleteMessage);
const result = await boCurrenciesPage.deleteCurrency(page, 1);
expect(result).to.be.equal(boCurrenciesPage.successfulDeleteMessage);
});

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

const numberOfCurrenciesAfterReset = await currenciesPage.resetAndGetNumberOfLines(page);
const numberOfCurrenciesAfterReset = await boCurrenciesPage.resetAndGetNumberOfLines(page);
expect(numberOfCurrenciesAfterReset).to.be.at.least(1);
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,12 @@ import testContext from '@utils/testContext';
// Import commonTests
import loginCommon from '@commonTests/BO/loginBO';

// Import pages
import currenciesPage from '@pages/BO/international/currencies';

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

Expand Down Expand Up @@ -54,24 +52,24 @@ describe('BO - International - currencies : Help button', async () => {

await boLocalizationPage.goToSubTabCurrencies(page);

const pageTitle = await currenciesPage.getPageTitle(page);
expect(pageTitle).to.contains(currenciesPage.pageTitle);
const pageTitle = await boCurrenciesPage.getPageTitle(page);
expect(pageTitle).to.contains(boCurrenciesPage.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 currenciesPage.openHelpSideBar(page);
const isHelpSidebarVisible = await boCurrenciesPage.openHelpSideBar(page);
expect(isHelpSidebarVisible).to.eq(true);

const documentURL = await currenciesPage.getHelpDocumentURL(page);
const documentURL = await boCurrenciesPage.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 isHelpSidebarVisible = await currenciesPage.closeHelpSideBar(page);
const isHelpSidebarVisible = await boCurrenciesPage.closeHelpSideBar(page);
expect(isHelpSidebarVisible).to.eq(true);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,10 @@ import {createCurrencyTest, deleteCurrencyTest} from '@commonTests/BO/internatio
import loginCommon from '@commonTests/BO/loginBO';

// Import pages
// Import BO pages
import currenciesPage from '@pages/BO/international/currencies';

import {
boDashboardPage,
boLocalizationPage,
boCurrenciesPage,
dataCurrencies,
dataProducts,
foClassicHomePage,
Expand Down Expand Up @@ -100,18 +98,18 @@ describe('FO - Header and Footer : Change currency', async () => {

await boLocalizationPage.goToSubTabCurrencies(page);

const pageTitle = await currenciesPage.getPageTitle(page);
expect(pageTitle).to.contains(currenciesPage.pageTitle);
const pageTitle = await boCurrenciesPage.getPageTitle(page);
expect(pageTitle).to.contains(boCurrenciesPage.pageTitle);
});

it(`should get the currency exchange rate value '${dataCurrencies.mad.isoCode}'`, async function () {
await testContext.addContextItem(this, 'testIdentifier', 'getExchangeRate', baseContext);

// Filter
await currenciesPage.filterTable(page, 'input', 'iso_code', dataCurrencies.mad.isoCode);
await boCurrenciesPage.filterTable(page, 'input', 'iso_code', dataCurrencies.mad.isoCode);

// Check exchange rate
exchangeRateValue = await currenciesPage.getExchangeRateValue(page, 1);
exchangeRateValue = await boCurrenciesPage.getExchangeRateValue(page, 1);
expect(exchangeRateValue).to.be.above(0);
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,10 @@ import {createCurrencyTest, deleteCurrencyTest} from '@commonTests/BO/internatio
import loginCommon from '@commonTests/BO/loginBO';

// Import pages
// Import BO pages
import currenciesPage from '@pages/BO/international/currencies';

import {
boDashboardPage,
boLocalizationPage,
boCurrenciesPage,
dataCurrencies,
dataProducts,
foHummingbirdHomePage,
Expand Down Expand Up @@ -102,18 +100,18 @@ describe('FO - Header and Footer : Change currency', async () => {

await boLocalizationPage.goToSubTabCurrencies(page);

const pageTitle = await currenciesPage.getPageTitle(page);
expect(pageTitle).to.contains(currenciesPage.pageTitle);
const pageTitle = await boCurrenciesPage.getPageTitle(page);
expect(pageTitle).to.contains(boCurrenciesPage.pageTitle);
});

it(`should get the currency exchange rate value '${dataCurrencies.mad.isoCode}'`, async function () {
await testContext.addContextItem(this, 'testIdentifier', 'getExchangeRate', baseContext);

// Filter
await currenciesPage.filterTable(page, 'input', 'iso_code', dataCurrencies.mad.isoCode);
await boCurrenciesPage.filterTable(page, 'input', 'iso_code', dataCurrencies.mad.isoCode);

// Check exchange rate
exchangeRateValue = await currenciesPage.getExchangeRateValue(page, 1);
exchangeRateValue = await boCurrenciesPage.getExchangeRateValue(page, 1);
expect(exchangeRateValue).to.be.above(0);
});
});
Expand Down
31 changes: 15 additions & 16 deletions tests/UI/commonTests/BO/international/currency.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@ import testContext from '@utils/testContext';
import loginCommon from '@commonTests/BO/loginBO';

// Import BO pages
import currenciesPage from '@pages/BO/international/currencies';
import addCurrencyPage from '@pages/BO/international/currencies/add';

import {
boDashboardPage,
boLocalizationPage,
boCurrenciesPage,
boCurrenciesCreatePage,
type FakerCurrency,
utilsPlaywright,
} from '@prestashop-core/ui-testing';
Expand Down Expand Up @@ -62,25 +61,25 @@ function createCurrencyTest(currencyData: FakerCurrency, baseContext: string = '

await boLocalizationPage.goToSubTabCurrencies(page);

const pageTitle = await currenciesPage.getPageTitle(page);
expect(pageTitle).to.contains(currenciesPage.pageTitle);
const pageTitle = await boCurrenciesPage.getPageTitle(page);
expect(pageTitle).to.contains(boCurrenciesPage.pageTitle);
});

it('should go to create new currency page', async function () {
await testContext.addContextItem(this, 'testIdentifier', 'goToAddNewCurrencyPage', baseContext);

await currenciesPage.goToAddNewCurrencyPage(page);
await boCurrenciesPage.goToAddNewCurrencyPage(page);

const pageTitle = await addCurrencyPage.getPageTitle(page);
expect(pageTitle).to.contains(addCurrencyPage.pageTitle);
const pageTitle = await boCurrenciesCreatePage.getPageTitle(page);
expect(pageTitle).to.contains(boCurrenciesCreatePage.pageTitle);
});

it('should create currency', async function () {
await testContext.addContextItem(this, 'testIdentifier', 'createOfficialCurrency', baseContext);

// Create and check successful message
const textResult = await addCurrencyPage.addOfficialCurrency(page, currencyData);
expect(textResult).to.contains(currenciesPage.successfulCreationMessage);
const textResult = await boCurrenciesCreatePage.addOfficialCurrency(page, currencyData);
expect(textResult).to.contains(boCurrenciesPage.successfulCreationMessage);
});
});
}
Expand Down Expand Up @@ -125,26 +124,26 @@ function deleteCurrencyTest(currencyData: FakerCurrency, baseContext: string = '

await boLocalizationPage.goToSubTabCurrencies(page);

const pageTitle = await currenciesPage.getPageTitle(page);
expect(pageTitle).to.contains(currenciesPage.pageTitle);
const pageTitle = await boCurrenciesPage.getPageTitle(page);
expect(pageTitle).to.contains(boCurrenciesPage.pageTitle);
});

it(`should filter by iso code of currency '${currencyData.isoCode}'`, async function () {
await testContext.addContextItem(this, 'testIdentifier', 'filterToDelete', baseContext);

// Filter
await currenciesPage.filterTable(page, 'input', 'iso_code', currencyData.isoCode);
await boCurrenciesPage.filterTable(page, 'input', 'iso_code', currencyData.isoCode);

// Check currency to delete
const textColumn = await currenciesPage.getTextColumnFromTableCurrency(page, 1, 'iso_code');
const textColumn = await boCurrenciesPage.getTextColumnFromTableCurrency(page, 1, 'iso_code');
expect(textColumn).to.contains(currencyData.isoCode);
});

it('should delete currency', async function () {
await testContext.addContextItem(this, 'testIdentifier', 'deleteCurrency', baseContext);

const result = await currenciesPage.deleteCurrency(page, 1);
expect(result).to.be.equal(currenciesPage.successfulDeleteMessage);
const result = await boCurrenciesPage.deleteCurrency(page, 1);
expect(result).to.be.equal(boCurrenciesPage.successfulDeleteMessage);
});
});
}
Expand Down

0 comments on commit 06221be

Please sign in to comment.