| /** | 
|  * @file        ADSO-49544 - Activate/Deactive New campaign optimizer | 
|  * @description Modify advanced setting in strategy - Campaign optimizer combinations | 
|  * @author      Zan Sen (zansen.tai@3ds.com) | 
|  * @copyright   Dassault Systèmes | 
|  */ | 
|   | 
| import { DataKPIName } from '../../libmp/data/data.kpi'; | 
| import { AppMP, Demo, Scenario } from '../../libmp/appmp'; | 
| import { DataMetalStrategyName } from '../../libmp/data/data.strategy'; | 
| import { qCustomMatcher } from '../../e2elib/lib/src/main/qmatchers.const'; | 
| import { ListStrategyContextMenuItem } from '../../libmp/forms/form.optimizerstrategies'; | 
| import { DialogStrategy, btnOkTooltip, campaignOptimizerTooltip } from '../../libmp/dialogs/dialog.strategy'; | 
|   | 
| describe('ADSO-49544 - Activate/Deactive New campaign optimizer.', () => { | 
|   // New dialog strategy instance to use active goal list name in steps | 
|   let dlgStrategy = new DialogStrategy(); | 
|   const isFullMatch = true; | 
|   const appMP = AppMP.getInstance(); | 
|   const viewOptimizerStrategies = appMP.viewOptimizerStrategies; | 
|   const listStrategy = appMP.viewOptimizerStrategies.frmOptimizerStrategies.listStrategy; | 
|   | 
|   beforeAll(async () => { | 
|     jasmine.addMatchers(qCustomMatcher); | 
|     await appMP.login(); | 
|   }); | 
|   | 
|   afterAll(async () => { | 
|     // Collapse the right docked optimizer strategies | 
|     await appMP.viewOptimizerStrategies.frmOptimizerStrategies.collapse(); | 
|     await appMP.cleanupAndLogout(); | 
|   }); | 
|   | 
|   afterEach(async () => { | 
|     await appMP.checkToastMessage(); | 
|   }); | 
|   | 
|   it(`Setup- ${AppMP.getDemoDataPath(Demo.Metals, Scenario.Base)}`, async () => { | 
|     await appMP.createDemoDataset(Demo.Metals, Scenario.Base, false); | 
|   }); | 
|   | 
|   it(`Step 1 - Click "${viewOptimizerStrategies.viewPath}" to open right docked form "${viewOptimizerStrategies.name}"`, async () => { | 
|     await viewOptimizerStrategies.switchTo(); | 
|   }); | 
|   | 
|   it(`Step 2 - Right click strategy "${DataMetalStrategyName.MaximizeEBITDA}" and select menu "${ListStrategyContextMenuItem.Edit.Label}".`, async () => { | 
|     const selectedRow = await listStrategy.getRow({ Name: DataMetalStrategyName.MaximizeEBITDA }); | 
|     [dlgStrategy] = await listStrategy.selectContextMenu(ListStrategyContextMenuItem.Edit, selectedRow); | 
|   }); | 
|   | 
|   it(`Step 3 - In list "${dlgStrategy.listActiveGoals.name}", right click "${DataKPIName.Campaign}" and select menu "${ListStrategyContextMenuItem.Edit.Label}". Set Weight = 1 and click OK. Verify Weight updated to 1.`, async () => { | 
|     await dlgStrategy.listActiveGoals.updateActiveGoalWeight(DataKPIName.Campaign, '1'); | 
|   }); | 
|   | 
|   it('Step 4 - Click "Advanced" tab and verify "Enable campaign sequencing optimizer" toggle off and "Maximum number of elements in campaign combi" is disabled and equals 4.', async () => { | 
|     await dlgStrategy.panelAdvanced.clickTab(); | 
|     await dlgStrategy.verifyDialogValues({ EnableCampaignOptimizer: 'false', MaxNrOfElementsInCampaignCombi: '4' }); | 
|     await dlgStrategy.verifyDialogEnabled({ MaxNrOfElementsInCampaignCombi: 'false' }); | 
|   }); | 
|   | 
|   it(`Step 5 - Hover "Enable campaign sequencing optimizer" and verify tooltip = "${campaignOptimizerTooltip.checkBox_enableCampaignOptimizer}".`, async () => { | 
|     await dlgStrategy.hoverElementVerifyTooltip({ EnableCampaignOptimizer: campaignOptimizerTooltip.checkBox_enableCampaignOptimizer }); | 
|   }); | 
|   | 
|   it(`Step 6 - Hover "Maximum number of elements in campaign combi" and verify tooltip = "${campaignOptimizerTooltip.editField_maxNrOfElementsInCampaignCombi}".`, async () => { | 
|     await dlgStrategy.hoverElementVerifyTooltip({ MaxNrOfElementsInCampaignCombi: campaignOptimizerTooltip.editField_maxNrOfElementsInCampaignCombi }); | 
|   }); | 
|   | 
|   it('Step 7 - Toggle on "Enable campaign sequencing optimizer" and verify "Maximum number of elements in campaign combi" enabled and defaulted to 4.', async () => { | 
|     await dlgStrategy.updateDialogValues({ EnableCampaignOptimizer: 'true' }); | 
|     await dlgStrategy.verifyDialogEnabled({ MaxNrOfElementsInCampaignCombi: 'true' }); | 
|     await dlgStrategy.verifyDialogValues({ MaxNrOfElementsInCampaignCombi: '4' }); | 
|   }); | 
|   | 
|   it(`Step 8 - Set "Maximum number of elements in campaign combi" = -1 and verify OK disabled with precondition = "${btnOkTooltip.maxNrOfElementsInCampaignCombi_isNumberNegative('-1')}".`, async () => { | 
|     await dlgStrategy.updateDialogValues({ MaxNrOfElementsInCampaignCombi: '-1' }); | 
|     await dlgStrategy.verifyOKDisabled(btnOkTooltip.maxNrOfElementsInCampaignCombi_isNumberNegative('-1'), isFullMatch); | 
|   }); | 
|   | 
|   it(`Step 9 - Set "Maximum number of elements in campaign combi" = 1.5 and verify OK disabled with precondition = "${btnOkTooltip.maxNrOfElementsInCampaignCombi_isInputInvalid()}".`, async () => { | 
|     await dlgStrategy.updateDialogValues({ MaxNrOfElementsInCampaignCombi: '1.5' }); | 
|     await dlgStrategy.verifyOKDisabled(btnOkTooltip.maxNrOfElementsInCampaignCombi_isInputInvalid(), isFullMatch); | 
|   }); | 
|   | 
|   it('Step 10 - Set "Maximum number of elements in campaign combi" = 5 and verify OK enabled. Click OK to save.', async () => { | 
|     await dlgStrategy.updateDialogValues({ MaxNrOfElementsInCampaignCombi: '5' }); | 
|     await dlgStrategy.verifyOKEnabled(); | 
|     await dlgStrategy.clickOK(); | 
|   }); | 
|   | 
|   it('Step 11 - Edit the strategy again. In dialog, verify Campaign Weight = 1.', async () => { | 
|     const selectedRow = await listStrategy.getRow({ Name: DataMetalStrategyName.MaximizeEBITDA }); | 
|     [dlgStrategy] = await listStrategy.selectContextMenu(ListStrategyContextMenuItem.Edit, selectedRow); | 
|     const selectedActiveGoal = await dlgStrategy.listActiveGoals.getRow({ KPI: DataKPIName.Campaign }); | 
|     await dlgStrategy.listActiveGoals.verifyRowValues(selectedActiveGoal, { Weight: '1' }); | 
|   }); | 
|   | 
|   it('Step 12 - Click "Advanced" tab. Verify "Enable campaign sequencing optimizer" toggle on and "Maximum number of elements in campaign combi" = 5.', async () => { | 
|     await dlgStrategy.panelAdvanced.clickTab(); | 
|     await dlgStrategy.verifyDialogValues({ EnableCampaignOptimizer: 'true', MaxNrOfElementsInCampaignCombi: '5' }); | 
|   }); | 
|   | 
|   it('Step 13 - Toggle off "Enable campaign sequencing optimizer" and verify "Maximum number of elements in campaign combi" is disabled. Click OK.', async () => { | 
|     await dlgStrategy.updateDialogValues({ EnableCampaignOptimizer: 'false' }); | 
|     await dlgStrategy.verifyDialogEnabled({ MaxNrOfElementsInCampaignCombi: 'false' }); | 
|     await dlgStrategy.clickOK(); | 
|   }); | 
|   | 
|   it(`Step 14 - Edit "${DataMetalStrategyName.MaximizeEBITDA}" again.`, async () => { | 
|     const selectedRow = await listStrategy.getRow({ Name: DataMetalStrategyName.MaximizeEBITDA }); | 
|     [dlgStrategy] = await listStrategy.selectContextMenu(ListStrategyContextMenuItem.Edit, selectedRow); | 
|   }); | 
|   | 
|   it('Step 15 - Click "Advanced" tab. Verify "Enable campaign sequencing optimizer" is unchecked and "Maximum number of elements in campaign combi" = 4 has been disabled. Click Cancel.', async () => { | 
|     await dlgStrategy.panelAdvanced.clickTab(); | 
|     await dlgStrategy.verifyDialogEnabled({ MaxNrOfElementsInCampaignCombi: 'false' }); | 
|     await dlgStrategy.verifyDialogValues({ EnableCampaignOptimizer: 'false', MaxNrOfElementsInCampaignCombi: '4' }); | 
|     await dlgStrategy.clickCancel(); | 
|   }); | 
| }); |