/**
|
* @file ADSO-9727
|
* @description Create fulfillment target and verify precondition
|
* @author Chan Clarence (ccn7@3ds.com)
|
* @copyright Dassault Systèmes
|
*/
|
import { qCustomMatcher } from '../../e2elib/lib/src/main/qmatchers.const';
|
import { AppMP, Demo, Scenario, Timeout } from '../../libmp/appmp';
|
import { DataMetalBaseProductName } from '../../libmp/data/data.product';
|
import { DataMetalBaseSalesSegmentName } from '../../libmp/data/data.salessegment';
|
import { DataMetalStockingPointName } from '../../libmp/data/data.stockingpoint';
|
import { DialogFulfillmentTarget, okButtonDisabledTooltip } from '../../libmp/dialogs/dialog.fulfillmenttarget';
|
import { FormFulfillmentTarget, ListFulfillmentTargetContextMenuItem } from '../../libmp/forms/form.fulfillmenttarget';
|
|
describe('ADSO-9727 - Create fulfillment target and verify precondition', () => {
|
const appMP = AppMP.getInstance();
|
let dialogFulfillmentTarget: DialogFulfillmentTarget;
|
const formFulfillmentTarget = new FormFulfillmentTarget();
|
const ftName = 'All Organics - Beverage Can';
|
const ftName2 = 'Create from action bar';
|
const ftStart = '1-Feb-2021';
|
const ftEnd = '1-Mar-2021';
|
const ftDefaultTargetPercentage = '0';
|
const ftUpdateTargetPercentage = '50.5';
|
const ftUpdateTargetPercentageRounded = '50';
|
|
beforeAll(async () => {
|
jasmine.addMatchers(qCustomMatcher);
|
await appMP.login();
|
});
|
|
afterAll(async () => {
|
await appMP.cleanupAndLogout();
|
});
|
|
afterEach(async () => {
|
await appMP.checkToastMessage();
|
});
|
|
it(`Step 1 - ${AppMP.getDemoDataPath(Demo.Metals, Scenario.Base)}`, async () => {
|
await appMP.createDemoDataset(Demo.Metals, Scenario.Base, false);
|
});
|
|
it('Step 2 - Click on action bar page "Sales".', async () => {
|
await appMP.abpSales.click();
|
});
|
|
it('Step 3 - In action bar, click button "Fulfillment Targets". The form should open docked on the right.', async () => {
|
await appMP.abpSales.btnFulfillmentTarget.clickAndWaitVisible([formFulfillmentTarget]);
|
});
|
|
it(`Step 4 - In list "Fulfillment Targets", right click and select menu "Create". Verify Name is empty.<br>
|
Verify OK disabled with precondition = "${okButtonDisabledTooltip.partialMustHaveName()}".`, async () => {
|
[dialogFulfillmentTarget] = await formFulfillmentTarget.listFulfillmentTarget.selectContextMenu(ListFulfillmentTargetContextMenuItem.Create);
|
await dialogFulfillmentTarget.verifyDialogValues({Name: ''});
|
await dialogFulfillmentTarget.verifyOKDisabled(okButtonDisabledTooltip.partialMustHaveName(), false);
|
});
|
|
it('Step 5 - Verify that both Sales Segment and Product can set as empty.', async () => {
|
await dialogFulfillmentTarget.updateDialogValues({SalesSegment: '', Product: ''});
|
});
|
|
it(`Step 6 - Set Name = "${ftName}", Sales Segment = "${DataMetalBaseSalesSegmentName.AllOrganics}" and Product = "${DataMetalBaseProductName.BeverageCan}".<br>
|
Set Start = "${ftStart}" and End = "${ftEnd}". Leave Stocking Point empty.`, async () => {
|
await dialogFulfillmentTarget.updateDialogValues({Name: ftName, SalesSegment: DataMetalBaseSalesSegmentName.AllOrganics,
|
Product: DataMetalBaseProductName.BeverageCan, StockingPoint: '',
|
Start: ftStart, End: ftEnd});
|
});
|
|
it(`Step 7 - Verify default Target Percentage = ${ftDefaultTargetPercentage}. Verify OK disabled with precondition = "${okButtonDisabledTooltip.partialMustLargerZero(ftDefaultTargetPercentage)}".`, async () => {
|
await dialogFulfillmentTarget.verifyDialogValues({TargetPercentage: ftDefaultTargetPercentage});
|
await dialogFulfillmentTarget.verifyOKDisabled(okButtonDisabledTooltip.partialMustLargerZero(ftDefaultTargetPercentage), false);
|
});
|
|
it(`Step 8 - Set Target Percentage = "${ftUpdateTargetPercentage}" and verify OK enabled. Click OK.`, async () => {
|
await dialogFulfillmentTarget.updateDialogValues({TargetPercentage: ftUpdateTargetPercentage});
|
await dialogFulfillmentTarget.clickOK(Timeout.ButtonState);
|
});
|
|
it(`Step 9 - Verify fulfillment target created in list, with Target percentage = ${ftUpdateTargetPercentageRounded} (rounding, no decimal shown in list).`, async () => {
|
const row = await formFulfillmentTarget.listFulfillmentTarget.getRow({Name: ftName});
|
await formFulfillmentTarget.listFulfillmentTarget.verifyRowValues(row, {Start: ftStart, End: ftEnd, 'Target (%)': ftUpdateTargetPercentageRounded});
|
});
|
|
it(`Step 10 - Right click and select menu "Create".<br>
|
In dialog, enter all the same values as before and verify OK disabled with precondition = "${okButtonDisabledTooltip.partialMustUnique()}". Click Cancel to dismiss dialog.`, async () => {
|
[dialogFulfillmentTarget] = await formFulfillmentTarget.listFulfillmentTarget.selectContextMenu(ListFulfillmentTargetContextMenuItem.Create);
|
// Name need not be unique thus can re-use
|
await dialogFulfillmentTarget.updateDialogValues({Name: ftName, SalesSegment: DataMetalBaseSalesSegmentName.AllOrganics,
|
Product: DataMetalBaseProductName.BeverageCan, StockingPoint: '',
|
Start: ftStart, End: ftEnd, TargetPercentage: ftUpdateTargetPercentage});
|
// The disabled OK proven that previous created values same with current dialog (must unique)
|
await dialogFulfillmentTarget.verifyOKDisabled(okButtonDisabledTooltip.partialMustUnique(), false);
|
await dialogFulfillmentTarget.clickCancel();
|
});
|
|
it(`Step 11 - Focus on Fulfillment Targets list and click Create action bar button.<br>
|
In dialog, set Name = "${ftName2}", Stocking Point = "${DataMetalStockingPointName.Asia}" and Sales Segment = "${DataMetalBaseSalesSegmentName.Cans}".<br>
|
Set Start = "${ftStart}", End = "${ftEnd}" and Target Percentage = ${ftUpdateTargetPercentage}. Leave Product empty. Click OK to save.`, async () => {
|
dialogFulfillmentTarget = await formFulfillmentTarget.listFulfillmentTarget.clickActionButton(appMP.abpSales.btnCreate);
|
await dialogFulfillmentTarget.updateDialogValues({Name: ftName2, StockingPoint: DataMetalStockingPointName.Asia,
|
SalesSegment: DataMetalBaseSalesSegmentName.Cans, Product: '',
|
Start: ftStart, End: ftEnd, TargetPercentage: ftUpdateTargetPercentage});
|
await dialogFulfillmentTarget.clickOK();
|
});
|
|
it(`Step 12 - Verify fulfillment target created in list, with Target percentage = ${ftUpdateTargetPercentageRounded} (rounding, no decimal shown in list).`, async () => {
|
const row = await formFulfillmentTarget.listFulfillmentTarget.getRow({Name: ftName2});
|
await formFulfillmentTarget.listFulfillmentTarget.verifyRowValues(row, {Start: ftStart, End: ftEnd, 'Target (%)': ftUpdateTargetPercentageRounded});
|
});
|
|
it(`Step 13 - Edit the created fulfillment target and verify Stocking Point = "${DataMetalStockingPointName.Asia}",
|
Sales Segment = "${DataMetalBaseSalesSegmentName.Cans}", Product is empty and Target Percentage = ${ftUpdateTargetPercentage}.<br>
|
Click Cancel to dismiss dialog.`, async () => {
|
const row = await formFulfillmentTarget.listFulfillmentTarget.getRow({Name: ftName2});
|
await formFulfillmentTarget.listFulfillmentTarget.selectContextMenu(ListFulfillmentTargetContextMenuItem.Edit, row);
|
await dialogFulfillmentTarget.verifyDialogValues({StockingPoint: DataMetalStockingPointName.Asia, SalesSegment: DataMetalBaseSalesSegmentName.Cans,
|
Product: '', TargetPercentage: ftUpdateTargetPercentage});
|
await dialogFulfillmentTarget.clickCancel();
|
});
|
});
|