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
86
/**
 * @file        ADSO-9539
 * @description Delete currency
 * @author      Chan Clarence (ccn7@3ds.com)
 * @copyright   Dassault Systèmes
 */
import { AppMP, Demo, Scenario } from '../../libmp/appmp';
import { qCustomMatcher } from '../../e2elib/lib/src/main/qmatchers.const';
import { DataFoodBaseCurrency } from '../../libmp/data/data.currency';
import { ListCurrencyContextMenuItem, menuDisabledTooltip } from '../../libmp/forms/form.currency';
 
describe('ADSO-9539 - Delete currency', () => {
  const appMP = AppMP.getInstance();
  const listCurrency = appMP.viewCurrency.formCurrency.listCurrency;
  const newCurrencyRUB = 'RUB';
 
  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 currency "${DataFoodBaseCurrency.Krona}". Delete it via action bar Delete button. Verify "${DataFoodBaseCurrency.Krona}" is deleted.`, async () => {
    await listCurrency.selectRow({Name: DataFoodBaseCurrency.Krona});
    await listCurrency.clickActionButton(appMP.abpData.btnDelete);
    await listCurrency.verifyRowNotExist({Name: DataFoodBaseCurrency.Krona});
  });
 
  it(`Step 4 - Select currency "${DataFoodBaseCurrency.Dollar}".<br>
      Verify Delete context menu disabled with precondition text = "${menuDisabledTooltip.currencyInUse(DataFoodBaseCurrency.Dollar)}".<br>
      Verify Delete action bar button also disabled with same precondition text.`, async () => {
    const row = await listCurrency.selectRow({Name: DataFoodBaseCurrency.Dollar});
    await listCurrency.verifyContextMenuDisabled(ListCurrencyContextMenuItem.Delete, [row], undefined, menuDisabledTooltip.currencyInUse(DataFoodBaseCurrency.Dollar));
    await appMP.abpData.btnDelete.verifyEnabled(false, menuDisabledTooltip.currencyInUse(DataFoodBaseCurrency.Dollar));
  });
 
  it(`Step 5 - Select currency "${DataFoodBaseCurrency.Euro}".<br>
      Verify Delete context menu disabled with precondition text = "${menuDisabledTooltip.currencyIsDefault()}".<br>
      Verify Delete action bar button also disabled with same precondition text.`, async () => {
    const row = await listCurrency.selectRow({Name: DataFoodBaseCurrency.Euro});
    await listCurrency.verifyContextMenuDisabled(ListCurrencyContextMenuItem.Delete, [row], undefined, menuDisabledTooltip.currencyIsDefault());
    await appMP.abpData.btnDelete.verifyEnabled(false, menuDisabledTooltip.currencyIsDefault());
  });
 
  it(`Step 6 - Create currency ${newCurrencyRUB} via context menu.`, async () => {
    // We need 2 currencies that are NOT in used to perform batch delete
    const [dlg] = await listCurrency.selectContextMenu(ListCurrencyContextMenuItem.Create);
    await dlg.updateDialogValues({Name: newCurrencyRUB, ID: newCurrencyRUB, Symbol: newCurrencyRUB});
    await dlg.clickOK();
 
    await listCurrency.verifyRowExists({Name: newCurrencyRUB});
  });
 
  it(`Step 7 - Select currency ${DataFoodBaseCurrency.RMB} and ${newCurrencyRUB} (both not default currency and not in use).<br>
      Right click and click Delete context menu. Verify deleted from list.`, async () => {
    const rows = await listCurrency.selectListRows([{Name: DataFoodBaseCurrency.RMB}, {Name: newCurrencyRUB}]);
    await listCurrency.selectContextMenu(ListCurrencyContextMenuItem.Delete, rows);
 
    await listCurrency.verifyRowNotExist({Name: DataFoodBaseCurrency.RMB});
    await listCurrency.verifyRowNotExist({Name: newCurrencyRUB});
  });
 
  it(`Step 8 - Click Undo button at top right of action bar. Verify both ${DataFoodBaseCurrency.RMB} and ${newCurrencyRUB} re-appear in list.`, async () => {
    await appMP.btnUndo.click();
 
    // Both re-appear indicating previous Delete done in 1 transaction
    await listCurrency.verifyRowExists({Name: DataFoodBaseCurrency.RMB});
    await listCurrency.verifyRowExists({Name: newCurrencyRUB});
  });
});