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
/**
 * @file         ADSO-10118
 * @description  Copy unit cost - multiple costs selection
 * @testcategory Web - Financials - Units
 * @author       Jayden Chew (jayden.chew@3ds.com)
 * @copyright    Dassault Systemes
 */
import { qCustomMatcher } from '../../../e2elib/lib/src/main/qmatchers.const';
import { AppMP, Demo, Scenario } from '../../../libmp/appmp';
import { LogMessage } from '../../../libappbase/logmessage';
import { ListUnitCostContextMenuItem } from '../../../libmp/forms/form.unitcost';
 
describe('ADSO-10118 - Copy unit cost - multiple costs selection', () => {
  const appMP = AppMP.getInstance();
  const listUnitCost = appMP.viewUnitCost.frmUnitCost.listUnitCost;
  const expectedTooltips = 'Copy one cost at a time.';
 
  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 - Open view ${appMP.viewUnitCost.viewPath}.`, async () => {
    // Open unit cost view
    await appMP.viewUnitCost.switchTo();
  });
 
  it('Step 2 -  Select 2 unit costs.', async () => {
    for (let index = 0; index < 2; index++) {
      const row = await listUnitCost.getRowByIndex(index);
      const modifier = index !== 0 ? { control: true } : undefined;
      await row.leftClick(modifier);
    }
  });
 
  it('Step 3 - Right click and verify "Copy" context menu is disabled with tooltip', async () => {
    await listUnitCost.rightClick();
    const [isContextMenuItemEnabled, ctnMenuDisabledTooltip] = await listUnitCost.verifyIsMenuItemClickable(ListUnitCostContextMenuItem.MenuCopy);
    expect(isContextMenuItemEnabled).toBe(false, LogMessage.menu_isEnabled(ListUnitCostContextMenuItem.MenuCopy));
    expect(ctnMenuDisabledTooltip).toBe(expectedTooltips, LogMessage.tooltip_notMatched(expectedTooltips, ctnMenuDisabledTooltip));
  });
 
  it('Step 4 - Verify "Copy" button is disabled with tooltip.', async () => {
    const [isButtonnEnabled, btnDisabledTooltip] = await appMP.abpData.btnCopy.getIsClickable();
 
    expect(isButtonnEnabled).toBe(false, LogMessage.btn_isEnabled('Copy'));
    expect(btnDisabledTooltip).toBe(expectedTooltips, LogMessage.tooltip_notMatched(expectedTooltips, btnDisabledTooltip));
  });
});