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
/**
 * @file        ADSO-50208
 * @description Navigate and visualize forecasts
 * Strategy used to test, will NOT verify all rows filtered based on certain stocking point/product/sales segment
 * as it will be very slow for UI automation. Instead, get first row and check that after filtering in navigation panel,
 * the first row is now based on the filtering criteria.
 * @author      Clarence (ccn7@3ds.com)
 * @copyright   Dassault Systèmes
 */
import { AppMP, Demo, Scenario } from '../../libmp/appmp';
import { StepNavigationPanel } from '../../libmp/forms/navigationpanel/form.navigationpanel';
import { StepList } from '../../libappsop/listsop';
import { DataMetalBaseProductName } from '../../libmp/data/data.product';
import { DataMetalBaseSalesSegmentName } from '../../libmp/data/data.salessegment';
import { dataMetalsUnits, dataMetalsUnitsProvider } from '../../libmp/data/data.unit';
 
describe('ADSO-50208 - Navigate and visualize forecasts', () => {
  const appMP = AppMP.getInstance();
  const listNavEntity = appMP.formNavigation.listEntity;
  const listNavProduct = appMP.formNavigation.listProduct;
  const listNavSalesSegment = appMP.formNavigation.listSalesSegment;
  const listForecasts = appMP.viewForecasts.formForecasts.listForecasts;
  const asiaSP = dataMetalsUnits.AsiaSP.Name;
  const northAmericaSP = dataMetalsUnits.NorthAmericaSP.Name;
 
  beforeAll(async () => {
    await appMP.login();
  });
 
  afterAll(async () => {
    await appMP.resetActiveView(appMP.viewForecasts);
    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 - Open view ${appMP.viewForecasts.viewPath}.`, async () => {
    await appMP.viewForecasts.switchTo();
  });
 
  it(`Step 3 - ${StepNavigationPanel.showEntitiesList()} ${StepList.verifyRowValuesForRowNum(listForecasts.title, 1, {'Stocking point': northAmericaSP})}`, async () => {
    await appMP.formNavigation.toggleEntityList(true);
 
    // Before filtering stocking point, check the 1st row is North America (we will filter Asia in next step)
    const firstForecastRow = await listForecasts.getRowByIndex(0);
    await listForecasts.verifyRowValues(firstForecastRow, {'Stocking point': northAmericaSP});
  });
 
  it(`Step 4 - ${StepNavigationPanel.checkStockingPoints([asiaSP])} ${StepList.verifyRowValuesForRowNum(listForecasts.title, 1, {'Stocking point': asiaSP, Product: DataMetalBaseProductName.BCCBNarrow})}`, async () => {
    // Check Asia and verify 1st row is now Asia forecast
    const row = await listNavEntity.getRow([dataMetalsUnitsProvider, dataMetalsUnits.AsiaSP]);
    await listNavEntity.toggleRowCheckbox(row, true);
 
    // Also verify 1st row product is BC CB narrow as next step will filter product that belong to another product family
    const firstForecastRow = await listForecasts.getRowByIndex(0);
    await listForecasts.verifyRowValues(firstForecastRow, {'Stocking point': asiaSP, Product: DataMetalBaseProductName.BCCBNarrow});
  });
 
  it(`Step 5 - ${StepNavigationPanel.showProductsList()} ${StepNavigationPanel.checkProducts([DataMetalBaseProductName.BCCanTab])}`, async () => {
    await appMP.formNavigation.toggleProductList(true);
 
    const filterByProductFamily = await listNavProduct.getRow({Name: DataMetalBaseProductName.BCCanTab}, [{Name: DataMetalBaseProductName.AllProducts}, {Name: DataMetalBaseProductName.Can}, {Name: DataMetalBaseProductName.BeverageCan}]);
    await listNavProduct.toggleRowCheckbox(filterByProductFamily, true);
  });
 
  it(`Step 6 - ${StepList.verifyRowValuesForRowNum(listForecasts.title, 1, {Product: DataMetalBaseProductName.BCCTClearCoated, 'Stocking point': asiaSP})}`, async () => {
    const firstForecastRow = await listForecasts.getRowByIndex(0);
    await listForecasts.verifyRowValues(firstForecastRow, {Product: DataMetalBaseProductName.BCCTClearCoated, 'Stocking point': asiaSP});
  });
 
  it(`Step 7 - ${StepNavigationPanel.showSalesSegmentsList()} ${StepNavigationPanel.checkSalesSegments([DataMetalBaseSalesSegmentName.Automotive])}`, async () => {
    await appMP.formNavigation.toggleSalesSegmentList(true);
 
    const filterBySalesSegment = await listNavSalesSegment.getRow({Name: DataMetalBaseSalesSegmentName.Automotive}, [{Name: DataMetalBaseSalesSegmentName.AllSalesSegments}]);
    await listNavSalesSegment.toggleRowCheckbox(filterBySalesSegment, true);
  });
 
  it(`Step 8 - ${StepList.verifyTotalRow(listForecasts.title, 0)}`, async () => {
    await listForecasts.verifyTotalRow(0, 'Expected no forecast in list as none matching Automotive segment, Asia stocking point and BC can tab product family.');
  });
 
  it(`Step 9 - ${StepNavigationPanel.clickHomeResetToRoot()} ${StepList.verifyRowValuesForRowNum(listForecasts.title, 1, {'Sales segment': DataMetalBaseSalesSegmentName.AllOrganics})}`, async () => {
    await appMP.formNavigation.resetNaviToRoot();
 
    const firstForecastRow = await listForecasts.getRowByIndex(0);
    await listForecasts.verifyRowValues(firstForecastRow, {'Sales segment': DataMetalBaseSalesSegmentName.AllOrganics});
  });
 
  it(`Step 10 - ${StepNavigationPanel.checkSalesSegments([DataMetalBaseSalesSegmentName.Automotive])}`, async () => {
    const filterBySalesSegment = await listNavSalesSegment.getRow({Name: DataMetalBaseSalesSegmentName.Automotive}, [{Name: DataMetalBaseSalesSegmentName.AllSalesSegments}]);
    await listNavSalesSegment.toggleRowCheckbox(filterBySalesSegment, true);
  });
 
  it(`Step 11 - ${StepList.verifyRowValuesForRowNum(listForecasts.title, 1, {'Sales segment': DataMetalBaseSalesSegmentName.AudiA8})}`, async () => {
    const firstForecastRow = await listForecasts.getRowByIndex(0);
    await listForecasts.verifyRowValues(firstForecastRow, {'Sales segment': DataMetalBaseSalesSegmentName.AudiA8});
  });
});