| /** | 
|  * @file        ADSO-11445 | 
|  * @description Create and Edit optimizer puzzle | 
|  * @author      Pethaperumal Natarajan (Pethaperumal.NATARAJAN.intern@3ds.com) | 
|  * @copyright   Dassault Systèmes | 
|  */ | 
|   | 
| import { AppMP, Demo, Scenario } from '../../libmp/appmp'; | 
| import { qCustomMatcher } from '../../e2elib/lib/src/main/qmatchers.const'; | 
| import { StepDialog } from '../../libappsop/dialogsop'; | 
| import { StepList } from '../../libappsop/listsop'; | 
| import { ListOptimizerPuzzles, ListOptimizerPuzzlesColumn, ListOptimizerPuzzlesContextMenuItem } from '../../libmp/forms/form.optimizerpuzzles'; | 
| import { StepActionBarScenarioSelection } from '../../libmp/actionbarpages/abp.scenarioselection'; | 
| import { StepActionBarPage } from '../../libappsop/actionbarpagesop'; | 
| import { DialogOptimizerPuzzles, DialogOptimizerPuzzlesField, okButtonDisabledTooltip } from '../../libmp/dialogs/optimizerpuzzles'; | 
|   | 
| describe('ADSO-11445 - Create and Edit optimizer puzzle', () => { | 
|   const appMP = AppMP.getInstance(); | 
|   const abpScenarioSelection = appMP.abpScenarioSelection; | 
|   const abpScenario = appMP.abpScenario; | 
|   const formOptimizerPuzzles = appMP.abpScenarioSelection.formOptimizerPuzzles; | 
|   const listOptimizerPuzzles = formOptimizerPuzzles.listOptimizerPuzzles; | 
|   let dlgOptimizerPuzzles: DialogOptimizerPuzzles; | 
|   | 
|   const dlgInput: DialogOptimizerPuzzlesField = { Name: 'My Puzzle', Description: 'My Description' }; | 
|   const dlgInput2: DialogOptimizerPuzzlesField = { Name: 'My Puzzle 2', Description: 'My Description 2' }; | 
|   const dlgEdittedInput: DialogOptimizerPuzzlesField = { Name: 'My Renamed Puzzle', Description: 'My New Description' }; | 
|   | 
|   const listInput: ListOptimizerPuzzlesColumn = { Name: 'My Puzzle', Description: 'My Description' }; | 
|   const listInput2: ListOptimizerPuzzlesColumn = { Name: 'My Puzzle 2', Description: 'My Description 2' }; | 
|   const listEdittedInput: ListOptimizerPuzzlesColumn = { Name: 'My Renamed Puzzle', Description: 'My New Description' }; | 
|   | 
|   beforeAll(async () => { | 
|     jasmine.addMatchers(qCustomMatcher); | 
|     await appMP.login(); | 
|   }); | 
|   | 
|   afterAll(async () => { | 
|     await appMP.resetActiveView(appMP.viewScenario); | 
|     await appMP.cleanupAndLogout(); | 
|   }); | 
|   | 
|   afterEach(async () => { | 
|     await appMP.checkToastMessage(); | 
|   }); | 
|   | 
|   describe('Create optimizer puzzle', () => { | 
|     it(`Step 1 - ${AppMP.getDemoDataPath(Demo.Food, Scenario.Base)}`, async () => { | 
|       await appMP.createDemoDataset(Demo.Food, Scenario.Base, true); | 
|     }); | 
|   | 
|     it(`Step 2 - Open view ${appMP.viewScenario.viewPath}.`, async () => { | 
|       await appMP.viewScenario.switchTo(); | 
|     }); | 
|   | 
|     it(`Step 3 - ${StepActionBarScenarioSelection.toggleOptimizerPuzzles(true)}`, async () => { | 
|       await abpScenarioSelection.toggleOptimizerPuzzles(true); | 
|     }); | 
|   | 
|     it(`Step 4 - ${StepList.rightClickSelectMenu(ListOptimizerPuzzles.title, ListOptimizerPuzzlesContextMenuItem.Create.Label)}`, async () => { | 
|       [dlgOptimizerPuzzles] = await listOptimizerPuzzles.selectContextMenu(ListOptimizerPuzzlesContextMenuItem.Create); | 
|     }); | 
|   | 
|     it(`Step 5 - ${StepDialog.verifyOKDisabled('OK', okButtonDisabledTooltip.mustHaveName())}`, async () => { | 
|       await dlgOptimizerPuzzles.verifyOKDisabled(okButtonDisabledTooltip.mustHaveName()); | 
|     }); | 
|   | 
|     it(`Step 6 - ${StepDialog.updateDialogValues(DialogOptimizerPuzzles.title, dlgInput)}`, async () => { | 
|       await dlgOptimizerPuzzles.updateDialogValues(dlgInput); | 
|     }); | 
|   | 
|     it(`Step 7 - ${StepDialog.clickOK()}`, async () => { | 
|       await dlgOptimizerPuzzles.clickOK(); | 
|     }); | 
|   | 
|     it(`Step 8 - ${StepList.verifyRowExists(ListOptimizerPuzzles.title, listInput)}`, async () => { | 
|       await listOptimizerPuzzles.verifyRowExists(listInput); | 
|     }); | 
|   | 
|     it(`Step 9 - ${StepActionBarPage.clickButton('Create')}`, async () => { | 
|       await listOptimizerPuzzles.clickActionButton(abpScenario.btnCreate); | 
|     }); | 
|   | 
|     it(`Step 10 - ${StepDialog.updateDialogValues(DialogOptimizerPuzzles.title, dlgInput)}`, async () => { | 
|       // Enter same as before to disable OK button | 
|       await dlgOptimizerPuzzles.updateDialogValues(dlgInput); | 
|     }); | 
|   | 
|     it(`Step 11 - ${StepDialog.verifyOKDisabled('OK', okButtonDisabledTooltip.nameMustUnique())}`, async () => { | 
|       await dlgOptimizerPuzzles.verifyOKDisabled(okButtonDisabledTooltip.nameMustUnique()); | 
|     }); | 
|   | 
|     it(`Step 12 - ${StepDialog.updateDialogValues(DialogOptimizerPuzzles.title, dlgInput2)}`, async () => { | 
|       await dlgOptimizerPuzzles.updateDialogValues(dlgInput2); | 
|     }); | 
|   | 
|     it(`Step 13 - ${StepDialog.clickOK()}`, async () => { | 
|       await dlgOptimizerPuzzles.clickOK(); | 
|     }); | 
|   | 
|     it(`Step 14 - ${StepList.verifyRowExists(ListOptimizerPuzzles.title, listInput2)}`, async () => { | 
|       await listOptimizerPuzzles.verifyRowExists(listInput2); | 
|     }); | 
|   }); | 
|   | 
|   describe('Edit optimizer puzzle', () => { | 
|     it(`Step 1 - ${StepList.selectRowAndClickMenu(ListOptimizerPuzzles.title, listInput, ListOptimizerPuzzlesContextMenuItem.Edit.Label)}`, async () => { | 
|       const row = await listOptimizerPuzzles.getRow(listInput); | 
|       await listOptimizerPuzzles.selectContextMenu(ListOptimizerPuzzlesContextMenuItem.Edit, row); | 
|     }); | 
|   | 
|     it(`Step 2 - ${StepDialog.verifyDialogValues(DialogOptimizerPuzzles.title, dlgInput)}`, async () => { | 
|       await dlgOptimizerPuzzles.verifyDialogValues(dlgInput); | 
|     }); | 
|   | 
|     it(`Step 3 - ${StepDialog.updateDialogValues(DialogOptimizerPuzzles.title, dlgEdittedInput)}`, async () => { | 
|       await dlgOptimizerPuzzles.updateDialogValues(dlgEdittedInput); | 
|     }); | 
|   | 
|     it(`Step 4 - ${StepDialog.clickOK()}`, async () => { | 
|       await dlgOptimizerPuzzles.clickOK(); | 
|     }); | 
|   | 
|     it(`Step 5 - ${StepList.verifyRowExists(ListOptimizerPuzzles.title, listEdittedInput)}`, async () => { | 
|       await listOptimizerPuzzles.verifyRowExists(listEdittedInput); | 
|     }); | 
|   | 
|     it(`Step 6 - ${StepList.selectRow(ListOptimizerPuzzles.title, listEdittedInput)} ${StepActionBarPage.clickButton('Edit')}`, async () => { | 
|       const row = await listOptimizerPuzzles.selectRow(listEdittedInput); | 
|       await listOptimizerPuzzles.clickActionButton(abpScenario.btnEdit, undefined, row); | 
|     }); | 
|   | 
|     it(`Step 7 - ${StepDialog.updateDialogValues(DialogOptimizerPuzzles.title, dlgInput)}`, async () => { | 
|       await dlgOptimizerPuzzles.updateDialogValues(dlgInput); | 
|     }); | 
|   | 
|     it(`Step 8 - ${StepDialog.clickOK()}`, async () => { | 
|       await dlgOptimizerPuzzles.clickOK(); | 
|     }); | 
|   | 
|     it(`Step 9 - ${StepList.verifyRowExists(ListOptimizerPuzzles.title, listInput)}`, async () => { | 
|       await listOptimizerPuzzles.verifyRowExists(listInput); | 
|     }); | 
|   }); | 
| }); |