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
/**
 * @file        ADSO-10203
 * @description Select parent level items in the navigation panel (units)
 * @testcategory Web - Navigation
 * @author      Meng Yew Cheah (MengYew.CHEAH@3ds.com)
 * @copyright   Dassault Systemes
 */
 import { qCustomMatcher } from '../../../e2elib/lib/src/main/qmatchers.const';
 import { AppMP, Demo, Scenario } from '../../../libmp/appmp';
 import { ListEntityColumn, StepNavigationPanel } from '../../../libmp/forms/navigationpanel/form.navigationpanel';
 import { dataFoodUnits, dataFoodUnitsProvider } from '../../../libmp/data/data.unit';
 import { DataRowCheckBoxDecoration, StepList } from '../../../libappsop/listsop';
 import { ListEntity } from '../../../libmp/forms/form.unit';
 import { ListRow } from '../../../e2elib/lib/src/pageobjects/list/listrow.component';
 
 describe('ADSO-10203 -  Select parent level items in the navigation panel (units)', () => {
  const appMP = AppMP.getInstance();
  const listNavEntity = appMP.formNavigation.listEntity;
  let name: ListEntityColumn;
  let parent: ListEntityColumn[] | undefined;
  let targetRow: ListRow;
 
  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.showEntitiesList()}`, async () => {
    await appMP.formNavigation.toggleEntityList();
  });
 
  it(`Step 3 - ${StepNavigationPanel.checkUnits([dataFoodUnits.Transportation.Name])}`, async () => {
    // New mechanism to pass only the Unit name to 'dataFoodUnitProvider' to retrieve the ancestors recursively for easy maintenance
    [name, parent] = listNavEntity.getHierarchy(dataFoodUnitsProvider, dataFoodUnits.Transportation);
    targetRow = await listNavEntity.getRow(name, parent);
    await listNavEntity.toggleRowCheckbox(targetRow, true);
    await targetRow.expandRow();
  });
 
  it(`Step 4 - ${StepList.verifyChildrenRowsChecked(ListEntity.title, dataFoodUnits.Transportation.Name)} `, async () => {
    await listNavEntity.verifyChildrenRowsChecked(true, name, parent);
  });
 
  it(`Step 5 - ${StepList.verifyCheckBoxRowDecoration (ListEntity.title, dataFoodUnits.Transportation.Name, DataRowCheckBoxDecoration.DarkDecorated)}`, async () => {
    await listNavEntity.verifyRowCheckBoxDecoration([dataFoodUnitsProvider, dataFoodUnits.Transportation], DataRowCheckBoxDecoration.DarkDecorated);
  });
 
  it(`Step 6 - ${StepList.verifyCheckBoxRowDecoration (ListEntity.title, dataFoodUnits.Europe.Name, DataRowCheckBoxDecoration.LightDecorated)}`, async () => {
    await listNavEntity.verifyRowCheckBoxDecoration([dataFoodUnitsProvider, dataFoodUnits.Europe], DataRowCheckBoxDecoration.LightDecorated);
  });
 
  it (`Step 7 - ${StepNavigationPanel.uncheckUnits ([dataFoodUnits.Transportation.Name])}`, async () => {
    const target = await listNavEntity.getRow(name, parent);
    await listNavEntity.toggleRowCheckbox(target, false);
    await target.expandRow();
  });
 
  it (`Step 8 - ${StepList.verifyChildrenRowsUnchecked (ListEntity.title, dataFoodUnits.Transportation.Name)}`, async () => {
    await listNavEntity.verifyChildrenRowsChecked(false, name, parent);
  });
 
  it(`Step 9 - ${StepList.verifyCheckBoxRowDecoration (ListEntity.title, dataFoodUnits.Transportation.Name, DataRowCheckBoxDecoration.None)}`, async () => {
    await listNavEntity.verifyRowCheckBoxDecoration([dataFoodUnitsProvider, dataFoodUnits.Transportation], DataRowCheckBoxDecoration.None);
  });
 
  it(`Step 10 - ${StepList.verifyCheckBoxRowDecoration (ListEntity.title, dataFoodUnits.Europe.Name, DataRowCheckBoxDecoration.None)}`, async () => {
    await listNavEntity.verifyRowCheckBoxDecoration([dataFoodUnitsProvider, dataFoodUnits.Europe], DataRowCheckBoxDecoration.None);
  });
 });