Skip to content

Commit

Permalink
Merge pull request #36393 from Progi1984/test3615
Browse files Browse the repository at this point in the history
Functional Tests : BO - Shop Parameters - Search : Blacklisted words
  • Loading branch information
nesrineabdmouleh committed Jun 21, 2024
2 parents da70a44 + 14fcfe5 commit 0e52338
Show file tree
Hide file tree
Showing 9 changed files with 261 additions and 604 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import testContext from '@utils/testContext';
import loginCommon from '@commonTests/BO/loginBO';

// Import pages
import searchPage from '@pages/BO/shopParameters/search';
import addSearchPage from '@pages/BO/shopParameters/search/add';

import {expect} from 'chai';
import type {BrowserContext, Page} from 'playwright';
import {
boDashboardPage,
boSearchPage,
FakerSearchAlias,
utilsPlaywright,
} from '@prestashop-core/ui-testing';
Expand Down Expand Up @@ -54,14 +54,14 @@ describe('BO - Shop Parameters - Search : Create, update and delete search in BO
boDashboardPage.searchLink,
);

const pageTitle = await searchPage.getPageTitle(page);
expect(pageTitle).to.contains(searchPage.pageTitle);
const pageTitle = await boSearchPage.getPageTitle(page);
expect(pageTitle).to.contains(boSearchPage.pageTitle);
});

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

numberOfSearch = await searchPage.resetAndGetNumberOfLines(page);
numberOfSearch = await boSearchPage.resetAndGetNumberOfLines(page);
expect(numberOfSearch).to.be.above(0);
});

Expand All @@ -70,7 +70,7 @@ describe('BO - Shop Parameters - Search : Create, update and delete search in BO
it('should go to add new search page', async function () {
await testContext.addContextItem(this, 'testIdentifier', 'goToAddAliasPage', baseContext);

await searchPage.goToAddNewAliasPage(page);
await boSearchPage.goToAddNewAliasPage(page);

const pageTitle = await addSearchPage.getPageTitle(page);
expect(pageTitle).to.contains(addSearchPage.pageTitleCreate);
Expand All @@ -80,9 +80,9 @@ describe('BO - Shop Parameters - Search : Create, update and delete search in BO
await testContext.addContextItem(this, 'testIdentifier', 'createAlias', baseContext);

const textResult = await addSearchPage.setAlias(page, createAliasData);
expect(textResult).to.contains(searchPage.successfulCreationMessage);
expect(textResult).to.contains(boSearchPage.successfulCreationMessage);

const numberOfElementAfterCreation = await searchPage.getNumberOfElementInGrid(page);
const numberOfElementAfterCreation = await boSearchPage.getNumberOfElementInGrid(page);
expect(numberOfElementAfterCreation).to.be.equal(numberOfSearch + 1);
});
});
Expand All @@ -92,17 +92,17 @@ describe('BO - Shop Parameters - Search : Create, update and delete search in BO
it('should filter list by name', async function () {
await testContext.addContextItem(this, 'testIdentifier', 'filterForUpdate', baseContext);

await searchPage.resetFilter(page);
await searchPage.filterTable(page, 'input', 'alias', createAliasData.alias);
await boSearchPage.resetFilter(page);
await boSearchPage.filterTable(page, 'input', 'alias', createAliasData.alias);

const textEmail = await searchPage.getTextColumn(page, 1, 'alias');
const textEmail = await boSearchPage.getTextColumn(page, 1, 'alias');
expect(textEmail).to.contains(createAliasData.alias);
});

it('should go to edit alias page', async function () {
await testContext.addContextItem(this, 'testIdentifier', 'goToEditAliasPage', baseContext);

await searchPage.gotoEditAliasPage(page, 1);
await boSearchPage.gotoEditAliasPage(page, 1);

const pageTitle = await addSearchPage.getPageTitle(page);
expect(pageTitle).to.contains(addSearchPage.pageTitleEdit);
Expand All @@ -112,9 +112,9 @@ describe('BO - Shop Parameters - Search : Create, update and delete search in BO
await testContext.addContextItem(this, 'testIdentifier', 'updateAlias', baseContext);

const textResult = await addSearchPage.setAlias(page, editSearchData);
expect(textResult).to.contains(searchPage.successfulUpdateMessage);
expect(textResult).to.contains(boSearchPage.successfulUpdateMessage);

const numberOfSearchAfterUpdate = await searchPage.resetAndGetNumberOfLines(page);
const numberOfSearchAfterUpdate = await boSearchPage.resetAndGetNumberOfLines(page);
expect(numberOfSearchAfterUpdate).to.be.equal(numberOfSearch + 1);
});
});
Expand All @@ -124,20 +124,20 @@ describe('BO - Shop Parameters - Search : Create, update and delete search in BO
it('should filter list by name', async function () {
await testContext.addContextItem(this, 'testIdentifier', 'filterForDelete', baseContext);

await searchPage.resetFilter(page);
await searchPage.filterTable(page, 'input', 'alias', createAliasData.alias);
await boSearchPage.resetFilter(page);
await boSearchPage.filterTable(page, 'input', 'alias', createAliasData.alias);

const textEmail = await searchPage.getTextColumn(page, 1, 'alias');
const textEmail = await boSearchPage.getTextColumn(page, 1, 'alias');
expect(textEmail).to.contains(createAliasData.alias);
});

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

const textResult = await searchPage.deleteAlias(page, 1);
expect(textResult).to.contains(searchPage.successfulDeleteMessage);
const textResult = await boSearchPage.deleteAlias(page, 1);
expect(textResult).to.contains(boSearchPage.successfulDeleteMessage);

const numberOfSearchAfterDelete = await searchPage.resetAndGetNumberOfLines(page);
const numberOfSearchAfterDelete = await boSearchPage.resetAndGetNumberOfLines(page);
expect(numberOfSearchAfterDelete).to.be.equal(numberOfSearch);
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import testContext from '@utils/testContext';
import loginCommon from '@commonTests/BO/loginBO';

// Import pages
// Import BO pages
import searchPage from '@pages/BO/shopParameters/search';
// Import FO pages
import {homePage} from '@pages/FO/classic/home';
import {searchResultsPage} from '@pages/FO/classic/searchResults';
Expand All @@ -15,6 +13,7 @@ import {expect} from 'chai';
import type {BrowserContext, Page} from 'playwright';
import {
boDashboardPage,
boSearchPage,
utilsPlaywright,
} from '@prestashop-core/ui-testing';

Expand Down Expand Up @@ -47,21 +46,21 @@ describe('BO - Shop Parameters - Search : Fuzzy search', async () => {
boDashboardPage.searchLink,
);

const pageTitle = await searchPage.getPageTitle(page);
expect(pageTitle).to.contains(searchPage.pageTitle);
const pageTitle = await boSearchPage.getPageTitle(page);
expect(pageTitle).to.contains(boSearchPage.pageTitle);
});

it('should disable the Fuzzy Search', async function () {
await testContext.addContextItem(this, 'testIdentifier', 'disableFuzzySearch', baseContext);

const textResult = await searchPage.setFuzzySearch(page, false);
expect(textResult).to.be.eq(searchPage.settingsUpdateMessage);
const textResult = await boSearchPage.setFuzzySearch(page, false);
expect(textResult).to.be.eq(boSearchPage.settingsUpdateMessage);
});

it('should go to the Front Office', async function () {
await testContext.addContextItem(this, 'testIdentifier', 'goToFoWoFuzzy', baseContext);

await searchPage.goToFo(page);
await boSearchPage.goToFo(page);

const pageTitle = await homePage.getPageTitle(page);
expect(pageTitle).to.be.eq(homePage.pageTitle);
Expand Down Expand Up @@ -110,21 +109,21 @@ describe('BO - Shop Parameters - Search : Fuzzy search', async () => {
boDashboardPage.searchLink,
);

const pageTitle = await searchPage.getPageTitle(page);
expect(pageTitle).to.contains(searchPage.pageTitle);
const pageTitle = await boSearchPage.getPageTitle(page);
expect(pageTitle).to.contains(boSearchPage.pageTitle);
});

it('should disable the Fuzzy Search', async function () {
await testContext.addContextItem(this, 'testIdentifier', 'enableFuzzySearch', baseContext);

const textResult = await searchPage.setFuzzySearch(page, true);
expect(textResult).to.be.eq(searchPage.settingsUpdateMessage);
const textResult = await boSearchPage.setFuzzySearch(page, true);
expect(textResult).to.be.eq(boSearchPage.settingsUpdateMessage);
});

it('should go to the Front Office', async function () {
await testContext.addContextItem(this, 'testIdentifier', 'goToFoWFuzzy', baseContext);

await searchPage.goToFo(page);
await boSearchPage.goToFo(page);

const pageTitle = await homePage.getPageTitle(page);
expect(pageTitle).to.be.eq(homePage.pageTitle);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
// Import utils
import testContext from '@utils/testContext';

// Import login steps
import loginCommon from '@commonTests/BO/loginBO';

// Import pages
// Import BO pages
import boProductsPage from '@pages/BO/catalog/products';
import boProductsCreatePage from '@pages/BO/catalog/products/add';
// Import FO pages
import {homePage} from '@pages/FO/classic/home';
import {searchResultsPage} from '@pages/FO/classic/searchResults';

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

const baseContext: string = 'functional_BO_shopParameters_search_search_editSearchSettings_blacklistedWords';

describe('BO - Shop Parameters - Search : Blacklisted words', async () => {
const searchWord: string = 'does';

let browserContext: BrowserContext;
let page: Page;
let blacklistedWordsListEN: string;

// before and after functions
before(async function () {
browserContext = await utilsPlaywright.createBrowserContext(this.browser);
page = await utilsPlaywright.newTab(browserContext);
});

after(async () => {
await utilsPlaywright.closeBrowserContext(browserContext);
});

it('should login in BO', async function () {
await loginCommon.loginBO(this, page);
});

it('should go to \'Shop Parameters > Search\' page', async function () {
await testContext.addContextItem(this, 'testIdentifier', 'goToSearchPage', baseContext);

await boDashboardPage.goToSubMenu(
page,
boDashboardPage.shopParametersParentLink,
boDashboardPage.searchLink,
);

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

it('should verify that the Blacklisted words list is not empty', async function () {
await testContext.addContextItem(this, 'testIdentifier', 'checkBlacklistedWordsList', baseContext);

blacklistedWordsListEN = await boSearchPage.getBlacklistedWords(page, dataLanguages.english.id);
expect(blacklistedWordsListEN.length).to.be.gt(0);
expect(blacklistedWordsListEN).to.contains(searchWord);

const blacklistedWordsListFR = await boSearchPage.getBlacklistedWords(page, dataLanguages.french.id);
expect(blacklistedWordsListFR.length).to.be.gt(0);
});

it('should go to \'Catalog > Products\' page', async function () {
await testContext.addContextItem(this, 'testIdentifier', 'goToCatalogProducts', baseContext);

await boDashboardPage.goToSubMenu(page, boDashboardPage.catalogParentLink, boDashboardPage.productsLink);
await boProductsPage.closeSfToolBar(page);

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

it('should create a standard product', async function () {
await testContext.addContextItem(this, 'testIdentifier', 'clickAddNewProduct', baseContext);

const isModalVisible = await boProductsPage.clickOnNewProductButton(page);
expect(isModalVisible).to.eq(true);

await boProductsPage.selectProductType(page, 'standard');
await boProductsPage.clickOnAddNewProduct(page);

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

it('should set the title product and publish', async function () {
await testContext.addContextItem(this, 'testIdentifier', 'setTitleProduct', baseContext);

await boProductsCreatePage.setProductName(page, `Test ${searchWord}`);
await boProductsCreatePage.setProductStatus(page, true);

const updateProductMessage = await boProductsCreatePage.saveProduct(page);
expect(updateProductMessage).to.equal(boProductsCreatePage.successfulUpdateMessage);
});

it('should go to the FrontOffice', async function () {
await testContext.addContextItem(this, 'testIdentifier', 'viewMyShop', baseContext);

page = await boProductsCreatePage.viewMyShop(page);
await homePage.changeLanguage(page, 'en');

const isHomePage = await homePage.isHomePage(page);
expect(isHomePage, 'Fail to open FO home page').to.eq(true);
});

it(`should search the word "${searchWord}"`, async function () {
await testContext.addContextItem(this, 'testIdentifier', 'searchWordWithError', baseContext);

await homePage.searchProduct(page, searchWord);

const pageTitle = await searchResultsPage.getPageTitle(page);
expect(pageTitle).to.equal(searchResultsPage.pageTitle);

const hasResults = await searchResultsPage.hasResults(page);
expect(hasResults).to.eq(false);

const searchInputValue = await searchResultsPage.getSearchValue(page);
expect(searchInputValue).to.be.equal(searchWord);
});

it('should return to \'Shop Parameters > Search\' page', async function () {
await testContext.addContextItem(this, 'testIdentifier', 'returnToSearchPage', baseContext);

page = await searchResultsPage.changePage(browserContext, 0);
await boDashboardPage.goToSubMenu(
page,
boDashboardPage.shopParametersParentLink,
boDashboardPage.searchLink,
);

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

it(`should remove the word ${searchWord} from the list`, async function () {
await testContext.addContextItem(this, 'testIdentifier', 'removeWordFromList', baseContext);

const textResult = await boSearchPage.setBlacklistedWords(
page,
dataLanguages.english.id,
blacklistedWordsListEN.replace(`${searchWord}|`, ''),
);
expect(textResult).to.be.eq(boSearchPage.settingsUpdateMessage);
});

it(`should search the word "${searchWord}"`, async function () {
await testContext.addContextItem(this, 'testIdentifier', 'searchWordWithSuccess', baseContext);

page = await searchResultsPage.changePage(browserContext, 1);
await page.reload();

const pageTitle = await searchResultsPage.getPageTitle(page);
expect(pageTitle).to.equal(searchResultsPage.pageTitle);

const hasResults = await searchResultsPage.hasResults(page);
expect(hasResults).to.eq(true);

const searchInputValue = await searchResultsPage.getSearchValue(page);
expect(searchInputValue).to.be.equal(searchWord);
});

it('should reset the list', async function () {
await testContext.addContextItem(this, 'testIdentifier', 'resetList', baseContext);

page = await searchResultsPage.changePage(browserContext, 0);

const textResult = await boSearchPage.setBlacklistedWords(page, dataLanguages.english.id, blacklistedWordsListEN);
expect(textResult).to.be.eq(boSearchPage.settingsUpdateMessage);
});
});
Loading

0 comments on commit 0e52338

Please sign in to comment.