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
/**
 * @file         ADSO-10180
 * @description  Cannot create unit costs in the Stocking Costs list
 * @testcategory Web - Financials - Stocking points
 * @author       Gay Er Xuan (erxuan.gay@3ds.com)
 * @copyright    Dassault Systèmes
 */
import { qCustomMatcher } from '../../../e2elib/lib/src/main/qmatchers.const';
import { LogMessage } from '../../../libappbase/logmessage';
import { AppMP, Demo, Scenario } from '../../../libmp/appmp';
import { DataFoodBaseEntityName } from '../../../libmp/data/data.navigation';
import { ListStockingCostContextMenuItem } from '../../../libmp/forms/form.stockingcost';
 
describe('ADSO-10180 - Cannot create unit costs in the Stocking Costs list', () => {
  const appMP = AppMP.getInstance();
 
  beforeAll(async () => {
    jasmine.addMatchers(qCustomMatcher);
    await appMP.login();
  });
 
  afterAll(async () => {
    // Reset views and navigation
    await appMP.formNavigation.reset();
    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.viewStockingCost.viewPath}. Check any units without child stocking point in navigation panel`, async () => {
    // Open Inventory Cost View
    await appMP.viewStockingCost.switchTo();
    const isChecked = await appMP.formNavigation.filterByEntity(DataFoodBaseEntityName.Plants, [DataFoodBaseEntityName.Europe]);
    expect(isChecked).toBe(true, `${DataFoodBaseEntityName.Plants} should be checked in entity list of navigation form`);
  });
 
  it('Step 2 - Verify "Create" context menu item disabled with correct tooltip', async () => {
    // Verify context menu item is disabled
    const listStockingCost = appMP.viewStockingCost.frmStockingCost.lstStockingCost;
    await listStockingCost.rightClick();
    const expectedTooltip = 'Please select a stocking point or a unit with child stocking point in the navigation panel to create a stocking cost.';
    const [isMenuItemClickable, cmMenuItemDisabledTooltip] = await listStockingCost.verifyIsMenuItemClickable(ListStockingCostContextMenuItem.Create);
    expect(isMenuItemClickable).toBe(false, LogMessage.menu_isEnabled(ListStockingCostContextMenuItem.Create));
    expect(cmMenuItemDisabledTooltip).toBe(expectedTooltip, LogMessage.tooltip_notMatched(expectedTooltip, cmMenuItemDisabledTooltip));
  });
 
  it('Step 3 - Verify drag and drop units without child stocking point to create stocking cost is not allowed with correct tooltip', async () => {
    // Get unit row in navigation form
    const unitRow = await appMP.formNavigation.listEntity.getEntityRowByName(DataFoodBaseEntityName.Suppliers, [DataFoodBaseEntityName.Europe]);
    await unitRow.leftClick();
    // Get stocking acount row in stocking account form
    const listStockingAccount = appMP.viewStockingCost.frmStockingAccount.lstStockingAccount;
    const accRow = await listStockingAccount.getRowByIndex(0);
    // Verify drag and drop is not allowed with correct tooltip
    const expectedTooltip = 'Only stocking point can be dropped onto account to create stocking point cost.';
    const tooltip = await listStockingAccount.dropRowOnTargetRow(unitRow, accRow, true);
    expect(tooltip).toBe(expectedTooltip, LogMessage.list_dragAndDropAllowed(expectedTooltip));
  });
});