Skip to content

Commit

Permalink
Add some describes
Browse files Browse the repository at this point in the history
  • Loading branch information
nesrineabdmouleh committed Nov 16, 2023
1 parent 37961c0 commit 091652e
Show file tree
Hide file tree
Showing 5 changed files with 197 additions and 189 deletions.
Expand Up @@ -58,7 +58,7 @@ describe('BO - Shop Parameters - General : Enable/Disable Allow iframes on HTML
tests.forEach((test, index: number) => {
describe(`${test.args.action} Allow iframes on HTML fields`, async () => {
it('should go to \'Shop parameters > General\' page', async function () {
await testContext.addContextItem(this, 'testIdentifier', `goToGeneralPage_${index}`, baseContext);
await testContext.addContextItem(this, 'testIdentifier', `goToGeneralPage${index}`, baseContext);

await dashboardPage.goToSubMenu(
page,
Expand All @@ -79,7 +79,7 @@ describe('BO - Shop Parameters - General : Enable/Disable Allow iframes on HTML
});

it('should go to Products page', async function () {
await testContext.addContextItem(this, 'testIdentifier', `${test.args.action}GoToProductsPage`, baseContext);
await testContext.addContextItem(this, 'testIdentifier', `goToProductsPage${index}`, baseContext);

await dashboardPage.goToSubMenu(
page,
Expand All @@ -93,7 +93,7 @@ describe('BO - Shop Parameters - General : Enable/Disable Allow iframes on HTML
});

it('should go to first product page', async function () {
await testContext.addContextItem(this, 'testIdentifier', `${test.args.action}GoToFirstProductPage`, baseContext);
await testContext.addContextItem(this, 'testIdentifier', `goToFirstProductPage${index}`, baseContext);

await productsPage.goToProductPage(page, 1);

Expand All @@ -102,7 +102,7 @@ describe('BO - Shop Parameters - General : Enable/Disable Allow iframes on HTML
});

it('should add an iframe in the product description', async function () {
await testContext.addContextItem(this, 'testIdentifier', `${test.args.action}EditDescription`, baseContext);
await testContext.addContextItem(this, 'testIdentifier', `editDescription${index}`, baseContext);

await descriptionTab.setIframeInDescription(page, description);

Expand All @@ -117,7 +117,7 @@ describe('BO - Shop Parameters - General : Enable/Disable Allow iframes on HTML
});

it('should preview the product', async function () {
await testContext.addContextItem(this, 'testIdentifier', `${test.args.action}PreviewProduct`, baseContext);
await testContext.addContextItem(this, 'testIdentifier', `previewProduct${index}`, baseContext);

page = await addProductPage.previewProduct(page);
await foProductPage.changeLanguage(page, 'en');
Expand All @@ -127,7 +127,7 @@ describe('BO - Shop Parameters - General : Enable/Disable Allow iframes on HTML
});

it('should check the existence of the iframe in the product description', async function () {
await testContext.addContextItem(this, 'testIdentifier', `${test.args.action}checkIframe`, baseContext);
await testContext.addContextItem(this, 'testIdentifier', `checkIframe${index}`, baseContext);

const isIframeVisible = await foProductPage.isIframeVisibleInProductDescription(page);
expect(isIframeVisible).to.equal(test.args.exist);
Expand All @@ -139,7 +139,7 @@ describe('BO - Shop Parameters - General : Enable/Disable Allow iframes on HTML
});

it('should go back to BO', async function () {
await testContext.addContextItem(this, 'testIdentifier', `goBackToBo_${test.args.action}`, baseContext);
await testContext.addContextItem(this, 'testIdentifier', `goBackToBo${index}`, baseContext);

page = await foProductPage.closePage(browserContext, page, 0);

Expand All @@ -150,7 +150,7 @@ describe('BO - Shop Parameters - General : Enable/Disable Allow iframes on HTML
});

// POST-TEST : Delete iframe in product description
describe('POST-TEST : Delete iframe in product description', async () => {
describe('POST-TEST : Reset product description', async () => {
it('should go to Products page', async function () {
await testContext.addContextItem(this, 'testIdentifier', 'goToProductsPage', baseContext);

Expand Down
Expand Up @@ -44,92 +44,94 @@ describe('BO - Shop Parameters - General : Enable/Disable display suppliers', as
});

const tests = [
{args: {action: 'enable', exist: true}},
{args: {action: 'disable', exist: false}},
{args: {action: 'Enable', exist: true}},
{args: {action: 'Disable', exist: false}},
];

tests.forEach((test, index: number) => {
it('should go to \'Shop parameters > General\' page', async function () {
await testContext.addContextItem(this, 'testIdentifier', `goToGeneralPage_${index}`, baseContext);

await dashboardPage.goToSubMenu(
page,
dashboardPage.shopParametersParentLink,
dashboardPage.shopParametersGeneralLink,
);
await generalPage.closeSfToolBar(page);

const pageTitle = await generalPage.getPageTitle(page);
expect(pageTitle).to.contains(generalPage.pageTitle);
});
describe(`${test.args.action} Display suppliers`, async () => {
it('should go to \'Shop parameters > General\' page', async function () {
await testContext.addContextItem(this, 'testIdentifier', `goToGeneralPage_${index}`, baseContext);

it(`should ${test.args.action} display suppliers`, async function () {
await testContext.addContextItem(this, 'testIdentifier', `${test.args.action}DisplaySuppliers`, baseContext);
await dashboardPage.goToSubMenu(
page,
dashboardPage.shopParametersParentLink,
dashboardPage.shopParametersGeneralLink,
);
await generalPage.closeSfToolBar(page);

const result = await generalPage.setDisplaySuppliers(page, test.args.exist);
expect(result).to.contains(generalPage.successfulUpdateMessage);
});
const pageTitle = await generalPage.getPageTitle(page);
expect(pageTitle).to.contains(generalPage.pageTitle);
});

it('should go to \'Brands & Suppliers\' page', async function () {
await testContext.addContextItem(this, 'testIdentifier', `goToBrandsPage_${index}`, baseContext);
it(`should ${test.args.action} display suppliers`, async function () {
await testContext.addContextItem(this, 'testIdentifier', `${test.args.action}DisplaySuppliers`, baseContext);

await generalPage.goToSubMenu(
page,
generalPage.catalogParentLink,
generalPage.brandsAndSuppliersLink,
);
const result = await generalPage.setDisplaySuppliers(page, test.args.exist);
expect(result).to.contains(generalPage.successfulUpdateMessage);
});

const pageTitle = await brandsPage.getPageTitle(page);
expect(pageTitle).to.contains(brandsPage.pageTitle);
});
it('should go to \'Brands & Suppliers\' page', async function () {
await testContext.addContextItem(this, 'testIdentifier', `goToBrandsPage_${index}`, baseContext);

it('should go to \'Suppliers\' tab', async function () {
await testContext.addContextItem(this, 'testIdentifier', `goToSuppliersTab_${index}`, baseContext);
await generalPage.goToSubMenu(
page,
generalPage.catalogParentLink,
generalPage.brandsAndSuppliersLink,
);

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

const pageTitle = await suppliersPage.getPageTitle(page);
expect(pageTitle).to.contains(suppliersPage.pageTitle);
});
it('should go to \'Suppliers\' tab', async function () {
await testContext.addContextItem(this, 'testIdentifier', `goToSuppliersTab_${index}`, baseContext);

it(`should check that the message alert contains '${test.args.action}'`, async function () {
await testContext.addContextItem(this, 'testIdentifier', `checkAlertContains_${test.args.action}`, baseContext);
await brandsPage.goToSubTabSuppliers(page);

const text = await suppliersPage.getAlertInfoBlockParagraphContent(page);
expect(text).to.contains(test.args.action);
});
const pageTitle = await suppliersPage.getPageTitle(page);
expect(pageTitle).to.contains(suppliersPage.pageTitle);
});

it('should go to FO', async function () {
await testContext.addContextItem(this, 'testIdentifier', `goToFO_${test.args.action}`, baseContext);
it(`should check that the message alert contains '${test.args.action}'`, async function () {
await testContext.addContextItem(this, 'testIdentifier', `checkAlertContains_${test.args.action}`, baseContext);

// View shop
page = await suppliersPage.viewMyShop(page);
// Change shop language
await homePage.changeLanguage(page, 'en');
const text = await suppliersPage.getAlertInfoBlockParagraphContent(page);
expect(text).to.contains(test.args.action.toLowerCase());
});

const isHomePage = await homePage.isHomePage(page);
expect(isHomePage).to.eq(true);
});
it('should go to FO', async function () {
await testContext.addContextItem(this, 'testIdentifier', `goToFO_${test.args.action}`, baseContext);

it('should verify the existence of the suppliers page link', async function () {
await testContext.addContextItem(this, 'testIdentifier', `checkSuppliersPage_${test.args.action}`, baseContext);
// View shop
page = await suppliersPage.viewMyShop(page);
// Change shop language
await homePage.changeLanguage(page, 'en');

await homePage.goToFooterLink(page, 'Sitemap');
const isHomePage = await homePage.isHomePage(page);
expect(isHomePage).to.eq(true);
});

const pageTitle = await siteMapPage.getPageTitle(page);
expect(pageTitle).to.equal(siteMapPage.pageTitle);
it('should verify the existence of the suppliers page link', async function () {
await testContext.addContextItem(this, 'testIdentifier', `checkSuppliersPage_${test.args.action}`, baseContext);

const exist = await siteMapPage.isSuppliersLinkVisible(page);
expect(exist).to.be.equal(test.args.exist);
});
await homePage.goToFooterLink(page, 'Sitemap');

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

const exist = await siteMapPage.isSuppliersLinkVisible(page);
expect(exist).to.be.equal(test.args.exist);
});

it('should go back to BO', async function () {
await testContext.addContextItem(this, 'testIdentifier', `goBackToBo_${test.args.action}`, baseContext);
it('should go back to BO', async function () {
await testContext.addContextItem(this, 'testIdentifier', `goBackToBo_${test.args.action}`, baseContext);

page = await siteMapPage.closePage(browserContext, page, 0);
page = await siteMapPage.closePage(browserContext, page, 0);

const pageTitle = await suppliersPage.getPageTitle(page);
expect(pageTitle).to.contains(suppliersPage.pageTitle);
const pageTitle = await suppliersPage.getPageTitle(page);
expect(pageTitle).to.contains(suppliersPage.pageTitle);
});
});
});
});
Expand Up @@ -41,84 +41,86 @@ describe('BO - Shop Parameters - General : Enable/Disable display brands', async
});

const tests = [
{args: {action: 'disable', exist: false}},
{args: {action: 'enable', exist: true}},
{args: {action: 'Disable', exist: false}},
{args: {action: 'Enable', exist: true}},
];

tests.forEach((test, index: number) => {
it('should go to \'Shop parameters > General\' page', async function () {
await testContext.addContextItem(this, 'testIdentifier', `goToGeneralPage_${index}`, baseContext);

await dashboardPage.goToSubMenu(
page,
dashboardPage.shopParametersParentLink,
dashboardPage.shopParametersGeneralLink,
);
await generalPage.closeSfToolBar(page);

const pageTitle = await generalPage.getPageTitle(page);
expect(pageTitle).to.contains(generalPage.pageTitle);
});
describe(`${test.args.action} Display brands`, async () => {
it('should go to \'Shop parameters > General\' page', async function () {
await testContext.addContextItem(this, 'testIdentifier', `goToGeneralPage_${index}`, baseContext);

it(`should ${test.args.action} display brands`, async function () {
await testContext.addContextItem(this, 'testIdentifier', `${test.args.action}DisplayBrands`, baseContext);
await dashboardPage.goToSubMenu(
page,
dashboardPage.shopParametersParentLink,
dashboardPage.shopParametersGeneralLink,
);
await generalPage.closeSfToolBar(page);

const result = await generalPage.setDisplayBrands(page, test.args.exist);
expect(result).to.contains(generalPage.successfulUpdateMessage);
});
const pageTitle = await generalPage.getPageTitle(page);
expect(pageTitle).to.contains(generalPage.pageTitle);
});

it('should go to \'Brands & Suppliers\' page', async function () {
await testContext.addContextItem(this, 'testIdentifier', `goToBrandsPage_${index}`, baseContext);
it(`should ${test.args.action} display brands`, async function () {
await testContext.addContextItem(this, 'testIdentifier', `${test.args.action}DisplayBrands`, baseContext);

await generalPage.goToSubMenu(
page,
generalPage.catalogParentLink,
generalPage.brandsAndSuppliersLink,
);
const result = await generalPage.setDisplayBrands(page, test.args.exist);
expect(result).to.contains(generalPage.successfulUpdateMessage);
});

const pageTitle = await brandsPage.getPageTitle(page);
expect(pageTitle).to.contains(brandsPage.pageTitle);
});
it('should go to \'Brands & Suppliers\' page', async function () {
await testContext.addContextItem(this, 'testIdentifier', `goToBrandsPage_${index}`, baseContext);

it(`should check that the message alert contains '${test.args.action}'`, async function () {
await testContext.addContextItem(this, 'testIdentifier', `checkAlertContains_${test.args.action}`, baseContext);
await generalPage.goToSubMenu(
page,
generalPage.catalogParentLink,
generalPage.brandsAndSuppliersLink,
);

const text = await brandsPage.getAlertInfoBlockParagraphContent(page);
expect(text).to.contains(test.args.action);
});
const pageTitle = await brandsPage.getPageTitle(page);
expect(pageTitle).to.contains(brandsPage.pageTitle);
});

it('should go to FO', async function () {
await testContext.addContextItem(this, 'testIdentifier', `goToFO_${test.args.action}`, baseContext);
it(`should check that the message alert contains '${test.args.action}'`, async function () {
await testContext.addContextItem(this, 'testIdentifier', `checkAlertContains_${test.args.action}`, baseContext);

// View shop
page = await brandsPage.viewMyShop(page);
const text = await brandsPage.getAlertInfoBlockParagraphContent(page);
expect(text).to.contains(test.args.action.toLowerCase());
});

// Change FO language
await homePage.changeLanguage(page, 'en');
it('should go to FO', async function () {
await testContext.addContextItem(this, 'testIdentifier', `goToFO_${test.args.action}`, baseContext);

const isHomePage = await homePage.isHomePage(page);
expect(isHomePage).to.eq(true);
});
// View shop
page = await brandsPage.viewMyShop(page);

it('should verify the existence of the brands page link', async function () {
await testContext.addContextItem(this, 'testIdentifier', `checkBrandsPage_${test.args.action}`, baseContext);
// Change FO language
await homePage.changeLanguage(page, 'en');

await homePage.goToFooterLink(page, 'Sitemap');
const isHomePage = await homePage.isHomePage(page);
expect(isHomePage).to.eq(true);
});

const pageTitle = await siteMapPage.getPageTitle(page);
expect(pageTitle).to.equal(siteMapPage.pageTitle);
it('should verify the existence of the brands page link', async function () {
await testContext.addContextItem(this, 'testIdentifier', `checkBrandsPage_${test.args.action}`, baseContext);

const exist = await siteMapPage.isBrandsLinkVisible(page);
expect(exist).to.be.equal(test.args.exist);
});
await homePage.goToFooterLink(page, 'Sitemap');

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

const exist = await siteMapPage.isBrandsLinkVisible(page);
expect(exist).to.be.equal(test.args.exist);
});

it('should go back to BO', async function () {
await testContext.addContextItem(this, 'testIdentifier', `goBackToBo_${test.args.action}`, baseContext);
it('should go back to BO', async function () {
await testContext.addContextItem(this, 'testIdentifier', `goBackToBo_${test.args.action}`, baseContext);

page = await siteMapPage.closePage(browserContext, page, 0);
page = await siteMapPage.closePage(browserContext, page, 0);

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

0 comments on commit 091652e

Please sign in to comment.