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
80
81
82
83
84
85
/**
 * @file        ADSO-9541
 * @description Create new currency rate
 * @author      Tai Zan Sen (zansen.tai@3ds.com)
 * @copyright   Dassault Systèmes
 */
import { AppMP, Demo, Scenario } from '../../libmp/appmp';
import { qCustomMatcher } from '../../e2elib/lib/src/main/qmatchers.const';
import { DialogCurrencyRate, okButtonDisabledTooltip } from '../../libmp/dialogs/dialog.currencyrate';
import { ListCurrencyRateContextMenuItem } from '../../libmp/forms/form.currencyrate';
import { ChartCurrencyRates } from '../../libmp/forms/form.currencyratechart';
import { DataFoodBaseCurrency } from '../../libmp/data/data.currency';
import { UtilSOP } from '../../libappsop/utilsop';
 
describe('ADSO-9541 - Create new currency rate via context menu in currency list and action bar Create button', () => {
  const appMP = AppMP.getInstance();
 
  // Test data for currency rate start date
  const today = new Date(Date.now());
  const april14th = `14-Apr-${today.getFullYear()}`;
  const euro = DataFoodBaseCurrency.Euro;
  const rmb = DataFoodBaseCurrency.RMB;
  let dlgCurrencyRate: DialogCurrencyRate;
 
  beforeAll(async () => {
    jasmine.addMatchers(qCustomMatcher);
    await appMP.login();
  });
 
  afterAll(async () => {
    await appMP.viewCurrency.reset();
    await appMP.cleanupAndLogout();
  });
 
  afterEach(async () => {
    await appMP.checkToastMessage();
  });
 
  it(`Step 1 - ${AppMP.getDemoDataPath(Demo.Food, Scenario.Base)}`, async () => {
    await appMP.createDemoDataset(Demo.Food, Scenario.Base, false);
  });
 
  it(`Step 2 - Open view ${appMP.viewCurrency.viewPath}.`, async () => {
    await appMP.viewCurrency.switchTo();
  });
 
  it('Step 3 - Select RMB currency, right click context menu to Create', async () => {
    await appMP.viewCurrency.formCurrency.listCurrency.selectRow({Name: rmb});
    [dlgCurrencyRate] = await appMP.viewCurrency.formCurrencyRate.listCurrencyRate.selectContextMenu(ListCurrencyRateContextMenuItem.Create);
  });
 
  it('Step 4 - In Currency rate dialog, verify by default currency = RMB, Start = today date, Rate = 0 and OK button disabled as Rate must be greater than 0', async () => {
    const expectedLabelRate = dlgCurrencyRate.getLabelRateFormat(euro, rmb);
    await dlgCurrencyRate.verifyDialogValues({Currency: rmb, Start: UtilSOP.getDateString(today), Rate: '0', RateLabel: expectedLabelRate});
    await dlgCurrencyRate.verifyOKDisabled(okButtonDisabledTooltip.partialRateMustGreaterZero('0'));
  });
 
  it('Step 5 - Enter Rate = 0.567. Verify rate label shows "Euro to 1 RMB", and OK button is enabled', async () => {
    await dlgCurrencyRate.updateDialogValues({ Rate: '0.567' });
 
    const expectedLabelRate = dlgCurrencyRate.getLabelRateFormat(euro, rmb);
    await dlgCurrencyRate.verifyDialogValues({RateLabel: expectedLabelRate});
    await dlgCurrencyRate.verifyOKEnabled();
  });
 
  it('Step 6 - Update Start = 14-Apr-SOP and click OK to save. Verify currency rate is created in list. Verify currency rate shown in chart.', async () => {
    await dlgCurrencyRate.updateDialogValues({Start: april14th });
    await dlgCurrencyRate.clickOK();
    await appMP.viewCurrency.formCurrencyRate.listCurrencyRate.verifyRowExists({Start: april14th, Rate: '0.5670'});
 
    // Verify rate shown correctly in chart
    await appMP.viewCurrency.formCurrencyRateChart.chartCurrencyRate.verifyHasDataPoint(ChartCurrencyRates.LegendGroupName, rmb, april14th, '0.567');
  });
 
  it(`Step 7 - Click Create action bar button and enter values in dialog as: currency = RMB, start = 14-April-SOP, rate = 0.568.
      Verify OK disabled as currency rate must be unique by Currency and Start.`, async () => {
    dlgCurrencyRate = await appMP.viewCurrency.formCurrencyRate.listCurrencyRate.clickActionButton(appMP.abpData.btnCreate);
    await dlgCurrencyRate.updateDialogValues({ Currency: rmb, Start: april14th, Rate: '0.568' });
    await dlgCurrencyRate.verifyOKDisabled(okButtonDisabledTooltip.partialRateMustUnique());
  });
 
  it('Step 8 - Click Cancel to dismiss dialog', async () => {
    await dlgCurrencyRate.clickCancel();
  });
});