| /** | 
|  * @file        ADSO-9722 | 
|  * @description Create new priority | 
|  * @author      Kee Jie Yi (jke5@3ds.com) | 
|  * @copyright   Dassault Systèmes | 
|  */ | 
|   | 
| import { AppMP, Demo, Scenario } from '../../libmp/appmp'; | 
| import { DialogPriority, okButtonDisabledTooltip } from '../../libmp/dialogs/dialog.priority'; | 
| import { ListPriorityContextMenuItem } from '../../libmp/forms/form.priorities'; | 
|   | 
| describe('ADSO-9722 - Create new priority', () => { | 
|   const appMP = AppMP.getInstance(); | 
|   const listPriority = appMP.viewSalesSegments.formPriorities.listPriority; | 
|   let dlgPriority: DialogPriority; | 
|   | 
|   beforeAll(async () => { | 
|     await appMP.login(); | 
|   }); | 
|   | 
|   afterAll(async () => { | 
|     await appMP.viewSalesSegments.reset(); | 
|     await appMP.cleanupAndLogout(); | 
|   }); | 
|   | 
|   afterEach(async () => { | 
|     await appMP.checkToastMessage(); | 
|   }); | 
|   | 
|   it(`Step 1 - ${AppMP.getDemoDataPath(Demo.Metals, Scenario.Base)}.`, async () => { | 
|     await appMP.createDemoDataset(Demo.Metals, Scenario.Base, false); | 
|   }); | 
|   | 
|   it(`Step 2 - Open view ${appMP.viewSalesSegments.viewPath}.`, async () => { | 
|     await appMP.viewSalesSegments.switchTo(); | 
|   }); | 
|   | 
|   it('Step 3 - Open Priorities form via action bar.', async () => { | 
|     await appMP.viewSalesSegments.formPriorities.openDockedForm(); | 
|   }); | 
|   | 
|   it('Step 4 - Right-click Priorities list > Create. Verify Name is empty, OK button disabled with feedback.', async () => { | 
|     [dlgPriority] = await listPriority.selectContextMenu(ListPriorityContextMenuItem.Create); | 
|     await dlgPriority.verifyDialogValues({Name: ''}); | 
|     await dlgPriority.verifyOKDisabled(okButtonDisabledTooltip.nameCannotEmpty()); | 
|   }); | 
|   | 
|   it('Step 5 - Fill in "Normal" as Name. Verify that OK button is disabled with feedback.', async () => { | 
|     await dlgPriority.updateDialogValues({Name: 'Normal'}); | 
|     await dlgPriority.verifyOKDisabled(okButtonDisabledTooltip.nameMustUnique('Normal')); | 
|   }); | 
|   | 
|   it('Step 6 - Fill in "Urgent" as Name, with priority 50. Click OK.', async () => { | 
|     await dlgPriority.updateDialogValues({Name: 'Urgent', Weight: 50}); | 
|     await dlgPriority.verifyOKEnabled(); | 
|     await dlgPriority.clickOK(); | 
|   }); | 
|   | 
|   it('Step 7 - Verify that new priority is created in the list.', async () => { | 
|     await listPriority.verifyRowExists({Name: 'Urgent', Weight: '50'}); | 
|   }); | 
|   | 
|   it('Step 8 - Click on Create... > Priority button in the action bar.', async () => { | 
|     dlgPriority = await listPriority.clickActionButton(appMP.abpSales.btnCreate); | 
|   }); | 
|   | 
|   it('Step 9 - Enter "Low" as name and -1.5 as priority. Click OK.', async () => { | 
|     await dlgPriority.updateDialogValues({Name: 'Low', Weight: -1.5}); | 
|     await dlgPriority.verifyOKEnabled(); | 
|     await dlgPriority.clickOK(); | 
|   }); | 
|   | 
|   it('Step 10 - Verify that new priority is created in the list with Weight = -2 (rounding).', async () => { | 
|     // Due to global Real representation, in the list it will round up and show no decimal. | 
|     // TODO: To confirm with BC whether behavior expected. | 
|     await listPriority.verifyRowExists({Name: 'Low', Weight: '-2'}); | 
|   }); | 
|   | 
| }); |