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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
/**
 * @file        ADSO-50239
 * @description Navigate and visualize customer orders
 * Strategy used to test, use UTF to create copy of demo data.
 * Remove all customer orders and create few data for easy verification.
 * @author      Clarence (ccn7@3ds.com)
 * @copyright   Dassault Systèmes
 */
import { AppMP, StepAppMP } from '../../libmp/appmp';
import { DataMetalBaseEntityName } from '../../libmp/data/data.navigation';
import { StepNavigationPanel } from '../../libmp/forms/navigationpanel/form.navigationpanel';
import { DataMetalBaseProductName } from '../../libmp/data/data.product';
import { DataMetalBaseSalesSegmentName } from '../../libmp/data/data.salessegment';
import { DataMetalStockingPointName } from '../../libmp/data/data.stockingpoint';
import { ListCustomerOrdersColumn } from '../../libmp/forms/form.customerorders';
import { StepList } from '../../libappsop/listsop';
 
describe('ADSO-50239 - Navigate and visualize customer orders', () => {
  const appMP = AppMP.getInstance();
  const scenarioToSelect = 'ADSO-50251';
  const listNavEntity = appMP.formNavigation.listEntity;
  const listNavProduct = appMP.formNavigation.listProduct;
  const listNavSalesSegment = appMP.formNavigation.listSalesSegment;
  const listCustomerOrders = appMP.viewCustomerOrders.formCustomerOrders.listCustomerOrders;
  const customerOrders: ListCustomerOrdersColumn[] = [{'Sales segment': DataMetalBaseSalesSegmentName.CanManChina, Product: DataMetalBaseProductName.BCCBWide, 'Stocking point': DataMetalStockingPointName.Asia},
                                                      {'Sales segment': DataMetalBaseSalesSegmentName.CanManChina, Product: DataMetalBaseProductName.BCCTClearCoated, 'Stocking point': DataMetalStockingPointName.Asia},
                                                      {'Sales segment': DataMetalBaseSalesSegmentName.AudiA8, Product: DataMetalBaseProductName.BCCBWide, 'Stocking point': DataMetalStockingPointName.Europe}];
 
  // Function to loop each expected row (whether shown).
  // Each time check/uncheck navigation panel, we verify the same rows whether exist/not.
  const funcVerifyRowsShown = (async (expectedCustomerOrderRowsShown: boolean[]): Promise<void> => {
    for (let x = 0; x < customerOrders.length; x++) {
      const expectedShown = expectedCustomerOrderRowsShown[x];
      if (expectedShown) {
        await listCustomerOrders.verifyRowExists(customerOrders[x]);
      } else {
        await listCustomerOrders.verifyRowNotExist(customerOrders[x]);
      }
    }
  });
 
  // Function to retrieve the step description when verifying each expected row shown/not.
  const funcStepDescriptionVerifyRowsShown = ((expectedCustomerOrderRowsShown: boolean[]): string => {
    let stepDescription = '';
    for (let x = 0; x < customerOrders.length; x++) {
      const expectedShown = expectedCustomerOrderRowsShown[x];
      stepDescription = expectedShown ?
                        stepDescription.concat(StepList.verifyRowExists(listCustomerOrders.title, customerOrders[x]), ' ') :
                        stepDescription.concat(StepList.verifyRowNotExist(listCustomerOrders.title, customerOrders[x]), ' ');
    }
    return stepDescription;
  });
 
  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 - ${StepNavigationPanel.showEntitiesList()} ${StepNavigationPanel.checkStockingPoints([DataMetalStockingPointName.Asia])}`, async () => {
    await appMP.formNavigation.toggleEntityList(true);
 
    const row = await listNavEntity.getEntityRowByName(DataMetalStockingPointName.Asia, [DataMetalBaseEntityName.QAluminum, DataMetalBaseEntityName.Asia]);
    await listNavEntity.toggleRowCheckbox(row, true);
  });
 
  it(`Step 4 - ${funcStepDescriptionVerifyRowsShown([true, true, false])}`, async () => {
    await funcVerifyRowsShown([true, true, false]);
  });
 
  it(`Step 5 - ${StepNavigationPanel.showProductsList()} ${StepNavigationPanel.checkProducts([DataMetalBaseProductName.BCCanBody])}`, async () => {
    await appMP.formNavigation.toggleProductList(true);
 
    const row = await listNavProduct.getRow({Name: DataMetalBaseProductName.BCCanBody}, [{Name: DataMetalBaseProductName.AllProducts}, {Name: DataMetalBaseProductName.Can}, {Name: DataMetalBaseProductName.BeverageCan}]);
    await listNavEntity.toggleRowCheckbox(row, true);
  });
 
  it(`Step 6 - ${funcStepDescriptionVerifyRowsShown([true, false, false])}`, async () => {
    await funcVerifyRowsShown([true, false, false]);
  });
 
  it(`Step 7 - ${StepNavigationPanel.showSalesSegmentsList()} ${StepNavigationPanel.checkSalesSegments([DataMetalBaseSalesSegmentName.Automotive])}`, async () => {
    await appMP.formNavigation.toggleSalesSegmentList(true);
 
    const row = await listNavSalesSegment.getRow({Name: DataMetalBaseSalesSegmentName.Automotive}, [{Name: DataMetalBaseSalesSegmentName.AllSalesSegments}]);
    await listNavSalesSegment.toggleRowCheckbox(row, true);
  });
 
  it(`Step 8 - ${funcStepDescriptionVerifyRowsShown([false, false, false])}`, async () => {
    await funcVerifyRowsShown([false, false, false]);
  });
 
  it(`Step 9 - ${StepNavigationPanel.clickHomeResetToRoot()}`, async () => {
    await appMP.formNavigation.resetNaviToRoot();
  });
 
  it(`Step 10 - ${funcStepDescriptionVerifyRowsShown([true, true, true])}`, async () => {
    await funcVerifyRowsShown([true, true, true]);
  });
 
  it(`Step 11 - ${StepNavigationPanel.checkSalesSegments([DataMetalBaseSalesSegmentName.Automotive])}`, async () => {
    const row = await listNavSalesSegment.getRow({Name: DataMetalBaseSalesSegmentName.Automotive}, [{Name: DataMetalBaseSalesSegmentName.AllSalesSegments}]);
    await listNavSalesSegment.toggleRowCheckbox(row, true);
  });
 
  it(`Step 12 - ${funcStepDescriptionVerifyRowsShown([false, false, true])}`, async () => {
    await funcVerifyRowsShown([false, false, true]);
  });
});