diff options
author | Ittay Stern <ittay.stern@att.com> | 2019-03-24 19:16:51 +0200 |
---|---|---|
committer | Ittay Stern <ittay.stern@att.com> | 2019-03-24 19:18:24 +0200 |
commit | ab7debfa76efa8cce94bb1244ec6b9ad7add427d (patch) | |
tree | d5f868b67d44317bf611c636b309541e259f8bef /vid-app-common/src/main/webapp | |
parent | 926100a4e3d59d0dbee1f79570fca98d177d323b (diff) |
Ingest SO Task fields: 'timeout' and 'description'
Follows discussion in SO-1594
Issue-ID: VID-403
Change-Id: I04b793d730c9a26d140f52197c103b14d1babd72
Signed-off-by: Ittay Stern <ittay.stern@att.com>
Diffstat (limited to 'vid-app-common/src/main/webapp')
2 files changed, 64 insertions, 5 deletions
diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/modals/change-management-manual-tasks-controller/change-management-manual-tasks.controller.js b/vid-app-common/src/main/webapp/app/vid/scripts/modals/change-management-manual-tasks-controller/change-management-manual-tasks.controller.js index bfe733023..c4f8f14a9 100644 --- a/vid-app-common/src/main/webapp/app/vid/scripts/modals/change-management-manual-tasks-controller/change-management-manual-tasks.controller.js +++ b/vid-app-common/src/main/webapp/app/vid/scripts/modals/change-management-manual-tasks-controller/change-management-manual-tasks.controller.js @@ -43,10 +43,12 @@ }; function loadAvailableTasks(requestId) { - MsoService.getManualTasks(requestId) + return MsoService.getManualTasks(requestId) .then(function(response) { vm.task = response.data[0]; vm.manualTasks = vm.task && vm.task.validResponses; + vm.description = vm.task && vm.task.description || null; + vm.timeout = vm.task && vm.task.timeout || null; }) .catch(function(error) { $log.error(error); @@ -73,6 +75,10 @@ return vm.manualTasks.includes(task); }; + vm.__test_only__ = { + loadAvailableTasks: loadAvailableTasks, + }; + init(); } })(); diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/modals/change-management-manual-tasks-controller/change-management-manual-tasks.controller.test.js b/vid-app-common/src/main/webapp/app/vid/scripts/modals/change-management-manual-tasks-controller/change-management-manual-tasks.controller.test.js index f5821f7de..93bc1c2de 100644 --- a/vid-app-common/src/main/webapp/app/vid/scripts/modals/change-management-manual-tasks-controller/change-management-manual-tasks.controller.test.js +++ b/vid-app-common/src/main/webapp/app/vid/scripts/modals/change-management-manual-tasks-controller/change-management-manual-tasks.controller.test.js @@ -32,9 +32,10 @@ describe('changeManagementManualTasksController testing', () => { ); beforeEach(inject(function (_$controller_) { - $MsoService.getManualTasks = jestMock.fn().mockResolvedValue( - {data: [manualTaskResponse]}); $log.error = jestMock.fn(); + $uibModalInstance.close = jestMock.fn(); + + mockManualTaskResponse(manualTaskResponse); $controller = _$controller_('changeManagementManualTasksController', { "MsoService": $MsoService, @@ -51,6 +52,12 @@ describe('changeManagementManualTasksController testing', () => { }); })); + function mockManualTaskResponse(manualTaskResponse) { + $MsoService.getManualTasks = jestMock.fn().mockResolvedValue( + {data: [manualTaskResponse]} + ); + } + const job = { "requestId": "db775fac-d9b5-480e-8b3e-4f0d0ae67890", "requestScope": "vnf", @@ -69,16 +76,34 @@ describe('changeManagementManualTasksController testing', () => { } }; - const manualTaskResponse = { + const manualTaskResponseWithoutValidResponses = { "taskId": "db775fac-d9b5-480e-8b3e-4f0d0ae67890", - "validResponses": ["rollback", "abort", "skip", "resume", "retry"] }; + const manualTaskResponse = Object.assign({ + "validResponses": ["rollback", "abort", "skip", "resume", "retry"], + }, manualTaskResponseWithoutValidResponses); + + const manualTaskResponseWithTimeout = Object.assign({ + description: 'description', + timeout: 'timeout', + }, manualTaskResponse); + test('should populate vm.manualTasks (while init)', () => { expect($controller.manualTasks).toEqual( manualTaskResponse.validResponses); }); + test('should undefine vm.manualTasks when ValidResponses not given', () => { + // given + mockManualTaskResponse(manualTaskResponseWithoutValidResponses); + // when + return $controller.__test_only__.loadAvailableTasks('anything') + .then(() => { + expect($controller.manualTasks).toBeUndefined() + }); + }); + test('should populate vm.MANUAL_TASKS from COMPONENT (while init)', () => { expect($controller.MANUAL_TASKS).toEqual( ["manualTaskName1", "manualTaskName2"]); @@ -88,6 +113,34 @@ describe('changeManagementManualTasksController testing', () => { expect($controller.task).toEqual(manualTaskResponse); }); + test('should nullify vm.description (while init)', () => { + expect($controller.description).toBeNull(); + }); + + test('should nullify vm.timeout (while init)', () => { + expect($controller.timeout).toBeNull(); + }); + + test('should populate vm.description', () => { + // given + mockManualTaskResponse(manualTaskResponseWithTimeout); + // when + return $controller.__test_only__.loadAvailableTasks('anything') + .then(() => { + expect($controller.description).toEqual('description'); + }); + }); + + test('should populate vm.timeout', () => { + // given + mockManualTaskResponse(manualTaskResponseWithTimeout); + // when + return $controller.__test_only__.loadAvailableTasks('anything') + .then(() => { + expect($controller.timeout).toEqual('timeout'); + }); + }); + test('should find manual task using isTaskAvailable', () => { expect($controller.isTaskAvailable('abort')).toBeTruthy(); expect($controller.isTaskAvailable('resume')).toBeTruthy(); |