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
/**
 * @file        ADSO-9529
 * @description Create Unit of Measure (UoM)
 * @author      Chan Clarence (ccn7@3ds.com)
 * @copyright   Dassault Systèmes
 */
import { qCustomMatcher } from '../../e2elib/lib/src/main/qmatchers.const';
import { AppMP, ImageAttribute } from '../../libmp/appmp';
import { DialogUnitOfMeasure } from '../../libmp/dialogs/dialog.unitofmeasure';
import { ListUnitsOfMeasureContextMenuItem } from '../../libmp/forms/form.unitsofmeasure';
 
describe('ADSO-9529 - Create Unit of Measure (UoM)', () => {
  const appMP = AppMP.getInstance();
  let dlgUoM: DialogUnitOfMeasure;
  const listUoM = appMP.viewUnitsOfMeasure.formUnitsOfMeasure.listUnitsOfMeasure;
 
  beforeAll(async () => {
    jasmine.addMatchers(qCustomMatcher);
    await appMP.login();
  });
 
  afterAll(async () => {
    await appMP.viewScenario.reset();
    await appMP.viewUnitsOfMeasure.reset();
    await appMP.cleanupAndLogout();
  });
 
  afterEach(async () => {
    await appMP.checkToastMessage();
  });
 
  it(`Step 1 - Open view ${appMP.viewScenario.viewPath}`, async () => {
    await appMP.viewScenario.switchTo();
  });
 
  it('Step 2 - In Scenario Manager form, right click list and click Create scenario menu. Fill name as \'1\' and click OK.', async () => {
    await appMP.viewScenario.formScenario.lstScenario.createEmptyScenario('1');
  });
 
  it(`Step 3 - Open view ${appMP.viewUnitsOfMeasure.viewPath}`, async () => {
    await appMP.viewUnitsOfMeasure.switchTo();
  });
 
  it(`Step 4 - Verify Ton exists in UoM list and set as default UoM (ImgIsDefault column has ${ImageAttribute.IsDefault} icon).`, async () => {
    const row = await listUoM.getRow({Name: 'Ton'});
    await listUoM.verifyRowValues(row, {ImgIsDefault: ImageAttribute.IsDefault});
  });
 
  it('Step 5 - Right click in UoM list and click Create menu. In dialog, verify factor default 1.', async () => {
    [dlgUoM] = await listUoM.selectContextMenu(ListUnitsOfMeasureContextMenuItem.Create);
    await dlgUoM.verifyDialogValues({Factor: '1'});
  });
 
  it('Step 6 - Set UoM name = \'UoM 2\' and factor = 2. Click OK. Verify UoM created in list and not marked as default.', async () => {
    await dlgUoM.updateDialogValues({Name: 'UoM 2', Factor: '2'});
    await dlgUoM.clickOK();
 
    const row = await listUoM.getRow({Name: 'UoM 2'});      // Check row exists
    await listUoM.verifyRowValues(row, {ImgIsDefault: ImageAttribute.IsEmpty}); // Created not as default (empty img attribute)
  });
 
  it('Step 7 - Focus on UoM list and click Create action bar button. Set UoM name = \'UoM 3\' and factor = 3. Click OK. Verify UoM created in list and not marked as default.', async () => {
    dlgUoM = await listUoM.clickActionButton(appMP.abpData.btnCreate);
    await dlgUoM.updateDialogValues({Name: 'UoM 3', Factor: '3'});
    await dlgUoM.clickOK();
 
    const row = await listUoM.getRow({Name: 'UoM 3'});      // Check row exists
    await listUoM.verifyRowValues(row, {ImgIsDefault: ImageAttribute.IsEmpty}); // Created not as default (empty img attribute)
  });
});