Skip to content

Commit

Permalink
Add new test to check help card in dashboard page
Browse files Browse the repository at this point in the history
  • Loading branch information
nesrineabdmouleh committed Oct 18, 2023
1 parent 2eaba2c commit e6e846b
Show file tree
Hide file tree
Showing 2 changed files with 92 additions and 0 deletions.
51 changes: 51 additions & 0 deletions tests/UI/campaigns/functional/BO/01_dashboard/04_helpCard.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// Import utils
import helper from '@utils/helpers';
import testContext from '@utils/testContext';

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

// Import pages
import dashboardPage from '@pages/BO/dashboard';

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

const baseContext: string = 'functional_BO_dashboard_helpCard';

// Check help card language in dashboard page
describe('BO - dashboard : Help card in order page', async () => {
let browserContext: BrowserContext;
let page: Page;

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

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

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

it('should open the help side bar and check the document title', async function () {
await testContext.addContextItem(this, 'testIdentifier', 'openHelpSidebar', baseContext);

const isHelpSidebarVisible = await dashboardPage.openHelpCard(page);
expect(isHelpSidebarVisible).to.eq(true);

const documentURL = await dashboardPage.getHelpDocumentTitle(page);
expect(documentURL).to.contains('Discovering the Administration Area');
});

it('should close the help side bar', async function () {
await testContext.addContextItem(this, 'testIdentifier', 'closeHelpSidebar', baseContext);

const isHelpSidebarClosed = await dashboardPage.closeHelpCard(page);
expect(isHelpSidebarClosed).to.eq(true);
});
});
41 changes: 41 additions & 0 deletions tests/UI/pages/BO/dashboard/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ class Dashboard extends BOBasePage {

private readonly configureProductsAndSalesForm: string;

private readonly helpCardButton: string;

private readonly helpCardDocument: string;

private readonly helpCardDocumentTitle: string;

/**
* @constructs
* Setting up titles and selectors to use on dashboard page
Expand All @@ -58,6 +64,10 @@ class Dashboard extends BOBasePage {
this.demoModeButton = '#page-header-desc-configuration-switch_demo';
this.demoModeToggle = (toEnable: string) => `.process-icon-toggle-${toEnable}.switch_demo`;
this.salesScore = '#sales_score';
// Selectors of help card
this.helpCardButton = '#toolbar-nav a.btn-help';
this.helpCardDocument = '#help-container div.page-wrap';
this.helpCardDocumentTitle = '#help-container section.article h1';
// Selectors of Products and sales block
this.recentOrdersTitle = '#dash_recent_orders div.panel-heading';
this.recentOrdersTable = '#table_recent_orders';
Expand Down Expand Up @@ -222,6 +232,37 @@ class Dashboard extends BOBasePage {

return this.elementVisible(page, this.configureProductsAndSalesForm, 1000);
}

/**
* Open help sidebar
* @param page {Page} Browser tab
* @returns {Promise<boolean>}
*/
async openHelpCard(page: Page): Promise<boolean> {
await this.waitForSelectorAndClick(page, this.helpCardButton);

return this.elementVisible(page, this.helpCardDocument, 2000);
}

/**
* Close help sidebar
* @param page {Page} Browser tab
* @returns {Promise<boolean>}
*/
async closeHelpCard(page: Page): Promise<boolean> {
await this.waitForSelectorAndClick(page, this.helpCardButton);

return this.elementNotVisible(page, this.helpCardDocument, 2000);
}

/**
* Get help document title
* @param page {Page} Browser tab
* @returns {Promise<string>}
*/
async getHelpDocumentTitle(page: Page): Promise<string> {
return this.getTextContent(page, this.helpCardDocumentTitle);
}
}

export default new Dashboard();

0 comments on commit e6e846b

Please sign in to comment.