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
80
81
82
83
84
85
86
87
88
/**
 * @file        ADSO-10204
 * @description Select parent level items in the navigation panel (Products)
 * @author      CHEAH Meng Yew (MengYew.CHEAH@3ds.com)
 * @copyright   Dassault Systemes
 */
 import { qCustomMatcher } from '../../../e2elib/lib/src/main/qmatchers.const';
 import { AppMP, Demo, Scenario  } from '../../../libmp/appmp';
 import { DataRowCheckBoxDecoration, StepList } from '../../../libappsop/listsop';
 import { ListProduct, ListProductColumn, StepNavigationPanel } from '../../../libmp/forms/navigationpanel/form.navigationpanel';
 import { dataFoodProducts, dataFoodProductsProvider } from '../../../libmp/data/data.product';
 
 describe('ADSO-10204 - Select parent level items in the navigation panel Products', () => {
  const appMP = AppMP.getInstance();
  const listNavProduct = appMP.formNavigation.listProduct;
  let name: ListProductColumn;
  let parent: ListProductColumn[] | undefined;
  beforeAll(async () => {
    jasmine.addMatchers(qCustomMatcher);
    await appMP.login();
  });
 
  afterAll(async () => {
    await appMP.cleanupAndLogout();
  });
 
  afterEach(async () => {
    await appMP.checkToastMessage();
  });
 
  it(`Setup - ${AppMP.getDemoDataPath(Demo.Food, Scenario.Base)}`, async () => {
    await appMP.createDemoDataset(Demo.Food, Scenario.Base, false);
  });
 
  it(`Step 1 - ${StepNavigationPanel.openNavigationPanel()}`, async () => {
    await appMP.formNavigation.openNavigationPanel();
  });
 
  it(`Step 2 - ${StepNavigationPanel.showProductsList()}`, async () => {
    await appMP.formNavigation.toggleProductList(true);
  });
 
  it(`Step 3 - ${StepNavigationPanel.checkProducts([dataFoodProducts.Lowfat.Name])}`, async () => {
    // New mechanism to pass only the product name to 'dataFoodProductsProvider' to retrieve the ancestors recursively for easy maintenance
    [name, parent] = listNavProduct.getHierarchy(dataFoodProductsProvider, dataFoodProducts.Lowfat);
    const lowFatRow = await listNavProduct.getRow(name, parent);
    await listNavProduct.toggleRowCheckbox(lowFatRow, true);
    await lowFatRow.expandRow();
  });
 
  it(`Step 4 - ${StepList.verifyChildrenRowsChecked (ListProduct.title, dataFoodProducts.Lowfat.Name)}`, async () => {
    await listNavProduct.verifyChildrenRowsChecked(true, name, parent);
  });
 
  it(`Step 5 - ${StepList.verifyCheckBoxRowDecoration (ListProduct.title, dataFoodProducts.Lowfat.Name, DataRowCheckBoxDecoration.DarkDecorated)}`, async () => {
    await listNavProduct.verifyRowCheckBoxDecoration([dataFoodProductsProvider, dataFoodProducts.Lowfat], DataRowCheckBoxDecoration.DarkDecorated);
  });
 
  it(`Step 6 - ${StepList.verifyCheckBoxRowDecoration (ListProduct.title, dataFoodProducts.FinishedGoods.Name, DataRowCheckBoxDecoration.LightDecorated)}`, async () => {
    await listNavProduct.verifyRowCheckBoxDecoration([dataFoodProductsProvider, dataFoodProducts.FinishedGoods], DataRowCheckBoxDecoration.LightDecorated);
  });
 
  it(`Step 7 - ${StepList.verifyCheckBoxRowDecoration (ListProduct.title, dataFoodProducts.AllProducts.Name, DataRowCheckBoxDecoration.LightDecorated)}`, async () => {
    await listNavProduct.verifyRowCheckBoxDecoration([dataFoodProductsProvider, dataFoodProducts.AllProducts], DataRowCheckBoxDecoration.LightDecorated);
  });
 
  it (`Step 8 - ${StepNavigationPanel.unCheckProducts ([dataFoodProducts.Lowfat.Name])}`, async () => {
    const lowFatRow = await listNavProduct.getRow(name, parent);
    await listNavProduct.toggleRowCheckbox(lowFatRow, false);
    await lowFatRow.expandRow();
  });
 
  it (`Step 9 - ${StepList.verifyChildrenRowsUnchecked (ListProduct.title, dataFoodProducts.Lowfat.Name)}`, async () => {
    await listNavProduct.verifyChildrenRowsChecked(false, name, parent);
  });
 
  it (`Step 10 - ${StepList.verifyCheckBoxRowNoDecoration (ListProduct.title, dataFoodProducts.Lowfat.Name)}`, async () => {
    await listNavProduct.verifyRowCheckBoxDecoration([dataFoodProductsProvider, dataFoodProducts.Lowfat], DataRowCheckBoxDecoration.None);
  });
 
  it (`Step 11 - ${StepList.verifyCheckBoxRowNoDecoration (ListProduct.title, dataFoodProducts.FinishedGoods.Name)}`, async () => {
    await listNavProduct.verifyRowCheckBoxDecoration([dataFoodProductsProvider, dataFoodProducts.FinishedGoods], DataRowCheckBoxDecoration.None);
  });
 
  it (`Step 12 - ${StepList.verifyCheckBoxRowNoDecoration (ListProduct.title, dataFoodProducts.AllProducts.Name)}`, async () => {
    await listNavProduct.verifyRowCheckBoxDecoration([dataFoodProductsProvider, dataFoodProducts.AllProducts], DataRowCheckBoxDecoration.None);
  });
 });