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 test 'BO Dashboard > Products and sales & help card' #34333

Merged
merged 3 commits into from
Oct 20, 2023
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
128 changes: 128 additions & 0 deletions tests/UI/campaigns/functional/BO/01_dashboard/03_productsAndSales.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
// Import utils
import helper from '@utils/helpers';
import testContext from '@utils/testContext';

// Import BO pages
import dashboardPage from '@pages/BO/dashboard';
import {viewOrderBasePage} from '@pages/BO/orders/view/viewOrderBasePage';

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

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

const baseContext: string = 'functional_BO_dashboard_productsAndSales';

describe('BO - Dashboard : Products and sales', 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);
});

describe('Check Online visitor & Active shopping carts', async () => {
it('should login in BO', async function () {
await loginCommon.loginBO(this, page);
});

describe('Check Recent orders tab', async () => {
it('should check the title of Recent orders tab', async function () {
await testContext.addContextItem(this, 'testIdentifier', 'checkRecentOrdersTitle', baseContext);

const tableTitle = await dashboardPage.getRecentOrdersTitle(page);
expect(tableTitle).to.eq('Last 10 orders');
});

it('should click on details icon of the first row and check Order details page', async function () {
await testContext.addContextItem(this, 'testIdentifier', 'clickOnDetailsButton', baseContext);

await dashboardPage.clickOnDetailsButtonOfRecentOrdersTable(page, 1);

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

it('should go back to dashboard page', async function () {
await testContext.addContextItem(this, 'testIdentifier', 'goBackToDashboard', baseContext);

await viewOrderBasePage.goToDashboardPage(page);

const pageTitle = await dashboardPage.getPageTitle(page);
expect(pageTitle).to.eq(dashboardPage.pageTitle);
});
});

describe('Check Best sellers tab', async () => {
it('should click on best sellers tab and check the title', async function () {
await testContext.addContextItem(this, 'testIdentifier', 'clickOnBestSellersTab', baseContext);

await dashboardPage.goToBestSellersTab(page);

const tabTitle = await dashboardPage.getBestSellersTabTitle(page);
expect(tabTitle).to.contains('Top 10 products');
});

it('should check that the best sellers table is visible', async function () {
await testContext.addContextItem(this, 'testIdentifier', 'isBestSellersTableVisible', baseContext);

const isVisible = await dashboardPage.isBestSellersTableVisible(page);
expect(isVisible).to.equal(true);
});
});

describe('Check Most viewed tab', async () => {
it('should click on most viewed tab and check the title', async function () {
await testContext.addContextItem(this, 'testIdentifier', 'clickOnMostViewedTab', baseContext);

await dashboardPage.goToMostViewedTab(page);

const tabTitle = await dashboardPage.getMostViewedTabTitle(page);
expect(tabTitle).to.contains('Most Viewed');
});

it('should check that the most viewed table is visible', async function () {
await testContext.addContextItem(this, 'testIdentifier', 'isMostViewedTableVisible', baseContext);

const isVisible = await dashboardPage.isMostViewedTableVisible(page);
expect(isVisible).to.equal(true);
});
});

describe('Check Top searches tab', async () => {
it('should check top searchers tab and check the title', async function () {
await testContext.addContextItem(this, 'testIdentifier', 'checkTopSearchersTab', baseContext);

await dashboardPage.goToTopSearchersTab(page);

const tabTitle = await dashboardPage.getTopSearchersTabTitle(page);
expect(tabTitle).to.contains('Top 10 most search terms');
});

it('should check that the top searchers table is visible', async function () {
await testContext.addContextItem(this, 'testIdentifier', 'isTopSearchersTableVisible', baseContext);

const isVisible = await dashboardPage.isTopSearchersTableVisible(page);
expect(isVisible).to.equal(true);
});
});

describe('Configuration', async () => {
it('should click on configure link', async function () {
await testContext.addContextItem(this, 'testIdentifier', 'clickOnConfigureLink', baseContext);

const isConfigureFormVisible = await dashboardPage.clickOnConfigureProductsAndSalesLink(page);
expect(isConfigureFormVisible).to.eq(true);
});

// @todo https://github.com/PrestaShop/PrestaShop/issues/34326
});
});
});
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 in dashboard page
describe('BO - dashboard : Help card in dashboard 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);
});
});
198 changes: 198 additions & 0 deletions tests/UI/pages/BO/dashboard/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,42 @@ class Dashboard extends BOBasePage {

private readonly configureForm: string;

private readonly recentOrdersTitle: string;

private readonly recentOrdersTable: string;

private readonly recentOrdersTableRow: (row: number) => string;

private readonly recentOrdersTableRowDetailsIcon: (row: number) => string;

private readonly bestSellersTab: string;

private readonly bestSellersTabTitle: string;

private readonly bestSellersTable: string;

private readonly mostViewedTab: string;

private readonly mostViewedTabTitle: string;

private readonly mostViewedTable: string;

private readonly topSearchersTab: string;

private readonly topSearchersTabTitle: string;

private readonly topSearchersTable: string;

private readonly configureProductsAndSalesLink: string;

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 @@ -96,6 +132,26 @@ 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';
this.recentOrdersTableRow = (row: number) => `#table_recent_orders tbody tr:nth-child(${row})`;
this.recentOrdersTableRowDetailsIcon = (row: number) => `${this.recentOrdersTableRow(row)} #details a[href*='vieworder']`;
this.bestSellersTab = '#dashproducts a[href*=\'#dash_best_sellers\']';
this.bestSellersTabTitle = '#dash_best_sellers div.panel-heading';
this.bestSellersTable = '#table_best_sellers';
this.mostViewedTab = '#dashproducts a[href*=\'#dash_most_viewed\']';
this.mostViewedTabTitle = '#dash_most_viewed div.panel-heading';
this.mostViewedTable = '#table_most_viewed';
this.topSearchersTab = '#dashproducts a[href*=\'#dash_top_search\']';
this.topSearchersTabTitle = '#dash_top_search div.panel-heading';
this.topSearchersTable = '#table_top_10_most_search';
this.configureProductsAndSalesLink = '#dashproducts i.process-icon-configure';
this.configureProductsAndSalesForm = '#fieldset_0_1 div.form-wrapper';
// Activity overview selectors
this.dashboardLiveSection = '#dash_live span.data_label';
this.onlineVisitorLink = `${this.dashboardLiveSection} a[href*='controller=AdminStats']`;
Expand Down Expand Up @@ -422,6 +478,148 @@ class Dashboard extends BOBasePage {

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

/**
* Get recent orders title
* @param page {Page} Browser tab
* @returns {Promise<string>}
*/
async getRecentOrdersTitle(page: Page): Promise<string> {
return this.getTextContent(page, this.recentOrdersTitle);
}

/**
*Click on details button of recent orders table
* @param page {Page} Browser tab
* @param row {number} Row on orders table
* @returns {Promise<void>}
*/
async clickOnDetailsButtonOfRecentOrdersTable(page: Page, row: number = 1): Promise<void> {
await this.clickAndWaitForURL(page, this.recentOrdersTableRowDetailsIcon(row));
}

/**
* Go to best sellers tab
* @param page {Page} Browser tab
* @returns {Promise<void>}
*/
async goToBestSellersTab(page: Page): Promise<void> {
await page.locator(this.bestSellersTab).click();
}

/**
* Get best sellers tab title
* @param page {Page} Browser tab
* @returns {Promise<string>}
*/
async getBestSellersTabTitle(page: Page): Promise<string> {
return this.getTextContent(page, this.bestSellersTabTitle);
}

/**
* Is best sellers table visible
* @param page {Page} Browser tab
* @returns {Promise<boolean>}
*/
async isBestSellersTableVisible(page: Page): Promise<boolean> {
return this.elementVisible(page, this.bestSellersTable, 1000);
}

/**
* Go to most viewed tab
* @param page {Page} Browser tab
* @returns {Promise<void>}
*/
async goToMostViewedTab(page: Page): Promise<void> {
await page.locator(this.mostViewedTab).click();
}

/**
* Get most viewed tab title
* @param page {Page} Browser tab
* @returns {Promise<string>}
*/
async getMostViewedTabTitle(page: Page): Promise<string> {
return this.getTextContent(page, this.mostViewedTabTitle);
}

/**
* Is most viewed table visible
* @param page {Page} Browser tab
* @returns {Promise<boolean>}
*/
async isMostViewedTableVisible(page: Page): Promise<boolean> {
return this.elementVisible(page, this.mostViewedTable, 1000);
}

/**
* Go to top searchers tab
* @param page {Page} Browser tab
* @returns {Promise<void>}
*/
async goToTopSearchersTab(page: Page): Promise<void> {
await page.locator(this.topSearchersTab).click();
}

/**
* Get top searchers tab title
* @param page {Page} Browser tab
* @returns {Promise<string>}
*/
async getTopSearchersTabTitle(page: Page): Promise<string> {
return this.getTextContent(page, this.topSearchersTabTitle);
}

/**
* Is top searchers table visible
* @param page {Page} Browser tab
* @returns {Promise<boolean>}
*/
async isTopSearchersTableVisible(page: Page): Promise<boolean> {
return this.elementVisible(page, this.topSearchersTable, 1000);
}

/**
* Click on configure products and sales link
* @param page {Page} Browser tab
* @returns {Promise<boolean>}
*/
async clickOnConfigureProductsAndSalesLink(page: Page): Promise<boolean> {
await page.locator(this.configureProductsAndSalesLink).click();

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();