yanweiyuan3
2023-08-09 588bc7829387dfc761cc25f06f77d4c81818bd10
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
/**
 * @file        ADSO-9493
 * @description Create new strategy
 * @author      Mehrab Kamrani (mehrab.hassan@3ds.com)
 * @copyright   Dassault Systèmes
 */
import { qCustomMatcher } from '../../e2elib/lib/src/main/qmatchers.const';
import { AppMP, Demo, Scenario } from '../../libmp/appmp';
import { ListStrategyContextMenuItem } from '../../libmp/forms/form.optimizerstrategies';
 
describe('ADSO-9493 - Create new strategy via context menu in strategy list and action bar Create button', () => {
  const appMP = AppMP.getInstance();
  const listStrategy = appMP.viewOptimizerStrategies.frmOptimizerStrategies.listStrategy;
 
  beforeAll(async () => {
    jasmine.addMatchers(qCustomMatcher);
    await appMP.login();
  });
 
  afterAll(async () => {
    await appMP.resetActiveView(appMP.viewScenarioAnalysisOverview);
    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 - Open view ${appMP.viewOptimizerStrategies.viewPath} and via context menu on Strategies list create new strategy`, async () => {
    await appMP.viewOptimizerStrategies.switchTo();
 
    // Create from context menu of strategy list
    const [dlgStrategy] = await listStrategy.selectContextMenu(ListStrategyContextMenuItem.Create);
 
    // Verify Active Goal list is empty for new created strategy
    const listActiveGoalsRowCount = await dlgStrategy.listActiveGoals.getRowCount();
    expect(listActiveGoalsRowCount).toBe(0, 'Create strategy dialog, by default active goals list should be empty.');
 
    await dlgStrategy.updateDialogValues({Name: 'Strategy Test 1'});
    await dlgStrategy.clickOK();
 
    // Verify strategy created in list
    await listStrategy.verifyRowExists({Name: 'Strategy Test 1'});
  });
 
  it('Step 2 - Repeat test using action bar Create button', async () => {
    // Create from Scenarios Action bar create menu
    const dlgStrategy = await listStrategy.clickActionButton(appMP.abpScenario.btnCreate);
 
    // Verify Active Goal list is empty for new created strategy
    const listActiveGoalsRowCount = await dlgStrategy.listActiveGoals.getRowCount();
    expect(listActiveGoalsRowCount).toBe(0, 'Create strategy dialog, by default active goals list should be empty.');
 
    await dlgStrategy.updateDialogValues({Name: 'Strategy Test 2'});
    await dlgStrategy.clickOK();
 
    // Verify strategy created in list
    await listStrategy.verifyRowExists({Name: 'Strategy Test 2'});
  });
 
  it('Clean Up the data - remove strategies and verify not in list', async () => {
    // Delete the strategy created in step 1
    let row = await listStrategy.getRow({Name: 'Strategy Test 1'});
    await listStrategy.selectContextMenu(ListStrategyContextMenuItem.Delete, row);
    await listStrategy.verifyRowNotExist({Name: 'Strategy Test 1'});
 
    // Delete the strategy created in step 2
    row = await listStrategy.getRow({Name: 'Strategy Test 2'});
    await listStrategy.selectContextMenu(ListStrategyContextMenuItem.Delete, row);
    await listStrategy.verifyRowNotExist({Name: 'Strategy Test 2'});
  });
});