renhao
2023-09-21 1aa9f2bb83dd9e4b7517f1cbf06b0db53979bb31
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
/**
 * @file        ADSO-50251
 * @description Visualize customer order with invalid PISP
 * @author      Clarence (ccn7@3ds.com)
 * @copyright   Dassault Systèmes
 */
import { AppMP, StepAppMP } from '../../libmp/appmp';
import { DataMetalBaseSalesSegmentName } from '../../libmp/data/data.salessegment';
import { DataMetalBaseProductName } from '../../libmp/data/data.product';
import { ListCustomerOrdersColumn } from '../../libmp/forms/form.customerorders';
import { DataIconEmoticons } from '../../libappsop/data.iconnames';
import { StepList } from '../../libappsop/listsop';
import { StepNavigationPanel } from '../../libmp/forms/navigationpanel/form.navigationpanel';
import { startOfPlanningYear } from '../../libmp/data/data.period';
 
describe('ADSO-50251 - Visualize customer order with invalid PISP', () => {
  const appMP = AppMP.getInstance();
  const scenarioToSelect = 'ADSO-50251';
  const janSOP = `1-Jan-${startOfPlanningYear}`;
  const listCustomerOrders = appMP.viewCustomerOrders.formCustomerOrders.listCustomerOrders;
  // Invalid as stocking point is empty as invalid stocking point passed in during creation in UTF
  const invalidRow: ListCustomerOrdersColumn = {'Stocking point': '', 'Sales segment': DataMetalBaseSalesSegmentName.CanManChina, Product: DataMetalBaseProductName.BCCBWide, 'Order date': janSOP};
 
  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.verifyRowExists(listCustomerOrders.title, invalidRow)}`, async () => {
    await listCustomerOrders.verifyRowExists(invalidRow);
  });
 
  it(`Step 4 - ${StepList.verifyRowConstraintViolation(listCustomerOrders.title, invalidRow, true)}`, async () => {
    const row = await listCustomerOrders.getRow(invalidRow);
    await listCustomerOrders.verifyRowHasOnDrawImage(row, DataIconEmoticons.ConstraintViolations);
  });
 
  it(`Step 5 - ${StepNavigationPanel.showSalesSegmentsList()} ${StepNavigationPanel.checkSalesSegments([DataMetalBaseSalesSegmentName.Automotive])}`, async () => {
    await appMP.formNavigation.toggleSalesSegmentList(true);
 
    // Filter sales segment by segment that does NOT intersect with the invalid customer order
    // To prove that customer order with invalid PISP always shown regardless of navigation panel filtering
    const row = await appMP.formNavigation.listSalesSegment.getRow({Name: DataMetalBaseSalesSegmentName.Automotive}, [{Name: DataMetalBaseSalesSegmentName.AllSalesSegments}]);
    await appMP.formNavigation.listSalesSegment.toggleRowCheckbox(row, true);
  });
 
  it(`Step 6 - ${StepList.verifyRowExists(listCustomerOrders.title, invalidRow)}`, async () => {
    await listCustomerOrders.verifyRowExists(invalidRow);
  });
 
  it(`Step 7 - ${StepNavigationPanel.showProductsList()} ${StepNavigationPanel.checkProducts([DataMetalBaseProductName.Automotive])}`, async () => {
    await appMP.formNavigation.toggleProductList(true);
 
    // Filter product by product that does NOT intersect with the invalid customer order
    // To prove that customer order with invalid PISP always shown regardless of navigation panel filtering
    const row = await appMP.formNavigation.listProduct.getRow({Name: DataMetalBaseProductName.Automotive}, [{Name: DataMetalBaseProductName.AllProducts}]);
    await appMP.formNavigation.listSalesSegment.toggleRowCheckbox(row, true);
  });
 
  it(`Step 8 - ${StepList.verifyRowExists(listCustomerOrders.title, invalidRow)}`, async () => {
    await listCustomerOrders.verifyRowExists(invalidRow);
  });
});