diff --git a/src/ServicePulse.Host.Tests/tests/js/views/archive/controller.spec.js b/src/ServicePulse.Host.Tests/tests/js/views/archive/controller.spec.js new file mode 100644 index 000000000..e8279f015 --- /dev/null +++ b/src/ServicePulse.Host.Tests/tests/js/views/archive/controller.spec.js @@ -0,0 +1,67 @@ +describe('archivedMessageController', + function() { + beforeEach(module('sc')); + + var $controller; + + beforeEach(inject(function(_$controller_) { + $controller = _$controller_; + })); + + describe('when calling selectAllMessages', + function() { + var controller, serviceControlService, root, deferred, getFailedMessageSpy; + + beforeEach(inject(function ($rootScope, notifyService, $q) { + root = $rootScope; + this.notifyService = notifyService; + serviceControlService = { getExceptionGroups: function () { }, getFailedMessages: function(){ } }; + deferred = $q.defer(); + spyOn(serviceControlService, 'getExceptionGroups').and.callFake(function () { + + return deferred.promise; + }); + + getFailedMessageSpy = spyOn(serviceControlService, 'getFailedMessages').and.callFake(function () { + return deferred.promise; + }); + + controller = $controller('archivedMessageController', + { + $scope: root, + $interval: function(){}, + sharedDataService: { getstats: function() { return { number_of_pending_retries: 0 }; }, getConfiguration: function() {return {data_retention: {error_retention_period: "00:00:00"}};} }, + notifyService: notifyService, + serviceControlService: serviceControlService, + failedMessageGroupsService: null + }); + })); + + it('all messages should be selected', + function () { + + controller.archives = [{id: 0, selected: false}, {id: 1, selected: false}, {id:2, selected: false}]; + + controller.selectAllMessages(); + + expect(controller.archives[0].selected).toEqual(true); + expect(controller.archives[1].selected).toEqual(true); + expect(controller.archives[2].selected).toEqual(true); + expect(controller.selectedIds.length).toEqual(3); + }); + + it('if any message was selected, all should be unselected', + function () { + + controller.archives = [{id: 0, selected: false}, {id: 1, selected: true}, {id:2, selected: false}]; + controller.selectedIds = [1]; + + controller.selectAllMessages(); + + expect(controller.archives[0].selected).toEqual(false); + expect(controller.archives[1].selected).toEqual(false); + expect(controller.archives[2].selected).toEqual(false); + expect(controller.selectedIds.length).toEqual(0); + }); + }); + }); \ No newline at end of file diff --git a/src/ServicePulse.Host.Tests/tests/js/views/failed_messages/controller.spec.js b/src/ServicePulse.Host.Tests/tests/js/views/failed_messages/controller.spec.js index fd5ff0607..62bad145a 100644 --- a/src/ServicePulse.Host.Tests/tests/js/views/failed_messages/controller.spec.js +++ b/src/ServicePulse.Host.Tests/tests/js/views/failed_messages/controller.spec.js @@ -8,6 +8,65 @@ $controller = _$controller_; })); + describe('when calling selectAllMessages', + function() { + var controller, serviceControlService, root, deferred, getFailedMessageSpy; + + beforeEach(inject(function ($rootScope, notifyService, $q) { + root = $rootScope; + this.notifyService = notifyService; + serviceControlService = { getExceptionGroups: function () { }, getFailedMessages: function(){ } }; + deferred = $q.defer(); + spyOn(serviceControlService, 'getExceptionGroups').and.callFake(function () { + + return deferred.promise; + }); + + getFailedMessageSpy = spyOn(serviceControlService, 'getFailedMessages').and.callFake(function () { + return deferred.promise; + }); + + controller = $controller('failedMessagesController', + { + $scope: root, + $timeout: null, + $interval: function(){}, + $location: null, + sharedDataService: { getstats: function() { return { number_of_pending_retries: 0 }; } }, + notifyService: notifyService, + serviceControlService: serviceControlService, + failedMessageGroupsService: null + }); + })); + + it('all messages should be selected', + function () { + + controller.failedMessages = [{id: 0, selected: false}, {id: 1, selected: false}, {id:2, selected: false}]; + + controller.selectAllMessages(); + + expect(controller.failedMessages[0].selected).toEqual(true); + expect(controller.failedMessages[1].selected).toEqual(true); + expect(controller.failedMessages[2].selected).toEqual(true); + expect(controller.selectedIds.length).toEqual(3); + }); + + it('if any message was selected, all should be unselected', + function () { + + controller.failedMessages = [{id: 0, selected: false}, {id: 1, selected: true}, {id:2, selected: false}]; + controller.selectedIds = [1]; + + controller.selectAllMessages(); + + expect(controller.failedMessages[0].selected).toEqual(false); + expect(controller.failedMessages[1].selected).toEqual(false); + expect(controller.failedMessages[2].selected).toEqual(false); + expect(controller.selectedIds.length).toEqual(0); + }); + }); + describe('when loading the data with infinite scroll', function() { var controller, serviceControlService, root, deferred, getFailedMessageSpy; @@ -18,10 +77,10 @@ serviceControlService = { getExceptionGroups: function () { }, getFailedMessages: function(){ } }; deferred = $q.defer(); spyOn(serviceControlService, 'getExceptionGroups').and.callFake(function () { - + return deferred.promise; }); - + getFailedMessageSpy = spyOn(serviceControlService, 'getFailedMessages').and.callFake(function () { return deferred.promise; }); @@ -42,10 +101,10 @@ it('no load happens when initial load is in progress', function () { expect(getFailedMessageSpy).toHaveBeenCalledTimes(1); - + controller.loadMoreResults(controller.selectedExceptionGroup, true); - expect(getFailedMessageSpy).toHaveBeenCalledTimes(1); + expect(getFailedMessageSpy).toHaveBeenCalledTimes(1); }); it('load happens when initial load is done', @@ -58,5 +117,5 @@ expect(getFailedMessageSpy).toHaveBeenCalledTimes(2); }); - }); + }); }); \ No newline at end of file diff --git a/src/ServicePulse.Host/app/js/views/archive/archive-view.html b/src/ServicePulse.Host/app/js/views/archive/archive-view.html index 924a69f3b..1977fb739 100644 --- a/src/ServicePulse.Host/app/js/views/archive/archive-view.html +++ b/src/ServicePulse.Host/app/js/views/archive/archive-view.html @@ -13,7 +13,7 @@ - +
All deleted messages ({{vm.archives.length}} / {{vm.selectedExceptionGroup.count}} | number)
@@ -27,6 +27,7 @@

{{vm.total | number}} message
+