/**
|
* @file ADSO-10106
|
* @description Create unit cost by drag & drop multiple units onto account
|
* @testcategory Web - Financials - Units
|
* @author Gay Er Xuan (erxuan.gay@3ds.com)
|
* @copyright Dassault Systemes
|
*/
|
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 { DataFoodBaseEntity, DataFoodBaseEntityName } from '../../../libmp/data/data.navigation';
|
import { DataFoodBaseUnitCostCost } from '../../../libmp/data/data.unitcost';
|
import { DataFoodBaseAccountName, DataFoodBaseAccountCost, DataFoodBaseAccountCostDriver, DataFoodBaseAccountLengthOfTime, DataFoodBaseAccountTimeUnit, DataFoodBaseAccountUoM, CostLabel } from '../../../libmp/data/data.account';
|
import { ListUnitCostColumn } from '../../../libmp/forms/form.unitcost';
|
|
describe('ADSO-10106 - Create unit cost by drag & drop multiple units onto account', () => {
|
const appMP = AppMP.getInstance();
|
const listAccount = appMP.viewAccount.frmAccount.listAccount;
|
const listUnitCost = appMP.viewUnitCost.frmUnitCost.listUnitCost;
|
let dlgUnitCost = listUnitCost.dlgUnitCost;
|
let accountRow: ListRow;
|
let newUnitStartDate: Date;
|
let newUnitStartString: string;
|
let endOfPlanningString: string;
|
let sopYear: string;
|
const account = DataFoodBaseAccountName.GeneralFixedCosts;
|
const costDriver = DataFoodBaseAccountCostDriver.Fixed;
|
const timeUnit = DataFoodBaseAccountTimeUnit.Quarter;
|
const lengthOfTime = DataFoodBaseAccountLengthOfTime._2;
|
const cost = DataFoodBaseAccountCost._122_22;
|
const newCost = DataFoodBaseUnitCostCost._200;
|
const units: string[] = [DataFoodBaseEntityName.DEFermenter, DataFoodBaseEntityName.DEPackaging];
|
const unitParents: string[] = DataFoodBaseEntity.deUnitsParents;
|
let canUpdate: boolean;
|
let tooltip = '';
|
|
beforeAll(async () => {
|
jasmine.addMatchers(qCustomMatcher);
|
await appMP.login();
|
});
|
|
afterAll(async () => {
|
// Reset navigation
|
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(`Setup - Open view ${appMP.viewPeriod.viewPath}. Get start and end of planning`, async () => {
|
// Open Periods view
|
await appMP.viewPeriod.switchTo();
|
const formPeriod = appMP.viewPeriod.frmPeriod;
|
({ sopYear, eopString: endOfPlanningString } = await formPeriod.getStartAndEndOfPlanning());
|
newUnitStartDate = new Date(Number(sopYear), 0, 1);
|
newUnitStartString = `1-Jan-${sopYear}`;
|
});
|
|
it(`Setup - Open view ${appMP.viewAccount.viewPath}. Configure ${account}`, async () => {
|
// Open account view
|
await appMP.viewAccount.switchTo();
|
await (await listAccount.getRow({ Name: DataFoodBaseAccountName.CostOfSales })).expandRow();
|
const accRow = await listAccount.getRow({ Name: account });
|
const dlgAccount = await listAccount.openAcountDialogViaEditContextMenu(accRow);
|
await dlgAccount.updateDialogValues({ CostDriver: costDriver, Cost: cost.toString(), TimeUnit: timeUnit, LengthOfTime: lengthOfTime.toString() });
|
canUpdate = await dlgAccount.clickOK();
|
tooltip = canUpdate ? '' : await dlgAccount.getOKButtonTooltip();
|
expect(canUpdate).toBe(true, LogMessage.btn_notClickable('OK', tooltip));
|
});
|
|
it(`Step 1 - Open view ${appMP.viewUnitCost.viewPath}. Create new ${units.join(', ')} unit costs for ${account} by drag and drop`, async () => {
|
// Open unit cost view
|
await appMP.viewUnitCost.switchTo();
|
// Get account row
|
accountRow = await appMP.viewUnitCost.frmUnitAccount.listAccount.getRow({ Account: account });
|
// Open navigation panel and get stocking point row
|
await appMP.formNavigation.openNavigationPanel();
|
await appMP.formNavigation.toggleEntityList();
|
const entityRows: ListRow[] = [];
|
for (const unit of units) {
|
const row = await appMP.formNavigation.listEntity.getEntityRowByName(unit, unitParents);
|
if (row) {
|
entityRows.push(row);
|
}
|
}
|
dlgUnitCost = await listUnitCost.dragEntitiesToCreateUnitCost(entityRows, accountRow);
|
// Verify dialog default value
|
const feedback = await dlgUnitCost.verifyDialogValue(account, costDriver, undefined, newUnitStartDate, timeUnit, lengthOfTime, cost);
|
expect(feedback.length).toBe(0, feedback.join('. \n'));
|
expect(units.indexOf(await dlgUnitCost.ddlUnit.getSelectedString()) > -1).toBe(true, `Unit should be defaulted to any of ${units.join(', ')}`);
|
expect(await dlgUnitCost.ddlUnit.isDisabled()).toBe(true, 'Unit drop down list should be disabled by default');
|
// Update dialog value and confirm the dialog
|
await dlgUnitCost.efCost.sendInput(newCost.toString());
|
expect(await dlgUnitCost.efCost.getComponentLabel()).toBe(CostLabel.euro(`${lengthOfTime} ${timeUnit}`), `Label of cost should be ${CostLabel.euro(`${lengthOfTime} ${timeUnit}`)}`);
|
canUpdate = await dlgUnitCost.clickOK();
|
tooltip = canUpdate ? '' : await dlgUnitCost.getOKButtonTooltip();
|
expect(canUpdate).toBe(true, LogMessage.btn_notClickable('OK', tooltip));
|
});
|
|
it('Step 2 - Verify multiple unit costs created with correct values', async () => {
|
// Verify rows created with correct values in dialog
|
for (const unit of units) {
|
const newUnit = await listUnitCost.getUnitCostRowByValues(unit, account, costDriver, newUnitStartString);
|
dlgUnitCost = await listUnitCost.openEditDialog(newUnit);
|
const verifyAfterDialogFeedback = await dlgUnitCost.verifyDialogValue(account, costDriver, unit, newUnitStartDate, undefined, undefined, newCost);
|
expect(verifyAfterDialogFeedback.length).toBe(0, verifyAfterDialogFeedback.join('. \n'));
|
await dlgUnitCost.clickCancel();
|
// Verify row created with correct values in list
|
if (newUnit !== undefined) {
|
// Verify UoM, Start, and End column value of the new row
|
expect(await listUnitCost.getCellValueFromRow(ListUnitCostColumn.UoM, newUnit)).toBe(`${DataFoodBaseAccountUoM.EuroPer}${lengthOfTime} ${timeUnit}`, `UoM of new ${unit} should be ${DataFoodBaseAccountUoM.EuroPer}${lengthOfTime} ${timeUnit}`);
|
expect(await listUnitCost.getCellValueFromRow(ListUnitCostColumn.Start, newUnit)).toBe(newUnitStartString, `Start of new ${unit} should be ${newUnitStartString}`);
|
expect(await listUnitCost.getCellValueFromRow(ListUnitCostColumn.End, newUnit)).toBe(endOfPlanningString, `End of new ${unit} should be ${endOfPlanningString}`);
|
} else {
|
expect(newUnit).toBeDefined(`New ${unit} for ${account} that starts on ${newUnitStartString} should be created`);
|
}
|
}
|
});
|
});
|