yanweiyuan3
2023-08-09 588bc7829387dfc761cc25f06f77d4c81818bd10
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/**
 * @file        ADSO-50247
 * @description Adjust customer orders - Multiply
 * @author      Clarence (ccn7@3ds.com)
 * @copyright   Dassault Systèmes
 */
import { AppMP, StepAppMP } from '../../libmp/appmp';
import { ListCustomerOrdersColumn, ListCustomerOrdersContextMenuItem } from '../../libmp/forms/form.customerorders';
import { DataMetalBaseSalesSegmentName } from '../../libmp/data/data.salessegment';
import { DataMetalBaseProductName } from '../../libmp/data/data.product';
import { DataMetalStockingPointName } from '../../libmp/data/data.stockingpoint';
import { StepList } from '../../libappsop/listsop';
import { StepActionBarPage } from '../../libappsop/actionbarpagesop';
import { DialogForecastAdjustQuantity } from '../../libmp/dialogs/dialog.forecastadjustquantity';
import { DataAdjustForecastQuantityMode } from '../../libmp/data/data.forecasts';
import { StepDialog } from '../../libappsop/dialogsop';
import { startOfPlanningYear } from '../../libmp/data/data.period';
 
describe('ADSO-50247 - Adjust customer orders - Multiply', () => {
  const appMP = AppMP.getInstance();
  const scenarioToSelect = 'ADSO-50251';
  const janSOP = `1-Jan-${startOfPlanningYear}`;
  const listCustomerOrders = appMP.viewCustomerOrders.formCustomerOrders.listCustomerOrders;
  const dlgAdjustQuantity: DialogForecastAdjustQuantity = new DialogForecastAdjustQuantity();
  const adjustRows: ListCustomerOrdersColumn[] = [{'Sales segment': DataMetalBaseSalesSegmentName.CanManChina, Product: DataMetalBaseProductName.BCCBWide, 'Stocking point': DataMetalStockingPointName.Asia, 'Order date': janSOP, Quantity: '300'},
                                                  {'Sales segment': DataMetalBaseSalesSegmentName.CanManChina, Product: DataMetalBaseProductName.BCCBWide, 'Stocking point': DataMetalStockingPointName.Asia, 'Order date': janSOP, Quantity: '400'}];
  const adjustedRows: ListCustomerOrdersColumn[] = [{...adjustRows[0], Quantity: '750'}, {...adjustRows[1], Quantity: '1,000'}];
  const adjustedRows2: ListCustomerOrdersColumn[] = [{...adjustedRows[0], Quantity: '375'}, {...adjustedRows[1], Quantity: '500'}];
 
  beforeAll(async () => {
    await appMP.login();
  });
 
  afterAll(async () => {
    await appMP.resetActiveView(appMP.viewCustomerOrders);
    await appMP.cleanupAndLogout();
  });
 
  afterEach(async () => {
    await appMP.checkToastMessage();
  });
 
  it(`Step 1 - ${StepAppMP.selectScenario(scenarioToSelect)}`, async () => {
    await appMP.selectScenario(scenarioToSelect);
  });
 
  it(`Step 2 - Open view ${appMP.viewCustomerOrders.viewPath}.`, async () => {
    await appMP.viewCustomerOrders.switchTo();
  });
 
  it(`Step 3 - ${StepList.selectRowsAndClickMenu(listCustomerOrders.title, adjustRows, ListCustomerOrdersContextMenuItem.AdjustQuantity.Label)}`, async () => {
    const rows = await listCustomerOrders.getRows(adjustRows);
    await listCustomerOrders.selectRows(rows);
    await listCustomerOrders.selectContextMenu(ListCustomerOrdersContextMenuItem.AdjustQuantity, rows, dlgAdjustQuantity);
  });
 
  it(`Step 4 - ${StepDialog.updateDialogValues(DialogForecastAdjustQuantity.title, {AdjustMode: DataAdjustForecastQuantityMode.Multiply})} ${StepDialog.verifyOKDisabled()}`, async () => {
    await dlgAdjustQuantity.updateDialogValues({AdjustMode: DataAdjustForecastQuantityMode.Multiply});
    await dlgAdjustQuantity.verifyOKDisabled();
  });
 
  it(`Step 5 - ${StepDialog.updateDialogValues(DialogForecastAdjustQuantity.title, {Value: '-2'})} ${StepDialog.verifyOKDisabled()}`, async () => {
    await dlgAdjustQuantity.updateDialogValues({Value: '-2'});
    await dlgAdjustQuantity.verifyOKDisabled();
  });
 
  it(`Step 6 - ${StepDialog.updateDialogValues(DialogForecastAdjustQuantity.title, {Value: '2.5'})} ${StepDialog.clickOK()}`, async () => {
    await dlgAdjustQuantity.updateDialogValues({Value: '2.5'});
    await dlgAdjustQuantity.clickOK();
  });
 
  it(`Step 7 - ${StepList.verifyRowExists(listCustomerOrders.title, adjustedRows[0])} ${StepList.verifyRowExists(listCustomerOrders.title, adjustedRows[1])}`, async () => {
    await listCustomerOrders.verifyRowExists(adjustedRows[0]);
    await listCustomerOrders.verifyRowExists(adjustedRows[1]);
  });
 
  it(`Step 8 - ${StepList.selectRows(listCustomerOrders.title, adjustedRows)} ${StepActionBarPage.clickButton('Adjust quantity')}`, async () => {
    const rows = await listCustomerOrders.getRows(adjustedRows);
    await listCustomerOrders.selectRows(rows);
    await listCustomerOrders.clickActionButton(appMP.abpSales.btnAdjustQuantity, undefined, rows, dlgAdjustQuantity);
  });
 
  it(`Step 9 - ${StepDialog.updateDialogValues(DialogForecastAdjustQuantity.title, {AdjustMode: DataAdjustForecastQuantityMode.Multiply, Value: '0.5'})} ${StepDialog.clickOK()}`, async () => {
    await dlgAdjustQuantity.updateDialogValues({AdjustMode: DataAdjustForecastQuantityMode.Multiply, Value: '0.5'});
    await dlgAdjustQuantity.clickOK();
  });
 
  it(`Step 10 - ${StepList.verifyRowExists(listCustomerOrders.title, adjustedRows2[0])} ${StepList.verifyRowExists(listCustomerOrders.title, adjustedRows2[1])}`, async () => {
    await listCustomerOrders.verifyRowExists(adjustedRows2[0]);
    await listCustomerOrders.verifyRowExists(adjustedRows2[1]);
  });
});