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
/**
 * @file        ADSO-10235
 * @description Delete multiple campaigns
 * @author      Pethaperumal Natarajan (Pethaperumal.NATARAJAN.intern@3ds.com)
 * @copyright   Dassault Systèmes
 */
 
import { AppMP, Demo, Scenario } from '../../libmp/appmp';
import { qCustomMatcher } from '../../e2elib/lib/src/main/qmatchers.const';
import { ListCampaignColumn } from '../../libmp/forms/form.campaign';
import { DataCampaignTypeName } from '../../libmp/data/data.campaign';
import { GanttChartCampaignPlanningColors, GanttChartCampaignPlanningContextMenuItem } from '../../libmp/forms/form.campaignplanning';
import { GanttChartNodeSOPCriteria, StepGanttChart } from '../../libappsop/ganttchartsop';
import { StepList } from '../../libappsop/listsop';
import { DataMetalBaseEntityName } from '../../libmp/data/data.unit';
import { GanttChartRow } from '../../e2elib/lib/src/pageobjects/ganttchart/ganttchartrow';
 
describe('ADSO-10235 - Delete multiple campaigns', () => {
  const appMP = AppMP.getInstance();
  const gcCampaign = appMP.viewCampaign.formCampaignPlanning.gcCampaign;
  let gcRowMeltingFurnaceQuilmes: GanttChartRow;
  const listCampaign = appMP.viewCampaign.formCampaign.listCampaign;
 
  const indexesToDelete: number[] = [1, 3];
 
  const itemBlue: ListCampaignColumn = {
    Unit: DataMetalBaseEntityName.MeltingFurnaceQuilmes,
    'Campaign type': DataCampaignTypeName.Campaignfor5XXXsmelt,
  };
 
  const nodeCriteria: GanttChartNodeSOPCriteria = {
    ColorHex: GanttChartCampaignPlanningColors.cyan().Hex,
  };
 
  beforeAll(async () => {
    jasmine.addMatchers(qCustomMatcher);
    await appMP.login();
  });
 
  afterAll(async () => {
    await appMP.resetActiveView(appMP.viewCampaign);
    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.viewCampaign.viewPath}.`, async () => {
    await appMP.viewCampaign.switchTo();
  });
 
  it(`Step 3 - ${StepList.verifyRowExists(listCampaign.name, itemBlue)}`, async () => {
    await listCampaign.verifyRowExists(itemBlue);
  });
 
  it(`Step 4 - ${StepGanttChart.verifyNodeCount(gcCampaign.name, DataMetalBaseEntityName.MeltingFurnaceQuilmes, 2, nodeCriteria)}`, async () => {
    const rows = await gcCampaign.getRowsByTitle(DataMetalBaseEntityName.MeltingFurnaceQuilmes);
    // Since there are 2 rows with the same title, we need to pick the second row.
    gcRowMeltingFurnaceQuilmes = rows[1];
    // Initially there are 2 blue nodes.
    await gcCampaign.verifyNodeCount(gcRowMeltingFurnaceQuilmes, 2, nodeCriteria);
  });
 
  it(`Step 5 - ${StepGanttChart.rightClickNodeIndexesAndSelectContextMenu(
    gcCampaign.name,
    DataMetalBaseEntityName.MeltingFurnaceQuilmes,
    indexesToDelete,
    GanttChartCampaignPlanningContextMenuItem.Delete.Label,
  )}`, async () => {
    // Deleting second and fourth node.
    await gcCampaign.rightClickNodeIndexesAndSelectContextMenu(gcRowMeltingFurnaceQuilmes, indexesToDelete, GanttChartCampaignPlanningContextMenuItem.Delete);
  });
 
  it(`Step 6 - ${StepList.verifyRowNotExist(listCampaign.name, itemBlue)}`, async () => {
    await listCampaign.verifyRowNotExist(itemBlue);
  });
 
  it(`Step 7 - ${StepGanttChart.verifyNodeCount(gcCampaign.name, DataMetalBaseEntityName.MeltingFurnaceQuilmes, 0, nodeCriteria)}`, async () => {
    // There were 5 nodes initially, now that 2 has been removed, there should be 0 blue nodes left
    await gcCampaign.verifyNodeCount(gcRowMeltingFurnaceQuilmes, 0, nodeCriteria);
  });
});