Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Functional tests - Add new tests to dispaly tags in 'FO>Product' page in (Classic & Hummingbird) theme #36103

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,202 @@
// Import utils
import helper from '@utils/helpers';
import testContext from '@utils/testContext';
import files from '@utils/files';

// Import common tests
import {deleteProductTest} from '@commonTests/BO/catalog/product';

// Import BO pages
import loginCommon from '@commonTests/BO/loginBO';
import dashboardPage from '@pages/BO/dashboard';
import productsPage from '@pages/BO/catalog/products';
import createProductPage from '@pages/BO/catalog/products/add';
import optionsTab from '@pages/BO/catalog/products/add/optionsTab';

// Import FO pages
import {productPage as foProductPage} from '@pages/FO/classic/product';
import {homePage} from '@pages/FO/classic/home';
import {categoryPage} from '@pages/FO/classic/category';

// Import data
import ProductData from '@data/faker/product';

import {expect} from 'chai';
import type {BrowserContext, Page} from 'playwright';

const baseContext: string = 'functional_FO_classic_productPage_productPage_displayTag';

describe('FO - Product page - Product page : Display tag products', async () => {
let browserContext: BrowserContext;
let page: Page;
let productsNumber: number;
// Data to create pack of products
const newProductData: ProductData = new ProductData({
type: 'pack',
coverImage: 'cover.jpg',
thumbImage: 'thumb.jpg',
pack: [
{
reference: 'demo_11',
quantity: 10,
},
],
taxRule: 'FR Taux standard (20%)',
tax: 20,
quantity: 0,
minimumQuantity: 0,
status: true,
});

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

if (newProductData.coverImage) {
await files.generateImage(newProductData.coverImage);
}
if (newProductData.thumbImage) {
await files.generateImage(newProductData.thumbImage);
}
});

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

if (newProductData.coverImage) {
await files.deleteFile(newProductData.coverImage);
}
if (newProductData.thumbImage) {
await files.deleteFile(newProductData.thumbImage);
}
});

describe('Create pack of products', async () => {
it('should login in BO', async function () {
await loginCommon.loginBO(this, page);
});

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

await dashboardPage.goToSubMenu(
page,
dashboardPage.catalogParentLink,
dashboardPage.productsLink,
);

await productsPage.closeSfToolBar(page);

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

it('should click on \'New product\' button and check new product modal', async function () {
await testContext.addContextItem(this, 'testIdentifier', 'clickOnNewProductButton', baseContext);

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

it('should choose \'Pack of products\'', async function () {
await testContext.addContextItem(this, 'testIdentifier', 'choosePackOfProducts', baseContext);

await productsPage.selectProductType(page, newProductData.type);

const productTypeDescription = await productsPage.getProductDescription(page);
expect(productTypeDescription).to.contains(productsPage.packOfProductsDescription);
});

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

await productsPage.clickOnAddNewProduct(page);

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

it('should create the product', async function () {
await testContext.addContextItem(this, 'testIdentifier', 'createPackOfProducts', baseContext);

await createProductPage.closeSfToolBar(page);

const createProductMessage = await createProductPage.setProduct(page, newProductData);
expect(createProductMessage).to.equal(createProductPage.successfulUpdateMessage);
});

it('should choose the option \'Web only\'', async function () {
await testContext.addContextItem(this, 'testIdentifier', 'setWebOnly', baseContext);

await createProductPage.goToTab(page, 'options');
await optionsTab.setWebOnly(page, true);

const message = await createProductPage.saveProduct(page);
expect(message).to.equal(createProductPage.successfulUpdateMessage);
});
});

describe('Check tags on FO Home page and Product page', async () => {
it('should view my shop', async function () {
await testContext.addContextItem(this, 'testIdentifier', 'viewMyShop', baseContext);

// Click on preview button
page = await createProductPage.viewMyShop(page);
await foProductPage.changeLanguage(page, 'en');

const isHomePage = await homePage.isHomePage(page);
expect(isHomePage, 'Home page is not displayed').to.eq(true);
});

it('should go to all products page', async function () {
await testContext.addContextItem(this, 'testIdentifier', 'goToAllProductsPage', baseContext);

await homePage.goToAllProductsPage(page);

const isCategoryPageVisible = await categoryPage.isCategoryPage(page);
expect(isCategoryPageVisible, 'Home category page was not opened').to.eq(true);
});

it('should go to the second product page', async function () {
await testContext.addContextItem(this, 'testIdentifier', 'goToSecondProductsPage', baseContext);

await categoryPage.goToNextPage(page);

productsNumber = await categoryPage.getProductsNumber(page);
expect(productsNumber).to.not.equal(19);
});

it('should check the tag \'New, pack, out-of-stock and Online only\' for the created product', async function () {
await testContext.addContextItem(this, 'testIdentifier', 'checkTagsInAllProductPage', baseContext);

const flagText = await categoryPage.getProductTag(page, productsNumber - 12);
expect(flagText).to.contains('Online only')
.and.to.contain('New')
.and.to.contain('Pack')
.and.to.contain('Out-of-Stock');
});

it('should go to the created product page', async function () {
await testContext.addContextItem(this, 'testIdentifier', 'goToCreatedProductPage', baseContext);

await categoryPage.goToProductPage(page, productsNumber - 12);

const pageTitle = await foProductPage.getPageTitle(page);
expect(pageTitle).to.contains(newProductData.name);
});

it('should check the tag \'New, pack, out-of-stock and Online only\'', async function () {
await testContext.addContextItem(this, 'testIdentifier', 'checkOnSaleFlag', baseContext);

const flagText = await foProductPage.getProductTag(page);
expect(flagText).to.contains('Online only')
.and.to.contain('New')
.and.to.contain('Pack')
.and.to.contain('Out-of-Stock');
});
});

// Post-condition: Delete specific price
deleteProductTest(newProductData, `${baseContext}_postTest`);
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
// Import utils
import helper from '@utils/helpers';
import testContext from '@utils/testContext';
import files from '@utils/files';

// Import common tests
import {deleteProductTest} from '@commonTests/BO/catalog/product';

// Import BO pages
import loginCommon from '@commonTests/BO/loginBO';
import dashboardPage from '@pages/BO/dashboard';
import productsPage from '@pages/BO/catalog/products';
import createProductPage from '@pages/BO/catalog/products/add';

// Import FO pages
import {productPage as foProductPage} from '@pages/FO/classic/product';
import {homePage} from '@pages/FO/classic/home';
import {categoryPage} from '@pages/FO/classic/category';

// Import data
import ProductData from '@data/faker/product';

import {expect} from 'chai';
import type {BrowserContext, Page} from 'playwright';

const baseContext: string = 'functional_FO_classic_productPage_productPage_displayOnSaleLabel';

describe('FO - Product page - Product page : Display on sale label', async () => {
let browserContext: BrowserContext;
let page: Page;
let productsNumber: number;
// Data to create pack of products
const newProductData: ProductData = new ProductData({
type: 'standard',
coverImage: 'cover.jpg',
thumbImage: 'thumb.jpg',
onSale: true,
taxRule: 'FR Taux standard (20%)',
tax: 20,
quantity: 0,
minimumQuantity: 0,
status: true,
});

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

if (newProductData.coverImage) {
await files.generateImage(newProductData.coverImage);
}
if (newProductData.thumbImage) {
await files.generateImage(newProductData.thumbImage);
}
});

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

if (newProductData.coverImage) {
await files.deleteFile(newProductData.coverImage);
}
if (newProductData.thumbImage) {
await files.deleteFile(newProductData.thumbImage);
}
});

describe('Create new product', async () => {
it('should login in BO', async function () {
await loginCommon.loginBO(this, page);
});

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

await dashboardPage.goToSubMenu(
page,
dashboardPage.catalogParentLink,
dashboardPage.productsLink,
);

await productsPage.closeSfToolBar(page);

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

it('should click on \'New product\' button and check new product modal', async function () {
await testContext.addContextItem(this, 'testIdentifier', 'clickOnNewProductButton', baseContext);

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

it('should choose \'Standard\'', async function () {
await testContext.addContextItem(this, 'testIdentifier', 'chooseStandardProduct', baseContext);

await productsPage.selectProductType(page, newProductData.type);

const productTypeDescription = await productsPage.getProductDescription(page);
expect(productTypeDescription).to.contains(productsPage.standardProductDescription);
});

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

await productsPage.clickOnAddNewProduct(page);

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

it('should create the product', async function () {
await testContext.addContextItem(this, 'testIdentifier', 'createPackOfProducts', baseContext);

await createProductPage.closeSfToolBar(page);

const createProductMessage = await createProductPage.setProduct(page, newProductData);
expect(createProductMessage).to.equal(createProductPage.successfulUpdateMessage);
});
});

describe('Check tags on FO Home page and Product page', async () => {
it('should view my shop', async function () {
await testContext.addContextItem(this, 'testIdentifier', 'viewMyShop', baseContext);

// Click on preview button
page = await createProductPage.viewMyShop(page);
await foProductPage.changeLanguage(page, 'en');

const isHomePage = await homePage.isHomePage(page);
expect(isHomePage, 'Home page is not displayed').to.eq(true);
});

it('should go to all products page', async function () {
await testContext.addContextItem(this, 'testIdentifier', 'goToAllProductsPage', baseContext);

await homePage.goToAllProductsPage(page);

const isCategoryPageVisible = await categoryPage.isCategoryPage(page);
expect(isCategoryPageVisible, 'Home category page was not opened').to.eq(true);
});

it('should go to the second product page', async function () {
await testContext.addContextItem(this, 'testIdentifier', 'goToSecondProductsPage', baseContext);

await categoryPage.goToNextPage(page);

productsNumber = await categoryPage.getProductsNumber(page);
expect(productsNumber).to.not.equal(19);
});

it('should check the tag \'New, pack, out-of-stock and Online only\' for the created product', async function () {
await testContext.addContextItem(this, 'testIdentifier', 'checkTagsInAllProductPage', baseContext);

const flagText = await categoryPage.getProductTag(page, productsNumber - 12);
expect(flagText).to.contains('On sale!')
.and.to.contain('New')
.and.to.contain('Out-of-Stock');
});

it('should go to the created product page', async function () {
await testContext.addContextItem(this, 'testIdentifier', 'goToCreatedProductPage', baseContext);

await categoryPage.goToProductPage(page, productsNumber - 12);

const pageTitle = await foProductPage.getPageTitle(page);
expect(pageTitle).to.contains(newProductData.name);
});

it('should check the tag \'New, pack, out-of-stock and Online only\'', async function () {
await testContext.addContextItem(this, 'testIdentifier', 'checkOnSaleFlag', baseContext);

const flagText = await foProductPage.getProductTag(page);
expect(flagText).to.contains('On sale!')
.and.to.contain('New')
.and.to.contain('Out-of-Stock');
});
});

// Post-condition: Delete specific price
deleteProductTest(newProductData, `${baseContext}_postTest`);
});