haorenhui
2023-10-30 6d6cc10d9e8e242661da7fd655dec155a09d676c
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
/**
 * @file         ADSO-10108
 * @description  Non unique unit cost should not be allowed to create
 * @testcategory Web - Financials - Units
 * @author       Gay Er Xuan (erxuan.gay@3ds.com)
 * @copyright    Dassault Systemes
 */
import { qCustomMatcher } from '../../../e2elib/lib/src/main/qmatchers.const';
import { AppMP, Demo, Scenario } from '../../../libmp/appmp';
import { ListRow } from '../../../e2elib/lib/src/pageobjects/list/listrow.component';
import { ListUnitCost } from '../../../libmp/forms/form.unitcost';
import { startOfPlanningYear } from '../../../libmp/data/data.period';
 
describe('ADSO-10108 - Non unique unit cost should not be allowed to create', () => {
  const appMP = AppMP.getInstance();
  let listUnitCost: ListUnitCost;
  const janSOPMinus1 = `1-Jan-${startOfPlanningYear - 1}`;
  const janSOP = `1-Jan-${startOfPlanningYear}`;
 
  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(`Setup - Open view ${appMP.viewUnitCost.viewPath}. Verify DE Fermenter exist`, async () => {
    // Open Unit Costs view
    await appMP.viewUnitCost.switchTo();
    // Open navigation form
    expect(await appMP.formNavigation.isVisible()).toBe(true, 'Navigation form should be visible');
    await appMP.formNavigation.btnEntity.click();
    const listEntity = appMP.formNavigation.listEntity;
    await listEntity.waitUntilPresent();
    // Select DE Fermenter
    const row = await listEntity.getEntityRowByName('DE Fermenter', ['Europe', 'Plants', 'Denmark Plant']);
    await row.checkboxClick();
    // Verify 1 DE Fermenter Unit Cost exist in the list
    listUnitCost = appMP.viewUnitCost.frmUnitCost.listUnitCost;
    const unitCostRow: ListRow | undefined = await listUnitCost.getUnitCostRowByValues('DE Fermenter', 'General fixed costs', 'Fixed', janSOPMinus1);
    expect(unitCostRow).toBeDefined('One DE Fermenter Unit Cost should exist in the list');
  });
 
  it('Step 1 - Verify non unique unit cost is not allowed to create', async () => {
    // Open create unit cost dialog
    const dlgUnitCost = await listUnitCost.openEditDialog();
    // Update dialog
    await dlgUnitCost.updateUnitCostValue('General fixed costs', 'Fixed', 'DE Fermenter', new Date(janSOPMinus1));
    // Verify OK button is disabled and feedback text is shown
    expect(await dlgUnitCost.clickOK(1000)).toBe(false, 'Non unique unit cost should not be allowed to create');
    expect(await dlgUnitCost.getOKButtonTooltip()).toBe('Identical cost definition exists. Unit cost must be unique by Account, Cost driver and Start date.', 'Feedback text should match');
    // Update dialog
    await dlgUnitCost.updateUnitCostValue('General fixed costs', 'Fixed', 'DE Fermenter', new Date(janSOP));
    // Verify OK button is enabled
    expect(await dlgUnitCost.btnOk.isClickable(1000)).toBe(true, 'Unique unit cost should be allowed to create');
    // Cancel the dialog
    await dlgUnitCost.clickCancel();
  });
});