Skip to content

Commit

Permalink
Merge pull request PrestaShop#37055 from Progi1984/test9830
Browse files Browse the repository at this point in the history
Functional Tests : BO - Shop Parameters - Search : Maximum word length (in characters)
  • Loading branch information
jolelievre authored Oct 1, 2024
2 parents 889343c + 5a1c0a1 commit f87678a
Show file tree
Hide file tree
Showing 26 changed files with 322 additions and 632 deletions.
1 change: 1 addition & 0 deletions .github/actions/ui-test/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,6 @@ runs:
URL_API: ${{ (inputs.ENABLE_SSL == 'false') && 'http://localhost:8001/admin-api/' || 'https://localhost:8002/admin-api/' }}
URL_INSTALL: ${{ (inputs.ENABLE_SSL == 'false') && 'http://localhost:8001/install-dev/' || 'https://localhost:8002/install-dev/' }}
DB_SERVER: ${{ inputs.DB_SERVER }}
LANG: 'en-GB'
shell: bash
run: npm run test:${{ inputs.TEST_CAMPAIGN }}
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ import loginCommon from '@commonTests/BO/loginBO';

// Import pages
import createProductsPage from '@pages/BO/catalog/products/add';
import descriptionTab from '@pages/BO/catalog/products/add/descriptionTab';

import {expect} from 'chai';
import type {APIRequestContext, BrowserContext, Page} from 'playwright';
import {
boApiClientsPage,
boApiClientsCreatePage,
boProductsPage,
boProductsCreateTabDescriptionPage,
boDashboardPage,
dataLanguages,
FakerAPIClient,
Expand Down Expand Up @@ -251,14 +251,14 @@ describe('API : POST /product', async () => {
it('should check the JSON Response : `description` (EN)', async function () {
await testContext.addContextItem(this, 'testIdentifier', 'checkResponseDescriptionsEN', baseContext);

const value = await descriptionTab.getValue(page, 'description', dataLanguages.english.id.toString());
const value = await boProductsCreateTabDescriptionPage.getValue(page, 'description', dataLanguages.english.id.toString());
expect(value).to.equal(jsonResponse.descriptions[dataLanguages.english.id]);
});

it('should check the JSON Response : `description` (FR)', async function () {
await testContext.addContextItem(this, 'testIdentifier', 'checkResponseDescriptionsFR', baseContext);

const value = await descriptionTab.getValue(page, 'description', dataLanguages.french.id.toString());
const value = await boProductsCreateTabDescriptionPage.getValue(page, 'description', dataLanguages.french.id.toString());
expect(value).to.equal(jsonResponse.descriptions[dataLanguages.french.id]);
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import loginCommon from '@commonTests/BO/loginBO';

// Import pages
import createProductsPage from '@pages/BO/catalog/products/add';
import descriptionTab from '@pages/BO/catalog/products/add/descriptionTab';

import {expect} from 'chai';
import type {APIRequestContext, BrowserContext, Page} from 'playwright';
Expand All @@ -16,6 +15,7 @@ import {
boApiClientsCreatePage,
boDashboardPage,
boProductsPage,
boProductsCreateTabDescriptionPage,
dataLanguages,
dataProducts,
FakerAPIClient,
Expand Down Expand Up @@ -186,10 +186,18 @@ describe('API : GET /product/{productId}', async () => {
productNameFr = await createProductsPage.getProductName(page, dataLanguages.french.isoCode);
expect(productNameFr).to.be.a('string');

productDescriptionEn = await descriptionTab.getValue(page, 'description', dataLanguages.english.id.toString());
productDescriptionEn = await boProductsCreateTabDescriptionPage.getValue(
page,
'description',
dataLanguages.english.id.toString(),
);
expect(productDescriptionEn).to.be.a('string');

productDescriptionFr = await descriptionTab.getValue(page, 'description', dataLanguages.french.id.toString());
productDescriptionFr = await boProductsCreateTabDescriptionPage.getValue(
page,
'description',
dataLanguages.french.id.toString(),
);
expect(productDescriptionFr).to.be.a('string');
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {createProductTest, deleteProductTest} from '@commonTests/BO/catalog/prod

// Import pages
import createProductsPage from '@pages/BO/catalog/products/add';
import descriptionTab from '@pages/BO/catalog/products/add/descriptionTab';

import {expect} from 'chai';
import type {APIRequestContext, BrowserContext, Page} from 'playwright';
Expand All @@ -17,6 +16,7 @@ import {
boApiClientsCreatePage,
boDashboardPage,
boProductsPage,
boProductsCreateTabDescriptionPage,
dataLanguages,
FakerAPIClient,
FakerProduct,
Expand Down Expand Up @@ -244,8 +244,16 @@ describe('API : PATCH /product/{productId}', async () => {
[dataLanguages.french.id]: valuePropertyFR,
}).to.deep.equal(data.propertyValue);
} else if (data.propertyName === 'descriptions') {
const valuePropertyEN = await descriptionTab.getValue(page, 'description', dataLanguages.english.id.toString());
const valuePropertyFR = await descriptionTab.getValue(page, 'description', dataLanguages.french.id.toString());
const valuePropertyEN = await boProductsCreateTabDescriptionPage.getValue(
page,
'description',
dataLanguages.english.id.toString(),
);
const valuePropertyFR = await boProductsCreateTabDescriptionPage.getValue(
page,
'description',
dataLanguages.french.id.toString(),
);
expect({
[dataLanguages.english.id]: valuePropertyEN,
[dataLanguages.french.id]: valuePropertyFR,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import loginCommon from '@commonTests/BO/loginBO';

// Import pages
import createProductsPage from '@pages/BO/catalog/products/add';
import descriptionTab from '@pages/BO/catalog/products/add/descriptionTab';

import {expect} from 'chai';
import fs from 'fs';
Expand All @@ -18,6 +17,7 @@ import {
boApiClientsCreatePage,
boDashboardPage,
boProductsPage,
boProductsCreateTabDescriptionPage,
dataLanguages,
FakerAPIClient,
FakerProduct,
Expand Down Expand Up @@ -239,10 +239,10 @@ describe('API : POST /product/{productId}/image', async () => {
const pageTitle: string = await createProductsPage.getPageTitle(page);
expect(pageTitle).to.contains(createProductsPage.pageTitle);

const numImages = await descriptionTab.getNumberOfImages(page);
const numImages = await boProductsCreateTabDescriptionPage.getNumberOfImages(page);
expect(numImages).to.be.equals(1);

productImageInformation = await descriptionTab.getProductImageInformation(page, 1);
productImageInformation = await boProductsCreateTabDescriptionPage.getProductImageInformation(page, 1);
});

it('should check the JSON Response : `imageId`', async function () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import loginCommon from '@commonTests/BO/loginBO';

// Import pages
import createProductsPage from '@pages/BO/catalog/products/add';
import descriptionTab from '@pages/BO/catalog/products/add/descriptionTab';

import {expect} from 'chai';
import type {APIRequestContext, BrowserContext, Page} from 'playwright';
Expand All @@ -16,6 +15,7 @@ import {
boApiClientsCreatePage,
boDashboardPage,
boProductsPage,
boProductsCreateTabDescriptionPage,
dataLanguages,
dataProducts,
FakerAPIClient,
Expand Down Expand Up @@ -206,15 +206,15 @@ describe('API : GET /product/{productId}/images', async () => {
const pageTitle: string = await createProductsPage.getPageTitle(page);
expect(pageTitle).to.contains(createProductsPage.pageTitle);

const numImages = await descriptionTab.getNumberOfImages(page);
const numImages = await boProductsCreateTabDescriptionPage.getNumberOfImages(page);
expect(numImages).to.be.equals(jsonResponse.length);
});

it('should fetch images informations', async function () {
await testContext.addContextItem(this, 'testIdentifier', 'checkJSONItems', baseContext);

for (let idxItem: number = 0; idxItem < jsonResponse.length; idxItem++) {
const productImageInformation = await descriptionTab.getProductImageInformation(page, idxItem + 1);
const productImageInformation = await boProductsCreateTabDescriptionPage.getProductImageInformation(page, idxItem + 1);

expect(productImageInformation.id).to.equal(jsonResponse[idxItem].imageId);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import loginCommon from '@commonTests/BO/loginBO';

// Import pages
import createProductsPage from '@pages/BO/catalog/products/add';
import descriptionTab from '@pages/BO/catalog/products/add/descriptionTab';

import {expect} from 'chai';
import type {APIRequestContext, BrowserContext, Page} from 'playwright';
Expand All @@ -16,6 +15,7 @@ import {
boApiClientsCreatePage,
boDashboardPage,
boProductsPage,
boProductsCreateTabDescriptionPage,
dataLanguages,
dataProducts,
FakerAPIClient,
Expand Down Expand Up @@ -206,7 +206,7 @@ describe('API : GET /product/image/{imageId}', async () => {
it('should fetch images informations', async function () {
await testContext.addContextItem(this, 'testIdentifier', 'checkJSONItems', baseContext);

const productImageInformation = await descriptionTab.getProductImageInformation(page, 1);
const productImageInformation = await boProductsCreateTabDescriptionPage.getProductImageInformation(page, 1);

expect(productImageInformation.id).to.equal(jsonResponse.imageId);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import loginCommon from '@commonTests/BO/loginBO';

// Import pages
import createProductsPage from '@pages/BO/catalog/products/add';
import descriptionTab from '@pages/BO/catalog/products/add/descriptionTab';

import {expect} from 'chai';
import fs from 'fs';
Expand All @@ -18,6 +17,7 @@ import {
boApiClientsCreatePage,
boDashboardPage,
boProductsPage,
boProductsCreateTabDescriptionPage,
dataLanguages,
FakerAPIClient,
FakerProduct,
Expand Down Expand Up @@ -188,23 +188,23 @@ describe('API : POST /product/image/{imageId}', async () => {
const pageTitle: string = await createProductsPage.getPageTitle(page);
expect(pageTitle).to.contains(createProductsPage.pageTitle);

const numImages = await descriptionTab.getNumberOfImages(page);
const numImages = await boProductsCreateTabDescriptionPage.getNumberOfImages(page);
expect(numImages).to.be.equals(0);
});

it('should add image', async function () {
await testContext.addContextItem(this, 'testIdentifier', 'addImage', baseContext);

await descriptionTab.addProductImages(page, [productImageCreated]);
await boProductsCreateTabDescriptionPage.addProductImages(page, [productImageCreated]);

const numOfImages = await descriptionTab.getNumberOfImages(page);
const numOfImages = await boProductsCreateTabDescriptionPage.getNumberOfImages(page);
expect(numOfImages).to.eq(1);
});

it('should set image information', async function () {
await testContext.addContextItem(this, 'testIdentifier', 'setImageInformation', baseContext);

const message = await descriptionTab.setProductImageInformation(
const message = await boProductsCreateTabDescriptionPage.setProductImageInformation(
page,
1,
true,
Expand All @@ -214,9 +214,9 @@ describe('API : POST /product/image/{imageId}', async () => {
true,
true,
);
expect(message).to.be.eq(descriptionTab.settingUpdatedMessage);
expect(message).to.be.eq(boProductsCreateTabDescriptionPage.settingUpdatedMessage);

productImageInformation = await descriptionTab.getProductImageInformation(page, 1);
productImageInformation = await boProductsCreateTabDescriptionPage.getProductImageInformation(page, 1);
});
});

Expand Down Expand Up @@ -294,7 +294,7 @@ describe('API : POST /product/image/{imageId}', async () => {

await boProductsPage.reloadPage(page);

productImageInformation = await descriptionTab.getProductImageInformation(page, 1);
productImageInformation = await boProductsCreateTabDescriptionPage.getProductImageInformation(page, 1);
});

it('should check the JSON Response : `imageId`', async function () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import loginCommon from '@commonTests/BO/loginBO';

// Import pages
import createProductsPage from '@pages/BO/catalog/products/add';
import descriptionTab from '@pages/BO/catalog/products/add/descriptionTab';
import detailsTab from '@pages/BO/catalog/products/add/detailsTab';
import pricingTab from '@pages/BO/catalog/products/add/pricingTab';

Expand All @@ -17,6 +16,7 @@ import {faker} from '@faker-js/faker';
import {
boDashboardPage,
boProductsPage,
boProductsCreateTabDescriptionPage,
boProductsCreateTabStocksPage,
FakerProduct,
type ProductHeaderSummary,
Expand Down Expand Up @@ -259,23 +259,29 @@ describe('BO - Catalog - Products : Header', async () => {
it('should add image', async function () {
await testContext.addContextItem(this, 'testIdentifier', 'addImage', baseContext);

await descriptionTab.addProductImages(page, [productCoverImage]);
await boProductsCreateTabDescriptionPage.addProductImages(page, [productCoverImage]);

const numOfImages = await descriptionTab.getNumberOfImages(page);
const numOfImages = await boProductsCreateTabDescriptionPage.getNumberOfImages(page);
expect(numOfImages).to.eq(2);
});

it('should set image information', async function () {
await testContext.addContextItem(this, 'testIdentifier', 'setImageInformation', baseContext);

const message = await descriptionTab.setProductImageInformation(page, 2, true, 'Caption EN', 'Caption FR');
expect(message).to.be.eq(descriptionTab.settingUpdatedMessage);
const message = await boProductsCreateTabDescriptionPage.setProductImageInformation(
page,
2,
true,
'Caption EN',
'Caption FR',
);
expect(message).to.be.eq(boProductsCreateTabDescriptionPage.settingUpdatedMessage);
});

it('should check image has changed', async function () {
await testContext.addContextItem(this, 'testIdentifier', 'checkImageHasChanged', baseContext);

await descriptionTab.reloadPage(page);
await boProductsCreateTabDescriptionPage.reloadPage(page);
const productHeaderSummary = await createProductsPage.getProductHeaderSummary(page);

expect(productHeaderSummary.imageUrl).to.be.not.eq(productHeaderSummaryInitial.imageUrl);
Expand Down
Loading

0 comments on commit f87678a

Please sign in to comment.