| /** | 
|  * @file        ADSO-9599 | 
|  * @description Create and delete recipe assignment with effective date | 
|  * @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 { StepList } from '../../libappsop/listsop'; | 
| import { DataMetalBaseProductName } from '../../libmp/data/data.product'; | 
| import { DataMetalBaseRecipeName } from '../../libmp/data/data.recipe'; | 
| import { DialogRecipeAssignmentFields, okButtonDisabledTooltip } from '../../libmp/dialogs/dialog.recipeassignment'; | 
| import { ListRecipeAssignment, ListRecipeAssignmentColumn, ListRecipeAssignmentContextMenuItem } from '../../libmp/forms/form.recipeassignment'; | 
|   | 
| describe('ADSO-9599 - Create and delete recipe assignment with effective date', () => { | 
|   const appMP = AppMP.getInstance(); | 
|   const listRecipeAssignment = appMP.viewRecipes.formRecipeAssignment.listRecipeAssignment; | 
|   const recipeName = DataMetalBaseRecipeName._5XXX; | 
|   const productName = DataMetalBaseProductName.MoltenAluminium3XXX; | 
|   const effectiveDate = '1-Jun-2021'; | 
|   const effectiveDateForPrecondition = 'Jun-1-2021'; | 
|   | 
|   const rowListRecipeAssignment: ListRecipeAssignmentColumn = { 'Product name': productName, 'Recipe name': recipeName, 'Effective date': effectiveDate }; | 
|   const inputDlgRecipeAssignment: DialogRecipeAssignmentFields = { Product: productName, Recipe: recipeName, EffectiveDate: effectiveDate }; | 
|   | 
|   beforeAll(async () => { | 
|     jasmine.addMatchers(qCustomMatcher); | 
|     await appMP.login(); | 
|   }); | 
|   | 
|   afterAll(async () => { | 
|     await appMP.viewRecipes.reset(); | 
|     await appMP.cleanupAndLogout(); | 
|   }); | 
|   | 
|   afterEach(async () => { | 
|     await appMP.checkToastMessage(); | 
|   }); | 
|   | 
|   describe('Create recipe assignment with effective date', () => { | 
|     it(`Step 1 - ${AppMP.getDemoDataPath(Demo.Metals, Scenario.Base)}`, async () => { | 
|       await appMP.createDemoDataset(Demo.Metals, Scenario.Base, false); | 
|     }); | 
|   | 
|     it(`Step 2 - Open view ${appMP.viewRecipes.viewPath}`, async () => { | 
|       await appMP.viewRecipes.switchTo(); | 
|     }); | 
|   | 
|     it(`Step 3 - In Recipe Assignments list, right click and select "Create" menu.<br> | 
|         In dialog, set Product = "${productName}", Recipe = "${recipeName}" and Effective date = "${effectiveDate}". Click OK to create.`, async () => { | 
|       const [dlgRecipeAssignment] = await listRecipeAssignment.selectContextMenu(ListRecipeAssignmentContextMenuItem.Create); | 
|       await dlgRecipeAssignment.updateDialogValues(inputDlgRecipeAssignment); | 
|       await dlgRecipeAssignment.clickOK(); | 
|     }); | 
|   | 
|     it('Step 4 - Verify recipe assignment created correctly.', async () => { | 
|       await listRecipeAssignment.verifyRowExists(rowListRecipeAssignment); | 
|     }); | 
|   | 
|     it(`Step 5 - Click "Create" menu to bring up dialog again.<br> | 
|         Set the same values as previous step and verify OK disabled with precondition = "${okButtonDisabledTooltip.notUnique(productName, effectiveDateForPrecondition)}". | 
|         Click Cancel to dismiss dialog.`, async () => { | 
|       const [dlgRecipeAssignment] = await listRecipeAssignment.selectContextMenu(ListRecipeAssignmentContextMenuItem.Create); | 
|       await dlgRecipeAssignment.updateDialogValues(inputDlgRecipeAssignment); | 
|       await dlgRecipeAssignment.verifyOKDisabled(okButtonDisabledTooltip.notUnique(productName, effectiveDateForPrecondition), true); | 
|       await dlgRecipeAssignment.clickCancel(); | 
|     }); | 
|   }); | 
|   | 
|   describe('Delete recipe assignment with effective date', () => { | 
|     it(`Step 1 - ${StepList.selectRowAndClickMenu(ListRecipeAssignment.title, rowListRecipeAssignment, ListRecipeAssignmentContextMenuItem.Delete.Label)}`, async () => { | 
|       const row = await listRecipeAssignment.getRow(rowListRecipeAssignment); | 
|       await listRecipeAssignment.selectContextMenu(ListRecipeAssignmentContextMenuItem.Delete, row); | 
|     }); | 
|   | 
|     it(`Step 2 - ${StepList.verifyRowNotExist(ListRecipeAssignment.title, rowListRecipeAssignment)}`, async () => { | 
|       await listRecipeAssignment.verifyRowNotExist(rowListRecipeAssignment); | 
|     }); | 
|   }); | 
| }); |