/**
|
* @file ADSO-10109
|
* @description Edit start and cost of single unit cost and verify the result
|
* @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 { AppMP, Demo, Scenario } from '../../../libmp/appmp';
|
import { ListUnitCost, ListUnitCostColumn } from '../../../libmp/forms/form.unitcost';
|
import { DataFoodBaseAccountUoM } from '../../../libmp/data/data.account';
|
import { startOfPlanningYear } from '../../../libmp/data/data.period';
|
|
describe('ADSO-10109 - Edit start and cost of single unit cost and verify the result', () => {
|
const appMP = AppMP.getInstance();
|
let listUnitCost: ListUnitCost;
|
let startOfPlanningDate: Date;
|
let eopString: string;
|
let sopYear: string;
|
const janSOPMinus1 = `1-Jan-${startOfPlanningYear - 1}`;
|
|
const uom = DataFoodBaseAccountUoM.EuroPerMonth;
|
|
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}. Get start and end of planning`, async () => {
|
// Open Periods view
|
await appMP.viewPeriod.switchTo();
|
const formPeriod = appMP.viewPeriod.frmPeriod;
|
({ startOfPlanningDate, sopYear, eopString } = await formPeriod.getStartAndEndOfPlanning());
|
});
|
|
it(`Setup - Open view ${appMP.viewAccount.viewPath}. Verify General fixed costs exists with cost driver Fixed & UoM as € / Month`, async () => {
|
await appMP.viewAccount.switchTo();
|
|
// Verify General fixed costs exists with cost driver Fixed
|
const listAccount = appMP.viewAccount.frmAccount.listAccount;
|
const accRow = await listAccount.getRow({ Name: 'General fixed costs' }, [{ Name: 'Cost of sales' }]);
|
await listAccount.verifyRowValues(accRow, { 'Default cost driver': 'Fixed' });
|
});
|
|
it(`Setup - Open view ${appMP.viewUnitCost.viewPath}. Verify General fixed costs exists with cost driver Fixed & UoM as € / Month`, async () => {
|
// Open Unit Costs view
|
await appMP.viewUnitCost.switchTo();
|
const listUnitAccount = appMP.viewUnitCost.frmUnitAccount.listAccount;
|
listUnitCost = appMP.viewUnitCost.frmUnitCost.listUnitCost;
|
// Verify General fixed costs exists with UoM as € / Month.
|
const account = await listUnitAccount.getRow({ Account: 'General fixed costs' });
|
await listUnitAccount.verifyRowValues(account, { 'Default UoM': uom });
|
});
|
|
it('Setup - Verify DE Fermenter exist', async () => {
|
// Filter by DE Fermenter
|
await appMP.formNavigation.filterByEntity('DE Fermenter', ['Europe', 'Plants', 'Denmark Plant']);
|
// Verify 1 DE Fermenter Unit Cost exist in the list
|
await listUnitCost.waitForScreenUpdate();
|
expect(await listUnitCost.getRowCount()).toBe(1, 'Exactly one DE Fermenter Unit Cost should exist in the list');
|
const unitCost = await listUnitCost.getRowByIndex(0);
|
expect(await (await unitCost.getCell(ListUnitCostColumn.Start)).getValue()).toBe(janSOPMinus1, `Start of the DE Fermenter unit cost should be ${janSOPMinus1}`);
|
});
|
|
it('Step 1 - Edit start and cost of single unit cost and verify the result', async () => {
|
// Open create edit unit cost dialog
|
const unitCost = await listUnitCost.getRowByIndex(0);
|
const dlgUnitCost = await listUnitCost.openEditDialog(unitCost);
|
// Verify all field in the dialog
|
const verifyAfterDialogFeedback = await dlgUnitCost.verifyDialogValue('General fixed costs', 'Fixed', 'DE Fermenter', new Date(janSOPMinus1), 'Month', 1, 1000);
|
expect(verifyAfterDialogFeedback.length).toBe(0, verifyAfterDialogFeedback.join('. '));
|
// Update start and cost
|
await dlgUnitCost.updateUnitCostValue(undefined, undefined, undefined, new Date(startOfPlanningDate.getFullYear(), 1, 1), undefined, undefined, 2000);
|
await dlgUnitCost.clickOK();
|
// Verify start and cost is updated
|
expect(await listUnitCost.getCellValueFromRow(ListUnitCostColumn.Cost, unitCost)).toBe('2,000', 'Cost of DE Fermenter should be updated to 2,000');
|
expect(await listUnitCost.getCellValueFromRow(ListUnitCostColumn.Start, unitCost)).toBe(`1-Feb-${sopYear}`, `Start of DE Fermenter should be updated to 1-Feb-${sopYear}`);
|
expect(await listUnitCost.getCellValueFromRow(ListUnitCostColumn.End, unitCost)).toBe(eopString, `End of DE Fermenter should be ${eopString}`);
|
});
|
});
|