/**
|
* @file ADSO-10196
|
* @description Products in Stocking Points and Inventory costs display (filter by leaf pisps selection from navigation panel)
|
* @testCategory Web - Financials - Inventory
|
* @author Gay Er Xuan (erxuan.gay@3ds.com)
|
* @copyright Dassault Systèmes
|
*/
|
import { qCustomMatcher } from '../../../e2elib/lib/src/main/qmatchers.const';
|
import { AppMP, Demo, Scenario } from '../../../libmp/appmp';
|
import { asyncEvery } from '../../../libappbase/utils';
|
import { ListRow } from '../../../e2elib/lib/src/pageobjects/list/listrow.component';
|
import { DataFoodBaseProductName, DataFoodBaseEntityName, DataLowFatVanilla6 } from '../../../libmp/data/data.navigation';
|
import { ListColumnInventoryPISP } from '../../../libmp/forms/form.inventorycostpisp';
|
|
describe('ADSO-10196 - Products in Stocking Points and Inventory costs display (filter by leaf pisps selection from navigation panel)', () => {
|
const appMP = AppMP.getInstance();
|
const listInventoryPISP = appMP.viewInventoryCosts.frmInventoryCostPISP.lstInventoryPISP;
|
const listAccountCosts = appMP.viewInventoryCosts.frmInventoryCosts.lstAccountCosts;
|
const stockingPointParents = [DataFoodBaseEntityName.Europe];
|
const stockingPoints: string[] = [DataFoodBaseEntityName.FRWarehouse, DataFoodBaseEntityName.HUWarehouse];
|
const stockingPointsStr: string = stockingPoints.join(', ');
|
const products: string[] = [DataFoodBaseProductName.LowfatVanilla6pk, DataFoodBaseProductName.LowfatVanilla12pk];
|
const productsStr: string = products.join(', ');
|
const expectedNrOfProducts = 4;
|
|
beforeAll(async () => {
|
jasmine.addMatchers(qCustomMatcher);
|
await appMP.login();
|
});
|
|
afterAll(async () => {
|
// Reset Navigation Form
|
await appMP.formNavigation.reset();
|
await appMP.cleanupAndLogout();
|
});
|
|
afterEach(async () => {
|
await appMP.checkToastMessage();
|
});
|
|
it(`Setup - ${AppMP.getDemoDataPath(Demo.Food, Scenario.Base)}`, async () => {
|
await appMP.createDemoDataset(Demo.Food, Scenario.Base, false);
|
});
|
|
it(`Step 1 - Open view ${appMP.viewInventoryCosts.viewPath}`, async () => {
|
await appMP.viewInventoryCosts.switchTo();
|
});
|
|
it('Step 2 - By default, Filter by Accounts toggled Off', async () => {
|
const isFilterByAccount = await appMP.viewInventoryCosts.frmInventoryCosts.cbFilterByAccounts.isChecked();
|
expect(isFilterByAccount).toBe(false, 'Filter by Accounts should be defaulted to off');
|
});
|
|
it(`Step 3 - In navigation panel, select stocking points (${stockingPoints.join(', ')}) and products (${products.join(', ')})`, async () => {
|
// Open StockingPoints and Units list
|
await appMP.formNavigation.toggleEntityList();
|
// Select stocking point
|
for (const stockingPoint of stockingPoints) {
|
await appMP.formNavigation.filterByEntity(stockingPoint, stockingPointParents);
|
}
|
// Close StockingPoints and Units list
|
await appMP.formNavigation.toggleEntityList(false);
|
// Open Product list
|
await appMP.formNavigation.toggleProductList();
|
// Select product
|
await appMP.formNavigation.filterByProduct({ Name: DataFoodBaseProductName.LowfatVanilla6pk }, DataLowFatVanilla6.parents); // Both share same parent
|
await appMP.formNavigation.filterByProduct({ Name: DataFoodBaseProductName.LowfatVanilla12pk }, DataLowFatVanilla6.parents);
|
});
|
|
it('Step 4 - Verify products in Stocking Points and Inventory Cost list are correct', async () => {
|
const feedback: (listName: string, feedbackType?: 1 | 2) => string = (listName: string, feedbackType: number = 1): string => {
|
switch (feedbackType) {
|
case 1:
|
return `There should be a total of ${expectedNrOfProducts} PISPs of '${productsStr}' products in '${listName}' list. Got ${inventoryPISPRowCount} instead.`;
|
case 2:
|
return `'${listName}' list should show relevant products (expected total number of rows: ${expectedNrOfProducts}, expected product names: ${productsStr}, products belong to: ${stockingPointsStr}).`;
|
default:
|
return '';
|
}
|
};
|
|
// To wait for list InventoryPISP update after filtering applied
|
await listInventoryPISP.waitForScreenUpdate();
|
|
// Verify products in Stocking Points list shows correct rows
|
const inventoryPISPRowCount = await listInventoryPISP.getRowCount();
|
const inventoryPISPAllRows = await listInventoryPISP.getAllRows();
|
const isPISPShowingRelevantRow = await asyncEvery(inventoryPISPAllRows, async (inventoryPISPRow: ListRow) => {
|
const productName = await listInventoryPISP.getCellValueFromRow(ListColumnInventoryPISP.Product, inventoryPISPRow); // await (await inventoryPISPRow.getCell(ListColumnInventoryPISP.Product)).getValue();
|
const stockingPointName = await listInventoryPISP.getCellValueFromRow(ListColumnInventoryPISP.StockingPoint, inventoryPISPRow); // await (await inventoryPISPRow.getCell(ListColumnInventoryPISP.StockingPoint)).getValue();
|
const result = products.indexOf(productName) > -1 && stockingPoints.indexOf(stockingPointName) > -1;
|
return result;
|
});
|
|
expect(inventoryPISPRowCount === expectedNrOfProducts).toBe(true, feedback('Products in Stocking Points'));
|
expect(isPISPShowingRelevantRow).toBe(true, feedback('Products in Stocking Points', 2));
|
|
// Verify Inventory Costs list shows correct rows
|
const inventoryCostRowCount = await listAccountCosts.getRowCount();
|
const inventoryCostAllRows = await listInventoryPISP.getAllRows();
|
const isInventoryCostShowingRelevantRow = await asyncEvery(inventoryCostAllRows, async (inventoryCostRow: ListRow) => {
|
const productName = await listInventoryPISP.getCellValueFromRow(ListColumnInventoryPISP.Product, inventoryCostRow); // await (await inventoryCostRow.getCell(ListColumnInventoryPISP.Product)).getValue();
|
const stockingPointName = await listInventoryPISP.getCellValueFromRow(ListColumnInventoryPISP.StockingPoint, inventoryCostRow); // await (await inventoryCostRow.getCell(ListColumnInventoryPISP.StockingPoint)).getValue();
|
const result = products.indexOf(productName) > -1 && stockingPoints.indexOf(stockingPointName) > -1;
|
return result;
|
});
|
expect(inventoryCostRowCount === expectedNrOfProducts).toBe(true, feedback('Inventory Costs'));
|
expect(isInventoryCostShowingRelevantRow).toBe(true, feedback('Inventory Costs', 2));
|
|
// Verify no non-leaf level pisps are shown in both lists
|
const lowfatInventoryCostRow = await listAccountCosts.getInventoryCostByName(DataFoodBaseProductName.Lowfat).catch(() => {
|
// do nothing as error is thrown due to no row is found
|
});
|
expect(lowfatInventoryCostRow).toBeUndefined('Lowfat as a non-leaf PISP should not be in Inventory Account Cost list');
|
const lowfatPISPRow = await listInventoryPISP.getPISPByName(DataFoodBaseProductName.Lowfat).catch(() => {
|
// do nothing as error is thrown due to no row is found
|
});
|
expect(lowfatPISPRow).toBeUndefined('Lowfat as a non-leaf PISP should not be in Inventory Product in Stocking Point list');
|
});
|
});
|