/**
|
* @file ADSO-10147
|
* @description General settings Shelf Life - usable if mature + expire within period
|
* @testcategory Web - Shelf life
|
* @author Umar Adkhamov (umar.adkhamov@3ds.com)
|
* @copyright Dassault Systèmes
|
*/
|
import { AppMP, Demo, Scenario } from '../../libmp/appmp';
|
import { qCustomMatcher } from '../../e2elib/lib/src/main/qmatchers.const';
|
import { ListProductContextMenuItem } from '../../libmp/forms/form.product';
|
import {
|
DataMatrixProductPlanningAttributeName,
|
DataMatrixProductPlanningRowName,
|
DataMatrixProductPlanningValue,
|
} from '../../libmp/data/data.supplyplanning';
|
import { DataFoodBaseProductName, DataLowFatStrawberry12 } from '../../libmp/data/data.navigation';
|
import { startOfPlanningYear } from '../../libmp/data/data.period';
|
|
describe('ADSO-10147 - General settings Shelf Life, usable if mature + expire within period', () => {
|
const appMP = AppMP.getInstance();
|
const datesToBeChecked = [
|
`1-Jan-${startOfPlanningYear}`,
|
`1-Feb-${startOfPlanningYear}`,
|
`1-Mar-${startOfPlanningYear}`,
|
`1-Apr-${startOfPlanningYear}`,
|
`1-May-${startOfPlanningYear}`,
|
];
|
const listProduct = appMP.viewProduct.frmProduct.listProduct;
|
const formProductPlanning = appMP.viewSupplyPlanning.frmProductPlanning;
|
const meRowName = DataMatrixProductPlanningRowName.LowFat12PKBulgaria;
|
const meAttributeName = DataMatrixProductPlanningAttributeName.InventoryEnd;
|
const mePlanningValue = +(DataMatrixProductPlanningValue._10000.replace(',', ''));
|
|
beforeAll(async () => {
|
jasmine.addMatchers(qCustomMatcher);
|
await appMP.login();
|
});
|
|
afterAll(async () => {
|
await appMP.viewProduct.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);
|
});
|
|
it(`Setup - Open view ${appMP.viewProduct.viewPath}, set new Shelf-life and Maturation values for ${DataFoodBaseProductName.AllProducts}
|
> ${DataFoodBaseProductName.FinishedGoods} > ${DataFoodBaseProductName.Lowfat} > ${DataLowFatStrawberry12.name} product`, async () => {
|
// Open Products view
|
await appMP.viewProduct.switchTo();
|
|
// Select AllProducts > FinishedGoods > Low fat > Lowfat Strawberry 12 pk product
|
const productRow = await listProduct.getRow({Name: DataLowFatStrawberry12.name}, DataLowFatStrawberry12.parents);
|
const [dialog] = await listProduct.selectContextMenu(ListProductContextMenuItem.Edit, productRow);
|
await dialog.pnlAdvanced.clickTab();
|
await dialog.updateDialogValues({ShelfLifeEnabled: 'true', ShelfLife: '145', MaturationEnabled: 'true', Maturation: '45'});
|
await dialog.clickOK();
|
});
|
|
it(`Setup - Open view ${appMP.viewGeneralSettings.viewPath}, verify that "If Expired Within Period/If Mature Within Period" checkboxes are checked by default in the General setttings form`, async () => {
|
// Open General Settings view
|
await appMP.viewGeneralSettings.switchTo();
|
const formGeneralSettings = appMP.viewGeneralSettings.frmGeneralSettings;
|
expect(await formGeneralSettings.cbIsUsableIfExpiredWithinPeriod.isChecked()).toBe(true, '"Is usable if expired within period" checkbox should be checked');
|
expect(await formGeneralSettings.cbIsUsableIfMatureWithinPeriod.isChecked()).toBe(true, '"Is usable if matured within period" checkbox should be checked');
|
});
|
|
it(`Step 1 - Open view ${appMP.viewSupplyPlanning.viewPath} and reset plan`, async () => {
|
// Open General Settings view
|
await appMP.viewSupplyPlanning.switchTo();
|
|
// Reset plan
|
await appMP.abpPlan.resetPlanAll();
|
});
|
|
it(`Step 2 - Set new ${DataMatrixProductPlanningAttributeName.TotalSupply} for "${meRowName}"`, async () => {
|
// Select first row to be able to use DOWN key on the MatrixEditor
|
await formProductPlanning.meProductPlanning.selectByRow(0);
|
// Scroll to the desired row
|
await formProductPlanning.meProductPlanning.scrollToRowByRowHeader(meRowName);
|
// Set Total Supply value
|
await formProductPlanning.meProductPlanning.setTotalSupply(meRowName, datesToBeChecked[0], mePlanningValue);
|
// Verify if optimizer run finish
|
const isOptimizerFinished = await appMP.abpScenarioSelection.verifyIsOptimizerCompleted(5000);
|
expect(isOptimizerFinished).toBe(true, 'Optimizer triggered after entered Total Supply value should be finished in 5 second.');
|
});
|
|
it(`Step 3 - Verify ${DataMatrixProductPlanningValue._10000} quantity is used to supply demand start from ${datesToBeChecked[1]} to ${datesToBeChecked[4]}`, async () => {
|
// Verify that quantity is not used to supply demand on Jan-SOPYear and used starting from Feb to May-SOPYear
|
for (const [index, date] of datesToBeChecked.entries()) {
|
const cell = await formProductPlanning.meProductPlanning.getCell(meRowName, meAttributeName, date);
|
const cellValue = await cell.getValue();
|
// As Jan-SOPYear will be first index in dateString array, check if quantity is used when index is not 1
|
if (index !== 0) {
|
// As we can't direct convert "10,000" type string value to number. Thus, we have to replace "," to empty string in order to convert
|
const numberValue = +(cellValue.replace(',', ''));
|
expect(numberValue).toBeLessThan(
|
mePlanningValue,
|
`${meAttributeName} value should be lesser than ${DataMatrixProductPlanningValue._10000} for ${date}. Actual value: ${cellValue}`,
|
);
|
} else {
|
expect(cellValue).toBe(
|
DataMatrixProductPlanningValue._10000,
|
`${meAttributeName} value should be ${DataMatrixProductPlanningValue._10000} for ${date}. Actual value: ${cellValue}`,
|
);
|
}
|
}
|
});
|
});
|