/**
|
* @file ADSO-10184 - Edit single stocking cost - not unique cost encountered
|
* @description Edit single stocking cost and enter existed start date to verify ok button in dialog is clickable
|
* @testcategory Web - Financials - Stocking points
|
* @author Wong Jia Hui (jiahui.wong@3ds.com)
|
* @copyright Dassault Systèmes
|
*/
|
import { qCustomMatcher } from '../../../e2elib/lib/src/main/qmatchers.const';
|
import { ListRow } from '../../../e2elib/lib/src/pageobjects/list/listrow.component';
|
import { LogMessage } from '../../../libappbase/logmessage';
|
import { AppMP, Demo, Scenario } from '../../../libmp/appmp';
|
import { DataFoodBaseEntityName } from '../../../libmp/data/data.navigation';
|
import { DataFoodBaseStockingCostStartDate } from '../../../libmp/data/data.stockingcost';
|
import { DataFoodBaseAccountCost, DataFoodBaseAccountCostDriver, DataFoodBaseAccountName } from '../../../libmp/data/data.account';
|
import { ListStockingCostColumn } from '../../../libmp/forms/form.stockingcost';
|
import { ColumnIDValueMap } from '../../../libappbase/listbase';
|
import { ActionTriggerType } from '../../../libappbase/utils';
|
import { startOfPlanningYear } from '../../../libmp/data/data.period';
|
|
describe('ADSO-10184 - Edit single stocking cost - not unique cost encountered', () => {
|
// Component used in this script
|
const appMP = AppMP.getInstance();
|
const listStockingCost = appMP.viewStockingCost.frmStockingCost.lstStockingCost;
|
let dlgStockingCost = listStockingCost.dlgStockingCost;
|
|
// Variable used across multiple steps
|
const stockingPoint = DataFoodBaseEntityName.DCAustria;
|
const account = DataFoodBaseAccountName.GeneralFixedCosts;
|
const costDriver = DataFoodBaseAccountCostDriver.Fixed;
|
const expectedTooltip = 'Identical cost definition exists. Stocking cost must be unique by Account, Cost driver and Start date.';
|
let sopYear: string;
|
const stockingCostStartDate1 = `1-Jan-${startOfPlanningYear - 1}`;
|
const stockingCostStartWithoutYear = DataFoodBaseStockingCostStartDate._1JanWithoutYear;
|
const editStartDateWithoutYear = DataFoodBaseStockingCostStartDate._1FebWithoutYear;
|
let stockingCostStartDate2 = '';
|
let editStartDate = '';
|
|
beforeAll(async () => {
|
jasmine.addMatchers(qCustomMatcher);
|
await appMP.login();
|
});
|
|
afterAll(async () => {
|
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(`Setup - Open view ${appMP.viewPeriod.viewPath} to get the start of planning (SOP) year`, async () => {
|
await appMP.viewPeriod.switchTo();
|
const formPeriod = appMP.viewPeriod.frmPeriod;
|
({ sopYear } = await formPeriod.getStartAndEndOfPlanning());
|
stockingCostStartDate2 = `${stockingCostStartWithoutYear}${sopYear}`;
|
editStartDate = `${editStartDateWithoutYear}${sopYear}`;
|
});
|
|
it(`Setup - Open view ${appMP.viewStockingCost.viewPath}. \
|
Ensure there are 2 stocking cost for ${stockingPoint} with start ${stockingCostStartDate1} and ${stockingCostStartWithoutYear}SOP year`, async () => {
|
await appMP.viewStockingCost.switchTo();
|
const startDateArray = [stockingCostStartDate1, stockingCostStartDate2];
|
for (const startDate of startDateArray) {
|
const scValueMap: ColumnIDValueMap[] = [
|
{ columnID: ListStockingCostColumn.StockingPoint, value: stockingPoint },
|
{ columnID: ListStockingCostColumn.Start, value: startDate },
|
];
|
|
try {
|
await listStockingCost.getRowByValue(scValueMap);
|
} catch {
|
dlgStockingCost = await listStockingCost.openStockingCostDialog(ActionTriggerType.ContextMenu);
|
await dlgStockingCost.updateDialog(account, costDriver, stockingPoint, new Date(startDate), DataFoodBaseAccountCost._1000);
|
const [isOkButtonClickable, btnDisabledTooltip] = await dlgStockingCost.btnOk.verifyIsButtonClickable();
|
expect(isOkButtonClickable).toBe(true, LogMessage.btn_notClickable('Ok', btnDisabledTooltip));
|
await dlgStockingCost.clickOK();
|
}
|
|
const scRow: ListRow = await listStockingCost.getRowByValue(scValueMap);
|
expect(scRow).toBeDefined(LogMessage.row_notFound(`SP = ${stockingPoint}, Start = ${startDate}`));
|
}
|
});
|
|
it(`Step 1 - Edit cost of ${stockingPoint} with ${stockingCostStartDate1} to ${stockingCostStartWithoutYear}SOP year and verify ok button in dialog is disbaled`, async () => {
|
const stockingCostRow = await listStockingCost.getRowByValue([
|
{ columnID: ListStockingCostColumn.StockingPoint, value: stockingPoint },
|
{ columnID: ListStockingCostColumn.Start, value: stockingCostStartDate1 },
|
]);
|
dlgStockingCost = await listStockingCost.openStockingCostDialog(ActionTriggerType.ContextMenu, stockingCostRow);
|
await dlgStockingCost.dtsStart.setDate(new Date(stockingCostStartDate2));
|
const [isOkButtonClickable, btnDisabledTooltip] = await dlgStockingCost.btnOk.verifyIsButtonClickable(1000);
|
expect(isOkButtonClickable).toBe(false, LogMessage.btn_isEnabled('Ok'));
|
expect(btnDisabledTooltip).toBe(expectedTooltip, LogMessage.tooltip_notMatched(expectedTooltip, btnDisabledTooltip));
|
});
|
|
it(`Step 2 - Change start value to ${editStartDateWithoutYear}SOP year and verify ok button in dialog is enabled`, async () => {
|
await dlgStockingCost.dtsStart.setDate(new Date(editStartDate));
|
const [isOkButtonClickable, btnDisabledTooltip] = await dlgStockingCost.btnOk.verifyIsButtonClickable();
|
expect(isOkButtonClickable).toBe(true, LogMessage.btn_notClickable('Ok', btnDisabledTooltip));
|
await dlgStockingCost.clickOK();
|
});
|
|
it(`Step 3 - Verify stocking costs for ${stockingPoint} has start date ${stockingCostStartDate2} and ${editStartDate}`, async () => {
|
const startDateArray = [stockingCostStartDate2, editStartDate];
|
for (const startDate of startDateArray) {
|
const scRow = await listStockingCost
|
.getRowByValue([
|
{ columnID: ListStockingCostColumn.StockingPoint, value: stockingPoint },
|
{ columnID: ListStockingCostColumn.Start, value: startDate },
|
])
|
.catch(() => {
|
// do nothing as error is thrown due to no row is found
|
});
|
expect(scRow).toBeDefined(LogMessage.row_notFound(`SP = ${stockingPoint}, Start = ${startDate}`));
|
}
|
});
|
});
|