| /** | 
|  * @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}); | 
|   }); | 
| }); |