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
77
78
79
/**
 * @file        ADSO-9722
 * @description Create new priority
 * @author      Kee Jie Yi (jke5@3ds.com)
 * @copyright   Dassault Systèmes
 */
 
import { AppMP, Demo, Scenario } from '../../libmp/appmp';
import { DialogPriority, okButtonDisabledTooltip } from '../../libmp/dialogs/dialog.priority';
import { ListPriorityContextMenuItem } from '../../libmp/forms/form.priorities';
 
describe('ADSO-9722 - Create new priority', () => {
  const appMP = AppMP.getInstance();
  const listPriority = appMP.viewSalesSegments.formPriorities.listPriority;
  let dlgPriority: DialogPriority;
 
  beforeAll(async () => {
    await appMP.login();
  });
 
  afterAll(async () => {
    await appMP.viewSalesSegments.reset();
    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.viewSalesSegments.viewPath}.`, async () => {
    await appMP.viewSalesSegments.switchTo();
  });
 
  it('Step 3 - Open Priorities form via action bar.', async () => {
    await appMP.viewSalesSegments.formPriorities.openDockedForm();
  });
 
  it('Step 4 - Right-click Priorities list > Create. Verify Name is empty, OK button disabled with feedback.', async () => {
    [dlgPriority] = await listPriority.selectContextMenu(ListPriorityContextMenuItem.Create);
    await dlgPriority.verifyDialogValues({Name: ''});
    await dlgPriority.verifyOKDisabled(okButtonDisabledTooltip.nameCannotEmpty());
  });
 
  it('Step 5 - Fill in "Normal" as Name. Verify that OK button is disabled with feedback.', async () => {
    await dlgPriority.updateDialogValues({Name: 'Normal'});
    await dlgPriority.verifyOKDisabled(okButtonDisabledTooltip.nameMustUnique('Normal'));
  });
 
  it('Step 6 - Fill in "Urgent" as Name, with priority 50. Click OK.', async () => {
    await dlgPriority.updateDialogValues({Name: 'Urgent', Weight: 50});
    await dlgPriority.verifyOKEnabled();
    await dlgPriority.clickOK();
  });
 
  it('Step 7 - Verify that new priority is created in the list.', async () => {
    await listPriority.verifyRowExists({Name: 'Urgent', Weight: '50'});
  });
 
  it('Step 8 - Click on Create... > Priority button in the action bar.', async () => {
    dlgPriority = await listPriority.clickActionButton(appMP.abpSales.btnCreate);
  });
 
  it('Step 9 - Enter "Low" as name and -1.5 as priority. Click OK.', async () => {
    await dlgPriority.updateDialogValues({Name: 'Low', Weight: -1.5});
    await dlgPriority.verifyOKEnabled();
    await dlgPriority.clickOK();
  });
 
  it('Step 10 - Verify that new priority is created in the list with Weight = -2 (rounding).', async () => {
    // Due to global Real representation, in the list it will round up and show no decimal.
    // TODO: To confirm with BC whether behavior expected.
    await listPriority.verifyRowExists({Name: 'Low', Weight: '-2'});
  });
 
});