Skip to content

Commit

Permalink
Merge pull request PrestaShop#35710 from Progi1984/uiTestsBumpLib
Browse files Browse the repository at this point in the history
UI Tests : Bump `@prestashop-core/ui-testing` to 0.0.11
  • Loading branch information
Progi1984 authored Mar 22, 2024
2 parents 3af02e8 + d67fc23 commit a574a1e
Show file tree
Hide file tree
Showing 274 changed files with 1,861 additions and 2,960 deletions.
47 changes: 27 additions & 20 deletions tests/UI/campaigns/cldr/03_deleteCurrency.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ import localizationPage from '@pages/BO/international/localization';
import currenciesPage from '@pages/BO/international/currencies';
import addCurrencyPage from '@pages/BO/international/currencies/add';

// Import data
import Currencies from '@data/demo/currencies';
import CurrencyData from '@data/faker/currency';
import {
dataCurrencies,
type FakerCurrency,
} from '@prestashop-core/ui-testing';

import {use, expect} from 'chai';
import chaiString from 'chai-string';
Expand All @@ -28,10 +29,10 @@ describe('CLDR : Delete a currency', async () => {
let page: Page;
let numberOfCurrencies: number;

const currencies: CurrencyData[] = [
Currencies.gbp,
Currencies.jpy,
Currencies.usd,
const currencies: FakerCurrency[] = [
dataCurrencies.gbp,
dataCurrencies.jpy,
dataCurrencies.usd,
];

before(async function () {
Expand Down Expand Up @@ -77,7 +78,7 @@ describe('CLDR : Delete a currency', async () => {
expect(numberOfCurrencies).to.be.above(0);
});

currencies.forEach((currency: CurrencyData, index : number) => {
currencies.forEach((currency: FakerCurrency, index : number) => {
it('should go to create new currency page', async function () {
await testContext.addContextItem(this, 'testIdentifier', `goToAddNewCurrencyPage${currency.isoCode}`, baseContext);

Expand Down Expand Up @@ -109,10 +110,13 @@ describe('CLDR : Delete a currency', async () => {
expect(pageTitle).to.contains(localizationPage.pageTitle);
});

it(`should choose '${Currencies.usd.isoCode}' as default currency`, async function () {
it(`should choose '${dataCurrencies.usd.isoCode}' as default currency`, async function () {
await testContext.addContextItem(this, 'testIdentifier', 'setUSDAsDefaultCurrency', baseContext);

const textResult = await localizationPage.setDefaultCurrency(page, `${Currencies.usd.name} (${Currencies.usd.isoCode})`);
const textResult = await localizationPage.setDefaultCurrency(
page,
`${dataCurrencies.usd.name} (${dataCurrencies.usd.isoCode})`,
);
expect(textResult).to.contains(localizationPage.successfulSettingsUpdateMessage);
});

Expand All @@ -125,19 +129,19 @@ describe('CLDR : Delete a currency', async () => {
expect(pageTitle).to.contains(currenciesPage.pageTitle);
});

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

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

// Check number of currencies
const numberOfCurrenciesAfterFilter = await currenciesPage.getNumberOfElementInGrid(page);
expect(numberOfCurrenciesAfterFilter).to.be.equal(1);

// Check currency
const textColumn = await currenciesPage.getTextColumnFromTableCurrency(page, 1, 'iso_code');
expect(textColumn).to.contains(Currencies.usd.isoCode);
expect(textColumn).to.contains(dataCurrencies.usd.isoCode);
});

it('should delete currency', async function () {
Expand All @@ -156,10 +160,13 @@ describe('CLDR : Delete a currency', async () => {
expect(pageTitle).to.contains(localizationPage.pageTitle);
});

it(`should choose '${Currencies.euro.isoCode}' as default currency`, async function () {
it(`should choose '${dataCurrencies.euro.isoCode}' as default currency`, async function () {
await testContext.addContextItem(this, 'testIdentifier', 'setEURAsDefaultCurrency', baseContext);

const textResult = await localizationPage.setDefaultCurrency(page, `${Currencies.euro.name} (${Currencies.euro.isoCode})`);
const textResult = await localizationPage.setDefaultCurrency(
page,
`${dataCurrencies.euro.name} (${dataCurrencies.euro.isoCode})`,
);
expect(textResult).to.contains(localizationPage.successfulSettingsUpdateMessage);
});

Expand All @@ -172,19 +179,19 @@ describe('CLDR : Delete a currency', async () => {
expect(pageTitle).to.contains(currenciesPage.pageTitle);
});

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

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

// Check number of currencies
const numberOfCurrenciesAfterFilter = await currenciesPage.getNumberOfElementInGrid(page);
expect(numberOfCurrenciesAfterFilter).to.be.equal(1);

// Check currency
const textColumn = await currenciesPage.getTextColumnFromTableCurrency(page, 1, 'iso_code');
expect(textColumn).to.contains(Currencies.usd.isoCode);
expect(textColumn).to.contains(dataCurrencies.usd.isoCode);
});

it('should delete currency', async function () {
Expand All @@ -194,7 +201,7 @@ describe('CLDR : Delete a currency', async () => {
expect(result).to.be.equal(currenciesPage.successfulDeleteMessage);
});

it(`should select rows except '${Currencies.euro.isoCode}'`, async function () {
it(`should select rows except '${dataCurrencies.euro.isoCode}'`, async function () {
await testContext.addContextItem(this, 'testIdentifier', 'resetAndSelectRowsExceptEUR', baseContext);

const numberOfCurrenciesAfterDelete = await currenciesPage.resetAndGetNumberOfLines(page);
Expand All @@ -206,7 +213,7 @@ describe('CLDR : Delete a currency', async () => {
for (let numRow = 1; numRow <= numberOfCurrenciesAfterDelete; numRow++) {
const textColumn = await currenciesPage.getTextColumnFromTableCurrency(page, numRow, 'iso_code');

if (textColumn !== Currencies.euro.isoCode) {
if (textColumn !== dataCurrencies.euro.isoCode) {
await currenciesPage.selectRow(page, numRow);
}
}
Expand Down
35 changes: 18 additions & 17 deletions tests/UI/campaigns/cldr/04_searchCurrencyByISOCode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ import localizationPage from '@pages/BO/international/localization';
import currenciesPage from '@pages/BO/international/currencies';
import addCurrencyPage from '@pages/BO/international/currencies/add';

// Import data
import Currencies from '@data/demo/currencies';
import CurrencyData from '@data/faker/currency';
import {
dataCurrencies,
type FakerCurrency,
} from '@prestashop-core/ui-testing';

import {use, expect} from 'chai';
import chaiString from 'chai-string';
Expand All @@ -29,11 +30,11 @@ describe('CLDR : Search a currency by ISO code', async () => {
let page: Page;
let numberOfCurrencies: number;

const installedCurrencies: CurrencyData[] = [
Currencies.usd,
Currencies.pyg,
Currencies.jpy,
Currencies.gbp,
const installedCurrencies: FakerCurrency[] = [
dataCurrencies.usd,
dataCurrencies.pyg,
dataCurrencies.jpy,
dataCurrencies.gbp,
];

before(async function () {
Expand Down Expand Up @@ -79,7 +80,7 @@ describe('CLDR : Search a currency by ISO code', async () => {
expect(numberOfCurrencies).to.be.above(0);
});

installedCurrencies.forEach((currency: CurrencyData, index: number) => {
installedCurrencies.forEach((currency: FakerCurrency, index: number) => {
it('should go to create new currency page', async function () {
await testContext.addContextItem(this, 'testIdentifier', `goToAddNewCurrencyPage${currency.isoCode}`, baseContext);

Expand Down Expand Up @@ -114,7 +115,7 @@ describe('CLDR : Search a currency by ISO code', async () => {

// Check currency
const textColumn = await currenciesPage.getTextColumnFromTableCurrency(page, 1, 'iso_code');
expect(textColumn).to.contains(Currencies.euro.isoCode);
expect(textColumn).to.contains(dataCurrencies.euro.isoCode);
});

it('should filter by iso code "US"', async function () {
Expand All @@ -129,7 +130,7 @@ describe('CLDR : Search a currency by ISO code', async () => {

// Check currency
const textColumn = await currenciesPage.getTextColumnFromTableCurrency(page, 1, 'iso_code');
expect(textColumn).to.contains(Currencies.usd.isoCode);
expect(textColumn).to.contains(dataCurrencies.usd.isoCode);
});

it('should filter by iso code "PY"', async function () {
Expand All @@ -145,10 +146,10 @@ describe('CLDR : Search a currency by ISO code', async () => {

// Check currencies
const textColumnRow1 = await currenciesPage.getTextColumnFromTableCurrency(page, 1, 'iso_code');
expect(textColumnRow1).to.contains(Currencies.jpy.isoCode);
expect(textColumnRow1).to.contains(dataCurrencies.jpy.isoCode);

const textColumnRow2 = await currenciesPage.getTextColumnFromTableCurrency(page, 2, 'iso_code');
expect(textColumnRow2).to.contains(Currencies.pyg.isoCode);
expect(textColumnRow2).to.contains(dataCurrencies.pyg.isoCode);
});

it('should filter by iso code "P"', async function () {
Expand All @@ -164,13 +165,13 @@ describe('CLDR : Search a currency by ISO code', async () => {

// Check currencies
const textColumnRow1 = await currenciesPage.getTextColumnFromTableCurrency(page, 1, 'iso_code');
expect(textColumnRow1).to.contains(Currencies.gbp.isoCode);
expect(textColumnRow1).to.contains(dataCurrencies.gbp.isoCode);

const textColumnRow2 = await currenciesPage.getTextColumnFromTableCurrency(page, 2, 'iso_code');
expect(textColumnRow2).to.contains(Currencies.jpy.isoCode);
expect(textColumnRow2).to.contains(dataCurrencies.jpy.isoCode);

const textColumnRow3 = await currenciesPage.getTextColumnFromTableCurrency(page, 3, 'iso_code');
expect(textColumnRow3).to.contains(Currencies.pyg.isoCode);
expect(textColumnRow3).to.contains(dataCurrencies.pyg.isoCode);
});

it('should filter by iso code "ABC"', async function () {
Expand All @@ -196,7 +197,7 @@ describe('CLDR : Search a currency by ISO code', async () => {
});

// Post-condition - Delete currencies
installedCurrencies.forEach((currency: CurrencyData, index: number) => {
installedCurrencies.forEach((currency: FakerCurrency, index: number) => {
deleteCurrencyTest(currency, `${baseContext}_postTest_${index}`);
});
});
31 changes: 16 additions & 15 deletions tests/UI/campaigns/cldr/05_searchCurrencyByEnableDisable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ import localizationPage from '@pages/BO/international/localization';
import currenciesPage from '@pages/BO/international/currencies';
import addCurrencyPage from '@pages/BO/international/currencies/add';

// Import data
import Currencies from '@data/demo/currencies';
import {
dataCurrencies,
} from '@prestashop-core/ui-testing';

import {use, expect} from 'chai';
import chaiString from 'chai-string';
Expand Down Expand Up @@ -84,31 +85,31 @@ describe('CLDR : Search a currency by enable/disable', async () => {
await testContext.addContextItem(this, 'testIdentifier', 'createOfficialCurrencyUSD', baseContext);

// Create and check successful message
const textResult = await addCurrencyPage.addOfficialCurrency(page, Currencies.usd);
const textResult = await addCurrencyPage.addOfficialCurrency(page, dataCurrencies.usd);
expect(textResult).to.contains(currenciesPage.successfulCreationMessage);

// Check number of currencies after creation
const numberOfCurrenciesAfterCreation = await currenciesPage.getNumberOfElementInGrid(page);
expect(numberOfCurrenciesAfterCreation).to.be.equal(numberOfCurrencies + 1);
});

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

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

// Check number of currencies
const numberOfCurrenciesAfterFilter = await currenciesPage.getNumberOfElementInGrid(page);
expect(numberOfCurrenciesAfterFilter).to.be.equal(1);

// Check currency created
const textColumn = await currenciesPage.getTextColumnFromTableCurrency(page, 1, 'iso_code');
expect(textColumn).to.contains(Currencies.usd.isoCode);
expect(textColumn).to.contains(dataCurrencies.usd.isoCode);
});

it(`should disable currency '${Currencies.usd.isoCode}'`, async function () {
await testContext.addContextItem(this, 'testIdentifier', `disableCurrency${Currencies.usd.isoCode}`, baseContext);
it(`should disable currency '${dataCurrencies.usd.isoCode}'`, async function () {
await testContext.addContextItem(this, 'testIdentifier', `disableCurrency${dataCurrencies.usd.isoCode}`, baseContext);

await currenciesPage.setStatus(page, 1, false);

Expand All @@ -126,7 +127,7 @@ describe('CLDR : Search a currency by enable/disable', async () => {
expect(numberEnabledCurrencies).to.be.eq(1);

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

it('should search Disabled currencies', async function () {
Expand All @@ -139,11 +140,11 @@ describe('CLDR : Search a currency by enable/disable', async () => {
expect(numberEnabledCurrencies).to.be.eq(1);

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

it(`should enable currency '${Currencies.usd.isoCode}'`, async function () {
await testContext.addContextItem(this, 'testIdentifier', `enableCurrency${Currencies.usd.isoCode}`, baseContext);
it(`should enable currency '${dataCurrencies.usd.isoCode}'`, async function () {
await testContext.addContextItem(this, 'testIdentifier', `enableCurrency${dataCurrencies.usd.isoCode}`, baseContext);

await currenciesPage.setStatus(page, 1, true);

Expand All @@ -164,7 +165,7 @@ describe('CLDR : Search a currency by enable/disable', async () => {
await testContext.addContextItem(this, 'testIdentifier', 'createOfficialCurrencyGBP', baseContext);

// Create and check successful message
const textResult = await addCurrencyPage.addOfficialCurrency(page, Currencies.gbp);
const textResult = await addCurrencyPage.addOfficialCurrency(page, dataCurrencies.gbp);
expect(textResult).to.contains(currenciesPage.successfulCreationMessage);

// Check number of currencies after creation
Expand All @@ -180,8 +181,8 @@ describe('CLDR : Search a currency by enable/disable', async () => {
});

// Post-condition - Delete currency USD
deleteCurrencyTest(Currencies.usd, `${baseContext}_postTest_1`);
deleteCurrencyTest(dataCurrencies.usd, `${baseContext}_postTest_1`);

// Post-condition - Delete currency GBP
deleteCurrencyTest(Currencies.gbp, `${baseContext}_postTest_2`);
deleteCurrencyTest(dataCurrencies.gbp, `${baseContext}_postTest_2`);
});
Loading

0 comments on commit a574a1e

Please sign in to comment.