haorenhui
2023-10-30 6d6cc10d9e8e242661da7fd655dec155a09d676c
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
/**
 * @file        ADSO-10205
 * @description Select parent level items in the navigation panel (Sales segment)
 * @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 { ListSalesSegment, StepNavigationPanel, ListSalesSegmentColumn } from '../../../libmp/forms/navigationpanel/form.navigationpanel';
import { dataFoodSalesSegment, dataFoodSalesSegmentProvider } from '../../../libmp/data/data.salessegment';
import { StepList } from '../../../libappsop/listsop';
 
describe('ADSO-10205 - Select parent level items in the navigation panel (Sales segment)', () => {
  const appMP = AppMP.getInstance();
  const listNavSalesSegment = appMP.formNavigation.listSalesSegment;
  let name: ListSalesSegmentColumn;
  let parent: ListSalesSegmentColumn[] | 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.showSalesSegmentsList()}`, async () => {
    await appMP.formNavigation.toggleSalesSegmentList();
  });
 
  it(`Step 3 - ${StepNavigationPanel.checkSalesSegments([dataFoodSalesSegment.Target.Name])}`, async () => {
    // New mechanism to pass only the Sales Segment name to 'dataFoodSalesSegmentProvider' to retrieve the ancestors recursively for easy maintenance
    [name, parent] = listNavSalesSegment.getHierarchy(dataFoodSalesSegmentProvider, dataFoodSalesSegment.Target);
    const targetRow = await listNavSalesSegment.getRow(name, parent);
    await listNavSalesSegment.toggleRowCheckbox(targetRow, true);
    await targetRow.expandRow();
  });
 
  it(`Step 4 - ${StepList.verifyChildrenRowsChecked(ListSalesSegment.title, dataFoodSalesSegment.Target.Name)} `, async () => {
    await listNavSalesSegment.verifyChildrenRowsChecked(true, name, parent);
  });
 
  it (`Step 5 - ${StepNavigationPanel.unCheckSalesSegments ([dataFoodSalesSegment.Target.Name])}`, async () => {
    const target = await listNavSalesSegment.getRow(name, parent);
    await listNavSalesSegment.toggleRowCheckbox(target, false);
    await target.expandRow();
  });
 
  it (`Step 6 - ${StepList.verifyChildrenRowsUnchecked (ListSalesSegment.title, dataFoodSalesSegment.Target.Name)}`, async () => {
    await listNavSalesSegment.verifyChildrenRowsChecked(false, name, parent);
  });
});