Merge pull request #16474 from sushantpaste/test-for-pr-13809
[civicrm-core.git] / tests / karma / unit / crmCaseTypeSpec.js
1 /* global $, _, CRM:true */
2 'use strict';
3
4 describe('crmCaseType', function() {
5 var $controller;
6 var $compile;
7 var $httpBackend;
8 var $q;
9 var $rootScope;
10 var $timeout;
11 var apiCalls;
12 var ctrl;
13 var compile;
14 var defaultAssigneeDefaultValue;
15 var scope;
16
17 beforeEach(function() {
18 CRM.resourceUrls = {
19 'civicrm': ''
20 };
21 module('crmCaseType');
22 module('crmJsonComparator');
23 inject(function(crmJsonComparator) {
24 crmJsonComparator.register(jasmine);
25 });
26 });
27
28 beforeEach(inject(function(_$controller_, _$compile_, _$httpBackend_, _$q_, _$rootScope_, _$timeout_) {
29 $controller = _$controller_;
30 $compile = _$compile_;
31 $httpBackend = _$httpBackend_;
32 $q = _$q_;
33 $rootScope = _$rootScope_;
34 $rootScope.ts = CRM.ts(null);
35 $timeout = _$timeout_;
36 }));
37
38 describe('CaseTypeCtrl', function() {
39 beforeEach(function () {
40 apiCalls = {
41 actStatuses: {
42 values: [
43 {
44 "id": "272",
45 "option_group_id": "25",
46 "label": "Scheduled",
47 "value": "1",
48 "name": "Scheduled",
49 "filter": "0",
50 "is_default": "1",
51 "weight": "1",
52 "is_optgroup": "0",
53 "is_reserved": "1",
54 "is_active": "1"
55 },
56 {
57 "id": "273",
58 "option_group_id": "25",
59 "label": "Completed",
60 "value": "2",
61 "name": "Completed",
62 "filter": "0",
63 "weight": "2",
64 "is_optgroup": "0",
65 "is_reserved": "1",
66 "is_active": "1"
67 }
68 ]
69 },
70 caseStatuses: {
71 values: [
72 {
73 "id": "290",
74 "option_group_id": "28",
75 "label": "Ongoing",
76 "value": "1",
77 "name": "Open",
78 "grouping": "Opened",
79 "filter": "0",
80 "is_default": "1",
81 "weight": "1",
82 "is_optgroup": "0",
83 "is_reserved": "1",
84 "is_active": "1"
85 },
86 {
87 "id": "291",
88 "option_group_id": "28",
89 "label": "Resolved",
90 "value": "2",
91 "name": "Closed",
92 "grouping": "Closed",
93 "filter": "0",
94 "weight": "2",
95 "is_optgroup": "0",
96 "is_reserved": "1",
97 "is_active": "1"
98 }
99 ]
100 },
101 actTypes: {
102 values: [
103 {
104 "id": "784",
105 "option_group_id": "2",
106 "label": "ADC referral",
107 "value": "62",
108 "name": "ADC referral",
109 "filter": "0",
110 "is_default": "0",
111 "weight": "64",
112 "is_optgroup": "0",
113 "is_reserved": "0",
114 "is_active": "1",
115 "component_id": "7"
116 },
117 {
118 "id": "32",
119 "option_group_id": "2",
120 "label": "Add Client To Case",
121 "value": "27",
122 "name": "Add Client To Case",
123 "filter": "0",
124 "is_default": "0",
125 "weight": "26",
126 "description": "",
127 "is_optgroup": "0",
128 "is_reserved": "1",
129 "is_active": "1",
130 "component_id": "7"
131 },
132 {
133 "id": "18",
134 "option_group_id": "2",
135 "label": "Open Case",
136 "value": "13",
137 "name": "Open Case",
138 "filter": "0",
139 "is_default": "0",
140 "weight": "13",
141 "is_optgroup": "0",
142 "is_reserved": "1",
143 "is_active": "1",
144 "component_id": "7",
145 "icon": "fa-folder-open-o"
146 },
147 {
148 "id": "857",
149 "option_group_id": "2",
150 "label": "Medical evaluation",
151 "value": "55",
152 "name": "Medical evaluation",
153 "filter": "0",
154 "is_default": "0",
155 "weight": "56",
156 "is_optgroup": "0",
157 "is_reserved": "0",
158 "is_active": "1",
159 "component_id": "7"
160 },
161 ]
162 },
163 relTypes: {
164 values: [
165 {
166 "id": "14",
167 "name_a_b": "Benefits Specialist is",
168 "label_a_b": "Benefits Specialist is",
169 "name_b_a": "Benefits Specialist",
170 "label_b_a": "Benefits Specialist",
171 "description": "Benefits Specialist",
172 "contact_type_a": "Individual",
173 "contact_type_b": "Individual",
174 "is_reserved": "0",
175 "is_active": "1"
176 },
177 {
178 "id": "9",
179 "name_a_b": "Case Coordinator is",
180 "label_a_b": "Case Coordinator is",
181 "name_b_a": "Case Coordinator",
182 "label_b_a": "Case Coordinator",
183 "description": "Case Coordinator",
184 "contact_type_a": "Individual",
185 "contact_type_b": "Individual",
186 "is_reserved": "0",
187 "is_active": "1"
188 },
189 {
190 "id": "10",
191 "name_a_b": "Homeless Services Coordinator is",
192 "label_a_b": "Homeless Services Coordinator is",
193 "name_b_a": "Homeless Services Coordinator",
194 "label_b_a": "Homeless Services Coordinator",
195 "description": "Homeless Services Coordinator",
196 "contact_type_a": "Individual",
197 "contact_type_b": "Individual",
198 "is_reserved": "0",
199 "is_active": "1"
200 },
201 {
202 "id": "2",
203 "name_a_b": "Spouse of",
204 "label_a_b": "Spouse of",
205 "name_b_a": "Spouse of",
206 "label_b_a": "Spouse of",
207 "description": "Spousal relationship.",
208 "contact_type_a": "Individual",
209 "contact_type_b": "Individual",
210 "is_reserved": "0",
211 "is_active": "1"
212 },
213 // include one where name is different from label
214 {
215 "id": "27",
216 "name_a_b": "GA123ab",
217 "label_a_b": "Guardian Angel is",
218 "name_b_a": "GA123ba",
219 "label_b_a": "Guardian Angel for",
220 "description": "Guardian Angel.",
221 "contact_type_a": "Individual",
222 "contact_type_b": "Individual",
223 "is_reserved": "0",
224 "is_active": "1"
225 }
226 ]
227 },
228 caseType: {
229 "id": "1",
230 "name": "housing_support",
231 "title": "Housing Support",
232 "description": "Help homeless individuals obtain temporary and long-term housing",
233 "is_active": "1",
234 "is_reserved": "0",
235 "weight": "1",
236 "is_forkable": "1",
237 "is_forked": "",
238 "definition": {
239 "activityTypes": [
240 {"name": "Open Case", "max_instances": "1"}
241 ],
242 "activitySets": [
243 {
244 "name": "standard_timeline",
245 "label": "Standard Timeline",
246 "timeline": "1",
247 "activityTypes": [
248 {
249 "name": "Open Case",
250 "status": "Completed"
251 },
252 {
253 "name": "Medical evaluation",
254 "reference_activity": "Open Case",
255 "reference_offset": "1",
256 "reference_select": "newest"
257 }
258 ]
259 }
260 ],
261 "caseRoles": [
262 {
263 "name": "Homeless Services Coordinator",
264 "creator": "1",
265 "manager": "1"
266 }
267 ]
268 }
269 },
270 defaultAssigneeTypes: {
271 values: [
272 {
273 "id": "1174",
274 "option_group_id": "152",
275 "label": "None",
276 "value": "1",
277 "name": "NONE",
278 "filter": "0",
279 "is_default": "1",
280 "weight": "1",
281 "is_optgroup": "0",
282 "is_reserved": "0",
283 "is_active": "1"
284 },
285 {
286 "id": "1175",
287 "option_group_id": "152",
288 "label": "By relationship to workflow client",
289 "value": "2",
290 "name": "BY_RELATIONSHIP",
291 "filter": "0",
292 "is_default": "0",
293 "weight": "2",
294 "is_optgroup": "0",
295 "is_reserved": "0",
296 "is_active": "1"
297 },
298 {
299 "id": "1176",
300 "option_group_id": "152",
301 "label": "Specific contact",
302 "value": "3",
303 "name": "SPECIFIC_CONTACT",
304 "filter": "0",
305 "is_default": "0",
306 "weight": "3",
307 "is_optgroup": "0",
308 "is_reserved": "0",
309 "is_active": "1"
310 },
311 {
312 "id": "1177",
313 "option_group_id": "152",
314 "label": "User creating the workflow",
315 "value": "4",
316 "name": "USER_CREATING_THE_CASE",
317 "filter": "0",
318 "is_default": "0",
319 "weight": "4",
320 "is_optgroup": "0",
321 "is_reserved": "0",
322 "is_active": "1"
323 }
324 ]
325 }
326 };
327 defaultAssigneeDefaultValue = _.find(apiCalls.defaultAssigneeTypes.values, { is_default: '1' });
328 scope = $rootScope.$new();
329 ctrl = $controller('CaseTypeCtrl', {$scope: scope, apiCalls: apiCalls});
330 });
331
332 it('should load activity statuses', function() {
333 expect(scope.activityStatuses).toEqualData(apiCalls.actStatuses.values);
334 });
335
336 it('should load activity types', function() {
337 expect(scope.activityTypes['ADC referral']).toEqualData(apiCalls.actTypes.values[0]);
338 });
339
340 it('should store the default assignee types', function() {
341 expect(scope.defaultAssigneeTypes).toBe(apiCalls.defaultAssigneeTypes.values);
342 });
343
344 it('should store the default assignee types values indexed by name', function() {
345 var defaultAssigneeTypeValues = _.chain(apiCalls.defaultAssigneeTypes.values)
346 .indexBy('name').mapValues('value').value();
347
348 expect(scope.defaultAssigneeTypeValues).toEqual(defaultAssigneeTypeValues);
349 });
350
351 it('should compute the relationship type options', function() {
352 var expectedRelationshipTypeOptions = [
353 {
354 "id": "14_a_b",
355 "text": "Benefits Specialist",
356 "xmlName": "Benefits Specialist is"
357 },
358 {
359 "id": "14_b_a",
360 "text": "Benefits Specialist is",
361 "xmlName": "Benefits Specialist"
362 },
363 {
364 "id": "9_a_b",
365 "text": "Case Coordinator",
366 "xmlName": "Case Coordinator is"
367 },
368 {
369 "id": "9_b_a",
370 "text": "Case Coordinator is",
371 "xmlName": "Case Coordinator"
372 },
373 {
374 "id": "10_a_b",
375 "text": "Homeless Services Coordinator",
376 "xmlName": "Homeless Services Coordinator is"
377 },
378 {
379 "id": "10_b_a",
380 "text": "Homeless Services Coordinator is",
381 "xmlName": "Homeless Services Coordinator"
382 },
383 // Bidirectional, so should only have the one direction in the list
384 {
385 "id": "2_a_b",
386 "text": "Spouse of",
387 "xmlName": "Spouse of"
388 },
389 // include one where name is different from label
390 {
391 "id": "27_a_b",
392 "text": "Guardian Angel for",
393 "xmlName": "GA123ab",
394 },
395 {
396 "id": "27_b_a",
397 "text": "Guardian Angel is",
398 "xmlName": "GA123ba",
399 }
400 ];
401
402 expect(scope.relationshipTypeOptions).toEqual(expectedRelationshipTypeOptions);
403 });
404
405 it('addActivitySet should add an activitySet to the case type', function() {
406 scope.addActivitySet('timeline');
407 var activitySets = scope.caseType.definition.activitySets;
408 var newSet = activitySets[activitySets.length - 1];
409 expect(newSet.name).toBe('timeline_1');
410 expect(newSet.timeline).toBe('1');
411 expect(newSet.label).toBe('Timeline');
412 });
413
414 it('addActivitySet handles second timeline correctly', function() {
415 scope.addActivitySet('timeline');
416 scope.addActivitySet('timeline');
417 var activitySets = scope.caseType.definition.activitySets;
418 var newSet = activitySets[activitySets.length - 1];
419 expect(newSet.name).toBe('timeline_2');
420 expect(newSet.timeline).toBe('1');
421 expect(newSet.label).toBe('Timeline #2');
422 });
423
424 describe('when clearing the activity\'s default assignee type values', function() {
425 var activity;
426
427 beforeEach(function() {
428 activity = {
429 default_assignee_relationship: 1,
430 default_assignee_contact: 2
431 };
432
433 scope.clearActivityDefaultAssigneeValues(activity);
434 });
435
436 it('clears the default assignee relationship for the activity', function() {
437 expect(activity.default_assignee_relationship).toBe(null);
438 });
439
440 it('clears the default assignee contact for the activity', function() {
441 expect(activity.default_assignee_contact).toBe(null);
442 });
443 });
444
445 describe('when adding a new activity to a set', function() {
446 var activitySet;
447
448 beforeEach(function() {
449 activitySet = { activityTypes: [] };
450 scope.activityTypes = { comment: { label: 'Add a new comment' } };
451
452 scope.addActivity(activitySet, 'comment');
453 });
454
455 it('adds a new Comment activity to the set', function() {
456 expect(activitySet.activityTypes[0]).toEqual({
457 name: 'comment',
458 label: scope.activityTypes.comment.label,
459 status: 'Scheduled',
460 reference_activity: 'Open Case',
461 reference_offset: '1',
462 reference_select: 'newest',
463 default_assignee_type: defaultAssigneeDefaultValue.value
464 });
465 });
466 });
467
468 describe('when creating a new workflow', function() {
469 beforeEach(inject(function ($controller) {
470 apiCalls.caseType = null;
471
472 ctrl = $controller('CaseTypeCtrl', {$scope: scope, apiCalls: apiCalls});
473 }));
474
475 it('sets default values for the case type title, name, and active status', function() {
476 expect(scope.caseType).toEqual(jasmine.objectContaining({
477 title: '',
478 name: '',
479 is_active: '1'
480 }));
481 });
482
483 it('adds an Open Case activty to the default activty set', function() {
484 expect(scope.caseType.definition.activitySets[0].activityTypes).toEqual([{
485 name: 'Open Case',
486 label: 'Open Case',
487 status: 'Completed',
488 default_assignee_type: defaultAssigneeDefaultValue.value
489 }]);
490 });
491 });
492
493 describe('when adding a role', function() {
494 beforeEach(inject(function ($controller) {
495 ctrl = $controller('CaseTypeCtrl', {$scope: scope, apiCalls: apiCalls});
496 }));
497
498 it('updates the case roles', function() {
499
500 // This line sort of simulates selecting a relationship type from the
501 // dropdown. It doesn't test that clicking picks the right value to
502 // add, just that if it did then the function that gets called does
503 // the right thing with it.
504 // Note the value returned by the dropdown is "backwards" to match
505 // historically what has been stored in the xml as name, e.g.
506 // for the client perspective direction the dropdown returns the other
507 // direction.
508 // So 9_b_a is "Case Coordinator", which means that they actually
509 // selected "Case Coordinator is".
510 scope.addRole(scope.caseType.definition.caseRoles, '9_b_a');
511
512 expect(scope.caseType.definition.caseRoles).toEqual(
513 [
514 {
515 name: 'Homeless Services Coordinator',
516 creator: '1',
517 manager: '1',
518 displayLabel: 'Homeless Services Coordinator is'
519 },
520 {
521 name: 'Case Coordinator',
522 displayLabel: 'Case Coordinator is'
523 }
524 ]
525 );
526 });
527
528 it('updates case roles when name and label are different', function() {
529 scope.addRole(scope.caseType.definition.caseRoles, '27_b_a');
530 expect(scope.caseType.definition.caseRoles).toEqual(
531 [
532 {
533 name: 'Homeless Services Coordinator',
534 creator: '1',
535 manager: '1',
536 displayLabel: 'Homeless Services Coordinator is'
537 },
538 {
539 name: 'GA123ba',
540 displayLabel: 'Guardian Angel is'
541 }
542 ]
543 );
544 });
545
546 it('updates case roles if choose non-client-perspective direction', function() {
547 // again, the dropdown returns the opposite direction
548 scope.addRole(scope.caseType.definition.caseRoles, '10_a_b');
549 expect(scope.caseType.definition.caseRoles).toEqual(
550 [
551 {
552 name: 'Homeless Services Coordinator',
553 creator: '1',
554 manager: '1',
555 displayLabel: 'Homeless Services Coordinator is'
556 },
557 {
558 name: 'Homeless Services Coordinator is',
559 displayLabel: 'Homeless Services Coordinator'
560 }
561 ]
562 );
563 });
564
565 it('updates case roles non-client-perspective direction name/label different', function() {
566 scope.addRole(scope.caseType.definition.caseRoles, '27_a_b');
567 expect(scope.caseType.definition.caseRoles).toEqual(
568 [
569 {
570 name: 'Homeless Services Coordinator',
571 creator: '1',
572 manager: '1',
573 displayLabel: 'Homeless Services Coordinator is'
574 },
575 {
576 name: 'GA123ab',
577 displayLabel: 'Guardian Angel for'
578 }
579 ]
580 );
581 });
582
583 it("doesn't add the same role twice", function() {
584 // This is in the mock casetype to start, so check if can add twice.
585 scope.addRole(scope.caseType.definition.caseRoles, '10_b_a');
586 expect(scope.caseType.definition.caseRoles).toEqual(
587 [
588 {
589 name: 'Homeless Services Coordinator',
590 creator: '1',
591 manager: '1',
592 displayLabel: 'Homeless Services Coordinator is'
593 }
594 ]
595 );
596
597 // Try with name and label different. We already tested one time in
598 // another test so just go straight to twice.
599 scope.addRole(scope.caseType.definition.caseRoles, '27_b_a');
600 scope.addRole(scope.caseType.definition.caseRoles, '27_b_a');
601 expect(scope.caseType.definition.caseRoles).toEqual(
602 [
603 {
604 name: 'Homeless Services Coordinator',
605 creator: '1',
606 manager: '1',
607 displayLabel: 'Homeless Services Coordinator is'
608 },
609 {
610 name: 'GA123ba',
611 displayLabel: 'Guardian Angel is'
612 }
613 ]
614 );
615 });
616 });
617
618 describe('when adding a role on-the-fly', function() {
619 beforeEach(inject(function ($controller) {
620 ctrl = $controller('CaseTypeCtrl', {$scope: scope, apiCalls: apiCalls});
621 }));
622
623 it('updates the case roles for unidirectional', function() {
624 // first simulate the ajax popup to create a new relationship type
625 var newType = {
626 "id": "33",
627 "name_a_b": "Some New Type is",
628 "label_a_b": "Some New Type is",
629 "name_b_a": "Some New Type for",
630 "label_b_a": "Some New Type for",
631 "description": "Some New Type",
632 "contact_type_a": "Individual",
633 "contact_type_b": "Individual",
634 "is_reserved": "0",
635 "is_active": "1"
636 };
637
638 // now let the real code do what it does with the new type
639 scope.addRoleOnTheFly(scope.caseType.definition.caseRoles, newType);
640
641 expect(scope.caseType.definition.caseRoles).toEqual(
642 [
643 {
644 name: 'Homeless Services Coordinator',
645 creator: '1',
646 manager: '1',
647 displayLabel: 'Homeless Services Coordinator is'
648 },
649 {
650 name: 'Some New Type for',
651 displayLabel: 'Some New Type is'
652 }
653 ]
654 );
655
656 expect(scope.relationshipTypeOptions.slice(-2)).toEqual(
657 [
658 {
659 xmlName: 'Some New Type is',
660 id: '33_a_b',
661 text: 'Some New Type for'
662 },
663 {
664 xmlName: 'Some New Type for',
665 id: '33_b_a',
666 text: 'Some New Type is'
667 }
668 ]
669 );
670 });
671
672 it('updates the case roles for bidirectional', function() {
673 // first simulate the ajax popup to create a new relationship type
674 var newType = {
675 "id": "34",
676 "name_a_b": "Friend of",
677 "label_a_b": "Friend of",
678 "name_b_a": "Friend of",
679 "label_b_a": "Friend of",
680 "description": "Friend",
681 "contact_type_a": "Individual",
682 "contact_type_b": "Individual",
683 "is_reserved": "0",
684 "is_active": "1"
685 };
686
687 // now let the real code do what it does with the new type
688 scope.addRoleOnTheFly(scope.caseType.definition.caseRoles, newType);
689
690 expect(scope.caseType.definition.caseRoles).toEqual(
691 [
692 {
693 name: 'Homeless Services Coordinator',
694 creator: '1',
695 manager: '1',
696 displayLabel: 'Homeless Services Coordinator is'
697 },
698 {
699 name: 'Friend of',
700 displayLabel: 'Friend of'
701 }
702 ]
703 );
704
705 expect(scope.relationshipTypeOptions.slice(-1)).toEqual(
706 [
707 {
708 xmlName: 'Friend of',
709 id: '34_a_b',
710 text: 'Friend of'
711 }
712 ]
713 );
714
715 // Check that it did NOT add two entries for this bidirectional type
716 expect(scope.relationshipTypeOptions.slice(-2,-1)).not.toEqual(
717 [
718 {
719 xmlName: 'Friend of',
720 id: '34_b_a',
721 text: 'Friend of'
722 }
723 ]
724 );
725 });
726 });
727 });
728
729 describe('crmAddName', function () {
730 var element;
731
732 beforeEach(function() {
733 scope = $rootScope.$new();
734 scope.activityTypeOptions = [1, 2, 3];
735 element = '<span crm-add-name crm-options="activityTypeOptions"></span>';
736
737 spyOn(CRM.$.fn, 'crmSelect2').and.callThrough();
738
739 element = $compile(element)(scope);
740 scope.$digest();
741 });
742
743 describe('when initialized', function () {
744 var returnValue;
745
746 beforeEach (function () {
747 var dataFunction = CRM.$.fn.crmSelect2.calls.argsFor(0)[0].data;
748 returnValue = dataFunction();
749 });
750
751 it('updates the UI with updated value of scope variable', function () {
752 expect(returnValue).toEqual({ results: scope.activityTypeOptions });
753 });
754 });
755 });
756
757 describe('crmEditableTabTitle', function () {
758 var element, titleLabel, penIcon, saveButton, cancelButton;
759
760 beforeEach(function() {
761 scope = $rootScope.$new();
762 element = '<div crm-editable-tab-title title="Click to edit">' +
763 '<span>{{ activitySet.label }}</span>' +
764 '</div>';
765
766 scope.activitySet = { label: 'Title'};
767 element = $compile(element)(scope);
768
769 titleLabel = $(element).find('span');
770 penIcon = $(element).find('i.fa-pencil');
771 saveButton = $(element).find('button[type=button]');
772 cancelButton = $(element).find('button[type=cancel]');
773
774 scope.$digest();
775 });
776
777 describe('when initialized', function () {
778 it('hides the save and cancel button', function () {
779 expect(saveButton.parent().css('display') === 'none').toBe(true);
780 expect(cancelButton.parent().css('display') === 'none').toBe(true);
781 });
782 });
783
784 describe('when clicked on title label', function () {
785 beforeEach(function () {
786 titleLabel.click();
787 });
788
789 it('hides the pen icon', function () {
790 expect(penIcon.css('display') === 'none').toBe(true);
791 });
792
793 it('shows the save button', function () {
794 expect(saveButton.parent().css('display') !== 'none').toBe(true);
795 });
796
797 it('makes the title editable', function () {
798 expect(titleLabel.attr('contenteditable')).toBe('true');
799 });
800 });
801
802 describe('when clicked outside of the editable area', function () {
803 beforeEach(function () {
804 titleLabel.click();
805 titleLabel.text('Updated Title');
806 titleLabel.blur();
807 $timeout.flush();
808 scope.$digest();
809 });
810
811 it('shows the pen icon', function () {
812 expect(penIcon.css('display') !== 'none').toBe(true);
813 });
814
815 it('hides the save and cancel button', function () {
816 expect(saveButton.parent().css('display') === 'none').toBe(true);
817 expect(cancelButton.parent().css('display') === 'none').toBe(true);
818 });
819
820 it('makes the title non editable', function () {
821 expect(titleLabel.attr('contenteditable')).not.toBe('true');
822 });
823
824 it('does not update the title in angular context', function () {
825 expect(scope.activitySet.label).toBe('Title');
826 });
827 });
828
829 describe('when ESCAPE key is pressed while typing', function () {
830 beforeEach(function () {
831 var eventObj = $.Event('keydown');
832 eventObj.key = 'Escape';
833
834 titleLabel.click();
835 titleLabel.text('Updated Title');
836 titleLabel.trigger(eventObj);
837 scope.$digest();
838 });
839
840 it('shows the pen icon', function () {
841 expect(penIcon.css('display') !== 'none').toBe(true);
842 });
843
844 it('hides the save and cancel button', function () {
845 expect(saveButton.parent().css('display') === 'none').toBe(true);
846 expect(cancelButton.parent().css('display') === 'none').toBe(true);
847 });
848
849 it('makes the title non editable', function () {
850 expect(titleLabel.attr('contenteditable')).not.toBe('true');
851 });
852
853 it('does not update the title', function () {
854 expect(scope.activitySet.label).toBe('Title');
855 });
856 });
857
858 describe('when ENTER key is pressed while typing', function () {
859 beforeEach(function () {
860 var eventObj = $.Event('keydown');
861 eventObj.key = 'Enter';
862
863 titleLabel.click();
864 titleLabel.text('Updated Title');
865 titleLabel.trigger(eventObj);
866 scope.$digest();
867 });
868
869 it('shows the pen icon', function () {
870 expect(penIcon.css('display') !== 'none').toBe(true);
871 });
872
873 it('hides the save and cancel button', function () {
874 expect(saveButton.parent().css('display') === 'none').toBe(true);
875 expect(cancelButton.parent().css('display') === 'none').toBe(true);
876 });
877
878 it('makes the title non editable', function () {
879 expect(titleLabel.attr('contenteditable')).not.toBe('true');
880 });
881
882 it('updates the title in angular context', function () {
883 expect(scope.activitySet.label).toBe('Updated Title');
884 });
885 });
886
887 describe('when SAVE button is clicked', function () {
888 beforeEach(function () {
889 titleLabel.click();
890 titleLabel.text('Updated Title');
891 saveButton.click();
892 scope.$digest();
893 });
894
895 it('shows the pen icon', function () {
896 expect(penIcon.css('display') !== 'none').toBe(true);
897 });
898
899 it('hides the save and cancel button', function () {
900 expect(saveButton.parent().css('display') === 'none').toBe(true);
901 expect(cancelButton.parent().css('display') === 'none').toBe(true);
902 });
903
904 it('makes the title non editable', function () {
905 expect(titleLabel.attr('contenteditable')).not.toBe('true');
906 });
907
908 it('updates the title in angular context', function () {
909 expect(scope.activitySet.label).toBe('Updated Title');
910 });
911 });
912
913 describe('when CANCEL button is clicked', function () {
914 beforeEach(function () {
915 titleLabel.click();
916 titleLabel.text('Updated Title');
917 cancelButton.click();
918 scope.$digest();
919 });
920
921 it('shows the pen icon', function () {
922 expect(penIcon.css('display') !== 'none').toBe(true);
923 });
924
925 it('hides the save and cancel button', function () {
926 expect(saveButton.parent().css('display') === 'none').toBe(true);
927 expect(cancelButton.parent().css('display') === 'none').toBe(true);
928 });
929
930 it('makes the title non editable', function () {
931 expect(titleLabel.attr('contenteditable')).not.toBe('true');
932 });
933
934 it('does not update the title in angular context', function () {
935 expect(scope.activitySet.label).toBe('Title');
936 });
937 });
938 });
939
940 describe('CaseTypeListCtrl', function() {
941 var caseTypes, crmApiSpy;
942
943 beforeEach(function() {
944 caseTypes = {
945 values: {
946 1: { id: 1 },
947 2: { id: 2 },
948 3: { id: 3 }
949 }
950 };
951 crmApiSpy = jasmine.createSpy('crmApi').and.returnValue($q.resolve());
952 scope = $rootScope.$new();
953 ctrl = $controller('CaseTypeListCtrl', {
954 $scope: scope,
955 caseTypes: caseTypes,
956 crmApi: crmApiSpy
957 });
958 });
959
960 it('should store an index of case types', function() {
961 expect(scope.caseTypes).toEqual(caseTypes.values);
962 });
963
964 describe('toggleCaseType', function() {
965 var caseType = { id: _.uniqueId() };
966
967 describe('when the case is active', function() {
968 beforeEach(function() {
969 caseType.is_active = '1';
970
971 scope.toggleCaseType(caseType);
972 });
973
974 it('sets the case type as inactive', function() {
975 expect(crmApiSpy).toHaveBeenCalledWith('CaseType', 'create', jasmine.objectContaining({
976 id: caseType.id,
977 is_active: '0'
978 }), true);
979 });
980 });
981
982 describe('when the case is inactive', function() {
983 beforeEach(function() {
984 caseType.is_active = '0';
985
986 scope.toggleCaseType(caseType);
987 });
988
989 it('sets the case type as active', function() {
990 expect(crmApiSpy).toHaveBeenCalledWith('CaseType', 'create', jasmine.objectContaining({
991 id: caseType.id,
992 is_active: '1'
993 }), true);
994 });
995 });
996 });
997
998 describe('deleteCaseType', function() {
999 var caseType = { id: _.uniqueId() };
1000
1001 beforeEach(function() {
1002 crmApiSpy.and.returnValue($q.resolve(caseType));
1003 scope.caseTypes[caseType.id] = caseType;
1004
1005 scope.deleteCaseType(caseType);
1006 scope.$digest();
1007 });
1008
1009 describe('when the case type can be deleted', function() {
1010 it('deletes the case from the api', function() {
1011 expect(crmApiSpy).toHaveBeenCalledWith('CaseType', 'delete', { id: caseType.id }, jasmine.any(Object));
1012 });
1013
1014 it('removes the case type from the list', function() {
1015 expect(scope.caseTypes[caseType.id]).toBeUndefined();
1016 });
1017 });
1018
1019 describe('when the case type cannot be delted', function() {
1020 var error = { error_message: 'Error Message' };
1021
1022 beforeEach(function() {
1023 var errorHandler;
1024
1025 crmApiSpy.and.returnValue($q.reject(error));
1026 scope.caseTypes[caseType.id] = caseType;
1027
1028 spyOn(CRM, 'alert');
1029 scope.deleteCaseType(caseType);
1030 scope.$digest();
1031
1032 errorHandler = crmApiSpy.calls.mostRecent().args[3].error;
1033 errorHandler(error);
1034 });
1035
1036 it('displays the error message', function() {
1037 expect(CRM.alert).toHaveBeenCalledWith(error.error_message, 'Error', 'error');
1038 });
1039 });
1040
1041 describe('revertCaseType', function() {
1042 var caseType = {
1043 id: _.uniqueId(),
1044 definition: {},
1045 is_forked: '1'
1046 };
1047
1048 describe('when reverting a case type', function() {
1049 beforeEach(function() {
1050 scope.revertCaseType(caseType);
1051 });
1052
1053 it('resets the case type information using the api', function() {
1054 expect(crmApiSpy).toHaveBeenCalledWith('CaseType', 'create', jasmine.objectContaining({
1055 id: caseType.id,
1056 definition: 'null',
1057 is_forked: '0'
1058 }), true);
1059 });
1060 });
1061 });
1062 });
1063
1064 // Test show/hide for the various dropdown actions
1065 describe('showandtell', function() {
1066 var templateCache;
1067 var template;
1068
1069 // $templateCache is populated by the nghtml2js plugin. See karma.conf.js
1070 // I'm not sure why it can't be injected higher up in the hierarchy. It doesn't seem to work?
1071 beforeEach(inject(function($templateCache) {
1072 scope = $rootScope.$new();
1073 templateCache = $templateCache;
1074 template = templateCache.get('~/crmCaseType/list.html');
1075 }));
1076
1077 // Helper function which we call repeatedly. It can't be in beforeEach
1078 // because then the timing is wrong because we need different caseTypes
1079 // in each test, which happens of course after beforeEach.
1080 var compileTemplate = function(scope) {
1081 var element = $compile(template)(scope);
1082 scope.$digest();
1083 return element;
1084 };
1085
1086 // This is the workhorse function that does the actual test, called
1087 // repeatedly for each case type variation from the `it()` below.
1088 var doTest = function(inputCaseType, expected) {
1089 // Mock up our case types based on input, merging some static info
1090 // with the variable input.
1091 var caseType = {
1092 id: 1,
1093 title: 'Housing Support',
1094 name: 'housing_support'
1095 };
1096 // PhantomJS at the moment doesn't support ES6, so do a loop.
1097 for (var memberVar in inputCaseType) {
1098 caseType[memberVar] = inputCaseType[memberVar];
1099 }
1100 scope.caseTypes = {
1101 1: caseType
1102 };
1103
1104 // Render the template in the context of our scope now that the scope
1105 // contains our mock case types.
1106 var element = compileTemplate(scope);
1107 //console.debug(element);
1108
1109 //
1110 // Now verify the expected values
1111 //
1112
1113 // Useful variable for displaying the inputs that caused failure
1114 // in readable form.
1115 var inputStr = JSON.stringify(inputCaseType);
1116
1117 expect(element.find('span.more-panel').hasClass('ng-hide')).toBe(expected.more_hidden, 'More link should be ' +
1118 (expected.more_hidden ? 'hidden' : 'visible') +
1119 ' for ' + inputStr);
1120
1121 expect(element.find('li.panel-item-enable').hasClass('ng-hide')).toBe(expected.enable_hidden, 'Enable should be ' +
1122 (expected.enable_hidden ? 'hidden' : 'visible') +
1123 ' for ' + inputStr);
1124
1125 expect(element.find('li.panel-item-disable').hasClass('ng-hide')).toBe(expected.disable_hidden, 'Disable should be ' +
1126 (expected.disable_hidden ? 'hidden' : 'visible') +
1127 ' for ' + inputStr);
1128
1129 expect(element.find('li.panel-item-revert').hasClass('ng-hide')).toBe(expected.revert_hidden, 'Revert should be ' +
1130 (expected.revert_hidden ? 'hidden' : 'visible') +
1131 ' for ' + inputStr);
1132
1133 expect(element.find('li.panel-item-delete').hasClass('ng-hide')).toBe(expected.delete_hidden, 'Delete should be ' +
1134 (expected.delete_hidden ? 'hidden' : 'visible') +
1135 ' for ' + inputStr);
1136 };
1137
1138 // Test show/hide for the various dropdown actions
1139 //
1140 // There's 625 assertions.
1141 // Three variables: [is_active, is_forked, is_reserved],
1142 // each with 5 possible values: [0, 1, "0", "1", undefined].
1143 // Then, multiply that by 5 because there are 5 UI elements
1144 // to be checked.
1145 // So 125 possible input tuples, with 5 things to check in each test.
1146 it('to be or not to be', function() {
1147 var caseTypeSimulations = [
1148 [
1149 // input case type
1150 {"is_active": "1", "is_reserved": "0"},
1151 {
1152 // should more link be hidden
1153 "more_hidden": false,
1154 // should enable choice be hidden
1155 "enable_hidden": true,
1156 // should disable choice be hidden
1157 "disable_hidden": false,
1158 // should revert choice be hidden
1159 "revert_hidden": true,
1160 // should delete choice be hidden
1161 "delete_hidden": false
1162 }
1163 ],
1164
1165 [
1166 {"is_active":0,"is_reserved":0,"is_forked":0},
1167 {
1168 "more_hidden": false,
1169 "enable_hidden": false,
1170 "disable_hidden": true,
1171 "revert_hidden": true,
1172 "delete_hidden": false
1173 }
1174 ],
1175
1176 [
1177 {"is_active":0,"is_reserved":0,"is_forked":1},
1178 {
1179 "more_hidden": false,
1180 "enable_hidden": false,
1181 "disable_hidden": true,
1182 "revert_hidden": false,
1183 "delete_hidden": false
1184 }
1185 ],
1186
1187 [
1188 {"is_active":0,"is_reserved":0,"is_forked":"0"},
1189 {
1190 "more_hidden": false,
1191 "enable_hidden": false,
1192 "disable_hidden": true,
1193 "revert_hidden": true,
1194 "delete_hidden": false
1195 }
1196 ],
1197
1198 [
1199 {"is_active":0,"is_reserved":0,"is_forked":"1"},
1200 {
1201 "more_hidden": false,
1202 "enable_hidden": false,
1203 "disable_hidden": true,
1204 "revert_hidden": false,
1205 "delete_hidden": false
1206 }
1207 ],
1208
1209 [
1210 {"is_active":0,"is_reserved":0},
1211 {
1212 "more_hidden": false,
1213 "enable_hidden": false,
1214 "disable_hidden": true,
1215 "revert_hidden": true,
1216 "delete_hidden": false
1217 }
1218 ],
1219
1220 [
1221 {"is_active":0,"is_reserved":1,"is_forked":0},
1222 {
1223 "more_hidden": false,
1224 "enable_hidden": false,
1225 "disable_hidden": true,
1226 "revert_hidden": true,
1227 "delete_hidden": true
1228 }
1229 ],
1230
1231 [
1232 {"is_active":0,"is_reserved":1,"is_forked":1},
1233 {
1234 "more_hidden": false,
1235 "enable_hidden": false,
1236 "disable_hidden": true,
1237 "revert_hidden": false,
1238 "delete_hidden": true
1239 }
1240 ],
1241
1242 [
1243 {"is_active":0,"is_reserved":1,"is_forked":"0"},
1244 {
1245 "more_hidden": false,
1246 "enable_hidden": false,
1247 "disable_hidden": true,
1248 "revert_hidden": true,
1249 "delete_hidden": true
1250 }
1251 ],
1252
1253 [
1254 {"is_active":0,"is_reserved":1,"is_forked":"1"},
1255 {
1256 "more_hidden": false,
1257 "enable_hidden": false,
1258 "disable_hidden": true,
1259 "revert_hidden": false,
1260 "delete_hidden": true
1261 }
1262 ],
1263
1264 [
1265 {"is_active":0,"is_reserved":1},
1266 {
1267 "more_hidden": false,
1268 "enable_hidden": false,
1269 "disable_hidden": true,
1270 "revert_hidden": true,
1271 "delete_hidden": true
1272 }
1273 ],
1274
1275 [
1276 {"is_active":0,"is_reserved":"0","is_forked":0},
1277 {
1278 "more_hidden": false,
1279 "enable_hidden": false,
1280 "disable_hidden": true,
1281 "revert_hidden": true,
1282 "delete_hidden": false
1283 }
1284 ],
1285
1286 [
1287 {"is_active":0,"is_reserved":"0","is_forked":1},
1288 {
1289 "more_hidden": false,
1290 "enable_hidden": false,
1291 "disable_hidden": true,
1292 "revert_hidden": false,
1293 "delete_hidden": false
1294 }
1295 ],
1296
1297 [
1298 {"is_active":0,"is_reserved":"0","is_forked":"0"},
1299 {
1300 "more_hidden": false,
1301 "enable_hidden": false,
1302 "disable_hidden": true,
1303 "revert_hidden": true,
1304 "delete_hidden": false
1305 }
1306 ],
1307
1308 [
1309 {"is_active":0,"is_reserved":"0","is_forked":"1"},
1310 {
1311 "more_hidden": false,
1312 "enable_hidden": false,
1313 "disable_hidden": true,
1314 "revert_hidden": false,
1315 "delete_hidden": false
1316 }
1317 ],
1318
1319 [
1320 {"is_active":0,"is_reserved":"0"},
1321 {
1322 "more_hidden": false,
1323 "enable_hidden": false,
1324 "disable_hidden": true,
1325 "revert_hidden": true,
1326 "delete_hidden": false
1327 }
1328 ],
1329
1330 [
1331 {"is_active":0,"is_reserved":"1","is_forked":0},
1332 {
1333 "more_hidden": false,
1334 "enable_hidden": false,
1335 "disable_hidden": true,
1336 "revert_hidden": true,
1337 "delete_hidden": true
1338 }
1339 ],
1340
1341 [
1342 {"is_active":0,"is_reserved":"1","is_forked":1},
1343 {
1344 "more_hidden": false,
1345 "enable_hidden": false,
1346 "disable_hidden": true,
1347 "revert_hidden": false,
1348 "delete_hidden": true
1349 }
1350 ],
1351
1352 [
1353 {"is_active":0,"is_reserved":"1","is_forked":"0"},
1354 {
1355 "more_hidden": false,
1356 "enable_hidden": false,
1357 "disable_hidden": true,
1358 "revert_hidden": true,
1359 "delete_hidden": true
1360 }
1361 ],
1362
1363 [
1364 {"is_active":0,"is_reserved":"1","is_forked":"1"},
1365 {
1366 "more_hidden": false,
1367 "enable_hidden": false,
1368 "disable_hidden": true,
1369 "revert_hidden": false,
1370 "delete_hidden": true
1371 }
1372 ],
1373
1374 [
1375 {"is_active":0,"is_reserved":"1"},
1376 {
1377 "more_hidden": false,
1378 "enable_hidden": false,
1379 "disable_hidden": true,
1380 "revert_hidden": true,
1381 "delete_hidden": true
1382 }
1383 ],
1384
1385 [
1386 {"is_active":0,"is_forked":0},
1387 {
1388 "more_hidden": false,
1389 "enable_hidden": false,
1390 "disable_hidden": true,
1391 "revert_hidden": true,
1392 "delete_hidden": false
1393 }
1394 ],
1395
1396 [
1397 {"is_active":0,"is_forked":1},
1398 {
1399 "more_hidden": false,
1400 "enable_hidden": false,
1401 "disable_hidden": true,
1402 "revert_hidden": false,
1403 "delete_hidden": false
1404 }
1405 ],
1406
1407 [
1408 {"is_active":0,"is_forked":"0"},
1409 {
1410 "more_hidden": false,
1411 "enable_hidden": false,
1412 "disable_hidden": true,
1413 "revert_hidden": true,
1414 "delete_hidden": false
1415 }
1416 ],
1417
1418 [
1419 {"is_active":0,"is_forked":"1"},
1420 {
1421 "more_hidden": false,
1422 "enable_hidden": false,
1423 "disable_hidden": true,
1424 "revert_hidden": false,
1425 "delete_hidden": false
1426 }
1427 ],
1428
1429 [
1430 {"is_active":0},
1431 {
1432 "more_hidden": false,
1433 "enable_hidden": false,
1434 "disable_hidden": true,
1435 "revert_hidden": true,
1436 "delete_hidden": false
1437 }
1438 ],
1439
1440 [
1441 {"is_active":1,"is_reserved":0,"is_forked":0},
1442 {
1443 "more_hidden": false,
1444 "enable_hidden": true,
1445 "disable_hidden": false,
1446 "revert_hidden": true,
1447 "delete_hidden": false
1448 }
1449 ],
1450
1451 [
1452 {"is_active":1,"is_reserved":0,"is_forked":1},
1453 {
1454 "more_hidden": false,
1455 "enable_hidden": true,
1456 "disable_hidden": false,
1457 "revert_hidden": false,
1458 "delete_hidden": false
1459 }
1460 ],
1461
1462 [
1463 {"is_active":1,"is_reserved":0,"is_forked":"0"},
1464 {
1465 "more_hidden": false,
1466 "enable_hidden": true,
1467 "disable_hidden": false,
1468 "revert_hidden": true,
1469 "delete_hidden": false
1470 }
1471 ],
1472
1473 [
1474 {"is_active":1,"is_reserved":0,"is_forked":"1"},
1475 {
1476 "more_hidden": false,
1477 "enable_hidden": true,
1478 "disable_hidden": false,
1479 "revert_hidden": false,
1480 "delete_hidden": false
1481 }
1482 ],
1483
1484 [
1485 {"is_active":1,"is_reserved":0},
1486 {
1487 "more_hidden": false,
1488 "enable_hidden": true,
1489 "disable_hidden": false,
1490 "revert_hidden": true,
1491 "delete_hidden": false
1492 }
1493 ],
1494
1495 [
1496 {"is_active":1,"is_reserved":1,"is_forked":0},
1497 {
1498 "more_hidden": true,
1499 "enable_hidden": true,
1500 "disable_hidden": true,
1501 "revert_hidden": true,
1502 "delete_hidden": true
1503 }
1504 ],
1505
1506 [
1507 {"is_active":1,"is_reserved":1,"is_forked":1},
1508 {
1509 "more_hidden": false,
1510 "enable_hidden": true,
1511 "disable_hidden": true,
1512 "revert_hidden": false,
1513 "delete_hidden": true
1514 }
1515 ],
1516
1517 [
1518 {"is_active":1,"is_reserved":1,"is_forked":"0"},
1519 {
1520 "more_hidden": true,
1521 "enable_hidden": true,
1522 "disable_hidden": true,
1523 "revert_hidden": true,
1524 "delete_hidden": true
1525 }
1526 ],
1527
1528 [
1529 {"is_active":1,"is_reserved":1,"is_forked":"1"},
1530 {
1531 "more_hidden": false,
1532 "enable_hidden": true,
1533 "disable_hidden": true,
1534 "revert_hidden": false,
1535 "delete_hidden": true
1536 }
1537 ],
1538
1539 [
1540 {"is_active":1,"is_reserved":1},
1541 {
1542 "more_hidden": true,
1543 "enable_hidden": true,
1544 "disable_hidden": true,
1545 "revert_hidden": true,
1546 "delete_hidden": true
1547 }
1548 ],
1549
1550 [
1551 {"is_active":1,"is_reserved":"0","is_forked":0},
1552 {
1553 "more_hidden": false,
1554 "enable_hidden": true,
1555 "disable_hidden": false,
1556 "revert_hidden": true,
1557 "delete_hidden": false
1558 }
1559 ],
1560
1561 [
1562 {"is_active":1,"is_reserved":"0","is_forked":1},
1563 {
1564 "more_hidden": false,
1565 "enable_hidden": true,
1566 "disable_hidden": false,
1567 "revert_hidden": false,
1568 "delete_hidden": false
1569 }
1570 ],
1571
1572 [
1573 {"is_active":1,"is_reserved":"0","is_forked":"0"},
1574 {
1575 "more_hidden": false,
1576 "enable_hidden": true,
1577 "disable_hidden": false,
1578 "revert_hidden": true,
1579 "delete_hidden": false
1580 }
1581 ],
1582
1583 [
1584 {"is_active":1,"is_reserved":"0","is_forked":"1"},
1585 {
1586 "more_hidden": false,
1587 "enable_hidden": true,
1588 "disable_hidden": false,
1589 "revert_hidden": false,
1590 "delete_hidden": false
1591 }
1592 ],
1593
1594 [
1595 {"is_active":1,"is_reserved":"0"},
1596 {
1597 "more_hidden": false,
1598 "enable_hidden": true,
1599 "disable_hidden": false,
1600 "revert_hidden": true,
1601 "delete_hidden": false
1602 }
1603 ],
1604
1605 [
1606 {"is_active":1,"is_reserved":"1","is_forked":0},
1607 {
1608 "more_hidden": true,
1609 "enable_hidden": true,
1610 "disable_hidden": true,
1611 "revert_hidden": true,
1612 "delete_hidden": true
1613 }
1614 ],
1615
1616 [
1617 {"is_active":1,"is_reserved":"1","is_forked":1},
1618 {
1619 "more_hidden": false,
1620 "enable_hidden": true,
1621 "disable_hidden": true,
1622 "revert_hidden": false,
1623 "delete_hidden": true
1624 }
1625 ],
1626
1627 [
1628 {"is_active":1,"is_reserved":"1","is_forked":"0"},
1629 {
1630 "more_hidden": true,
1631 "enable_hidden": true,
1632 "disable_hidden": true,
1633 "revert_hidden": true,
1634 "delete_hidden": true
1635 }
1636 ],
1637
1638 [
1639 {"is_active":1,"is_reserved":"1","is_forked":"1"},
1640 {
1641 "more_hidden": false,
1642 "enable_hidden": true,
1643 "disable_hidden": true,
1644 "revert_hidden": false,
1645 "delete_hidden": true
1646 }
1647 ],
1648
1649 [
1650 {"is_active":1,"is_reserved":"1"},
1651 {
1652 "more_hidden": true,
1653 "enable_hidden": true,
1654 "disable_hidden": true,
1655 "revert_hidden": true,
1656 "delete_hidden": true
1657 }
1658 ],
1659
1660 [
1661 {"is_active":1,"is_forked":0},
1662 {
1663 "more_hidden": false,
1664 "enable_hidden": true,
1665 "disable_hidden": false,
1666 "revert_hidden": true,
1667 "delete_hidden": false
1668 }
1669 ],
1670
1671 [
1672 {"is_active":1,"is_forked":1},
1673 {
1674 "more_hidden": false,
1675 "enable_hidden": true,
1676 "disable_hidden": false,
1677 "revert_hidden": false,
1678 "delete_hidden": false
1679 }
1680 ],
1681
1682 [
1683 {"is_active":1,"is_forked":"0"},
1684 {
1685 "more_hidden": false,
1686 "enable_hidden": true,
1687 "disable_hidden": false,
1688 "revert_hidden": true,
1689 "delete_hidden": false
1690 }
1691 ],
1692
1693 [
1694 {"is_active":1,"is_forked":"1"},
1695 {
1696 "more_hidden": false,
1697 "enable_hidden": true,
1698 "disable_hidden": false,
1699 "revert_hidden": false,
1700 "delete_hidden": false
1701 }
1702 ],
1703
1704 [
1705 {"is_active":1},
1706 {
1707 "more_hidden": false,
1708 "enable_hidden": true,
1709 "disable_hidden": false,
1710 "revert_hidden": true,
1711 "delete_hidden": false
1712 }
1713 ],
1714
1715 [
1716 {"is_active":"0","is_reserved":0,"is_forked":0},
1717 {
1718 "more_hidden": false,
1719 "enable_hidden": false,
1720 "disable_hidden": true,
1721 "revert_hidden": true,
1722 "delete_hidden": false
1723 }
1724 ],
1725
1726 [
1727 {"is_active":"0","is_reserved":0,"is_forked":1},
1728 {
1729 "more_hidden": false,
1730 "enable_hidden": false,
1731 "disable_hidden": true,
1732 "revert_hidden": false,
1733 "delete_hidden": false
1734 }
1735 ],
1736
1737 [
1738 {"is_active":"0","is_reserved":0,"is_forked":"0"},
1739 {
1740 "more_hidden": false,
1741 "enable_hidden": false,
1742 "disable_hidden": true,
1743 "revert_hidden": true,
1744 "delete_hidden": false
1745 }
1746 ],
1747
1748 [
1749 {"is_active":"0","is_reserved":0,"is_forked":"1"},
1750 {
1751 "more_hidden": false,
1752 "enable_hidden": false,
1753 "disable_hidden": true,
1754 "revert_hidden": false,
1755 "delete_hidden": false
1756 }
1757 ],
1758
1759 [
1760 {"is_active":"0","is_reserved":0},
1761 {
1762 "more_hidden": false,
1763 "enable_hidden": false,
1764 "disable_hidden": true,
1765 "revert_hidden": true,
1766 "delete_hidden": false
1767 }
1768 ],
1769
1770 [
1771 {"is_active":"0","is_reserved":1,"is_forked":0},
1772 {
1773 "more_hidden": false,
1774 "enable_hidden": false,
1775 "disable_hidden": true,
1776 "revert_hidden": true,
1777 "delete_hidden": true
1778 }
1779 ],
1780
1781 [
1782 {"is_active":"0","is_reserved":1,"is_forked":1},
1783 {
1784 "more_hidden": false,
1785 "enable_hidden": false,
1786 "disable_hidden": true,
1787 "revert_hidden": false,
1788 "delete_hidden": true
1789 }
1790 ],
1791
1792 [
1793 {"is_active":"0","is_reserved":1,"is_forked":"0"},
1794 {
1795 "more_hidden": false,
1796 "enable_hidden": false,
1797 "disable_hidden": true,
1798 "revert_hidden": true,
1799 "delete_hidden": true
1800 }
1801 ],
1802
1803 [
1804 {"is_active":"0","is_reserved":1,"is_forked":"1"},
1805 {
1806 "more_hidden": false,
1807 "enable_hidden": false,
1808 "disable_hidden": true,
1809 "revert_hidden": false,
1810 "delete_hidden": true
1811 }
1812 ],
1813
1814 [
1815 {"is_active":"0","is_reserved":1},
1816 {
1817 "more_hidden": false,
1818 "enable_hidden": false,
1819 "disable_hidden": true,
1820 "revert_hidden": true,
1821 "delete_hidden": true
1822 }
1823 ],
1824
1825 [
1826 {"is_active":"0","is_reserved":"0","is_forked":0},
1827 {
1828 "more_hidden": false,
1829 "enable_hidden": false,
1830 "disable_hidden": true,
1831 "revert_hidden": true,
1832 "delete_hidden": false
1833 }
1834 ],
1835
1836 [
1837 {"is_active":"0","is_reserved":"0","is_forked":1},
1838 {
1839 "more_hidden": false,
1840 "enable_hidden": false,
1841 "disable_hidden": true,
1842 "revert_hidden": false,
1843 "delete_hidden": false
1844 }
1845 ],
1846
1847 [
1848 {"is_active":"0","is_reserved":"0","is_forked":"0"},
1849 {
1850 "more_hidden": false,
1851 "enable_hidden": false,
1852 "disable_hidden": true,
1853 "revert_hidden": true,
1854 "delete_hidden": false
1855 }
1856 ],
1857
1858 [
1859 {"is_active":"0","is_reserved":"0","is_forked":"1"},
1860 {
1861 "more_hidden": false,
1862 "enable_hidden": false,
1863 "disable_hidden": true,
1864 "revert_hidden": false,
1865 "delete_hidden": false
1866 }
1867 ],
1868
1869 [
1870 {"is_active":"0","is_reserved":"0"},
1871 {
1872 "more_hidden": false,
1873 "enable_hidden": false,
1874 "disable_hidden": true,
1875 "revert_hidden": true,
1876 "delete_hidden": false
1877 }
1878 ],
1879
1880 [
1881 {"is_active":"0","is_reserved":"1","is_forked":0},
1882 {
1883 "more_hidden": false,
1884 "enable_hidden": false,
1885 "disable_hidden": true,
1886 "revert_hidden": true,
1887 "delete_hidden": true
1888 }
1889 ],
1890
1891 [
1892 {"is_active":"0","is_reserved":"1","is_forked":1},
1893 {
1894 "more_hidden": false,
1895 "enable_hidden": false,
1896 "disable_hidden": true,
1897 "revert_hidden": false,
1898 "delete_hidden": true
1899 }
1900 ],
1901
1902 [
1903 {"is_active":"0","is_reserved":"1","is_forked":"0"},
1904 {
1905 "more_hidden": false,
1906 "enable_hidden": false,
1907 "disable_hidden": true,
1908 "revert_hidden": true,
1909 "delete_hidden": true
1910 }
1911 ],
1912
1913 [
1914 {"is_active":"0","is_reserved":"1","is_forked":"1"},
1915 {
1916 "more_hidden": false,
1917 "enable_hidden": false,
1918 "disable_hidden": true,
1919 "revert_hidden": false,
1920 "delete_hidden": true
1921 }
1922 ],
1923
1924 [
1925 {"is_active":"0","is_reserved":"1"},
1926 {
1927 "more_hidden": false,
1928 "enable_hidden": false,
1929 "disable_hidden": true,
1930 "revert_hidden": true,
1931 "delete_hidden": true
1932 }
1933 ],
1934
1935 [
1936 {"is_active":"0","is_forked":0},
1937 {
1938 "more_hidden": false,
1939 "enable_hidden": false,
1940 "disable_hidden": true,
1941 "revert_hidden": true,
1942 "delete_hidden": false
1943 }
1944 ],
1945
1946 [
1947 {"is_active":"0","is_forked":1},
1948 {
1949 "more_hidden": false,
1950 "enable_hidden": false,
1951 "disable_hidden": true,
1952 "revert_hidden": false,
1953 "delete_hidden": false
1954 }
1955 ],
1956
1957 [
1958 {"is_active":"0","is_forked":"0"},
1959 {
1960 "more_hidden": false,
1961 "enable_hidden": false,
1962 "disable_hidden": true,
1963 "revert_hidden": true,
1964 "delete_hidden": false
1965 }
1966 ],
1967
1968 [
1969 {"is_active":"0","is_forked":"1"},
1970 {
1971 "more_hidden": false,
1972 "enable_hidden": false,
1973 "disable_hidden": true,
1974 "revert_hidden": false,
1975 "delete_hidden": false
1976 }
1977 ],
1978
1979 [
1980 {"is_active":"0"},
1981 {
1982 "more_hidden": false,
1983 "enable_hidden": false,
1984 "disable_hidden": true,
1985 "revert_hidden": true,
1986 "delete_hidden": false
1987 }
1988 ],
1989
1990 [
1991 {"is_active":"1","is_reserved":0,"is_forked":0},
1992 {
1993 "more_hidden": false,
1994 "enable_hidden": true,
1995 "disable_hidden": false,
1996 "revert_hidden": true,
1997 "delete_hidden": false
1998 }
1999 ],
2000
2001 [
2002 {"is_active":"1","is_reserved":0,"is_forked":1},
2003 {
2004 "more_hidden": false,
2005 "enable_hidden": true,
2006 "disable_hidden": false,
2007 "revert_hidden": false,
2008 "delete_hidden": false
2009 }
2010 ],
2011
2012 [
2013 {"is_active":"1","is_reserved":0,"is_forked":"0"},
2014 {
2015 "more_hidden": false,
2016 "enable_hidden": true,
2017 "disable_hidden": false,
2018 "revert_hidden": true,
2019 "delete_hidden": false
2020 }
2021 ],
2022
2023 [
2024 {"is_active":"1","is_reserved":0,"is_forked":"1"},
2025 {
2026 "more_hidden": false,
2027 "enable_hidden": true,
2028 "disable_hidden": false,
2029 "revert_hidden": false,
2030 "delete_hidden": false
2031 }
2032 ],
2033
2034 [
2035 {"is_active":"1","is_reserved":0},
2036 {
2037 "more_hidden": false,
2038 "enable_hidden": true,
2039 "disable_hidden": false,
2040 "revert_hidden": true,
2041 "delete_hidden": false
2042 }
2043 ],
2044
2045 [
2046 {"is_active":"1","is_reserved":1,"is_forked":0},
2047 {
2048 "more_hidden": true,
2049 "enable_hidden": true,
2050 "disable_hidden": true,
2051 "revert_hidden": true,
2052 "delete_hidden": true
2053 }
2054 ],
2055
2056 [
2057 {"is_active":"1","is_reserved":1,"is_forked":1},
2058 {
2059 "more_hidden": false,
2060 "enable_hidden": true,
2061 "disable_hidden": true,
2062 "revert_hidden": false,
2063 "delete_hidden": true
2064 }
2065 ],
2066
2067 [
2068 {"is_active":"1","is_reserved":1,"is_forked":"0"},
2069 {
2070 "more_hidden": true,
2071 "enable_hidden": true,
2072 "disable_hidden": true,
2073 "revert_hidden": true,
2074 "delete_hidden": true
2075 }
2076 ],
2077
2078 [
2079 {"is_active":"1","is_reserved":1,"is_forked":"1"},
2080 {
2081 "more_hidden": false,
2082 "enable_hidden": true,
2083 "disable_hidden": true,
2084 "revert_hidden": false,
2085 "delete_hidden": true
2086 }
2087 ],
2088
2089 [
2090 {"is_active":"1","is_reserved":1},
2091 {
2092 "more_hidden": true,
2093 "enable_hidden": true,
2094 "disable_hidden": true,
2095 "revert_hidden": true,
2096 "delete_hidden": true
2097 }
2098 ],
2099
2100 [
2101 {"is_active":"1","is_reserved":"0","is_forked":0},
2102 {
2103 "more_hidden": false,
2104 "enable_hidden": true,
2105 "disable_hidden": false,
2106 "revert_hidden": true,
2107 "delete_hidden": false
2108 }
2109 ],
2110
2111 [
2112 {"is_active":"1","is_reserved":"0","is_forked":1},
2113 {
2114 "more_hidden": false,
2115 "enable_hidden": true,
2116 "disable_hidden": false,
2117 "revert_hidden": false,
2118 "delete_hidden": false
2119 }
2120 ],
2121
2122 [
2123 {"is_active":"1","is_reserved":"0","is_forked":"0"},
2124 {
2125 "more_hidden": false,
2126 "enable_hidden": true,
2127 "disable_hidden": false,
2128 "revert_hidden": true,
2129 "delete_hidden": false
2130 }
2131 ],
2132
2133 [
2134 {"is_active":"1","is_reserved":"0","is_forked":"1"},
2135 {
2136 "more_hidden": false,
2137 "enable_hidden": true,
2138 "disable_hidden": false,
2139 "revert_hidden": false,
2140 "delete_hidden": false
2141 }
2142 ],
2143
2144 [
2145 {"is_active":"1","is_reserved":"0"},
2146 {
2147 "more_hidden": false,
2148 "enable_hidden": true,
2149 "disable_hidden": false,
2150 "revert_hidden": true,
2151 "delete_hidden": false
2152 }
2153 ],
2154
2155 [
2156 {"is_active":"1","is_reserved":"1","is_forked":0},
2157 {
2158 "more_hidden": true,
2159 "enable_hidden": true,
2160 "disable_hidden": true,
2161 "revert_hidden": true,
2162 "delete_hidden": true
2163 }
2164 ],
2165
2166 [
2167 {"is_active":"1","is_reserved":"1","is_forked":1},
2168 {
2169 "more_hidden": false,
2170 "enable_hidden": true,
2171 "disable_hidden": true,
2172 "revert_hidden": false,
2173 "delete_hidden": true
2174 }
2175 ],
2176
2177 [
2178 {"is_active":"1","is_reserved":"1","is_forked":"0"},
2179 {
2180 "more_hidden": true,
2181 "enable_hidden": true,
2182 "disable_hidden": true,
2183 "revert_hidden": true,
2184 "delete_hidden": true
2185 }
2186 ],
2187
2188 [
2189 {"is_active":"1","is_reserved":"1","is_forked":"1"},
2190 {
2191 "more_hidden": false,
2192 "enable_hidden": true,
2193 "disable_hidden": true,
2194 "revert_hidden": false,
2195 "delete_hidden": true
2196 }
2197 ],
2198
2199 [
2200 {"is_active":"1","is_reserved":"1"},
2201 {
2202 "more_hidden": true,
2203 "enable_hidden": true,
2204 "disable_hidden": true,
2205 "revert_hidden": true,
2206 "delete_hidden": true
2207 }
2208 ],
2209
2210 [
2211 {"is_active":"1","is_forked":0},
2212 {
2213 "more_hidden": false,
2214 "enable_hidden": true,
2215 "disable_hidden": false,
2216 "revert_hidden": true,
2217 "delete_hidden": false
2218 }
2219 ],
2220
2221 [
2222 {"is_active":"1","is_forked":1},
2223 {
2224 "more_hidden": false,
2225 "enable_hidden": true,
2226 "disable_hidden": false,
2227 "revert_hidden": false,
2228 "delete_hidden": false
2229 }
2230 ],
2231
2232 [
2233 {"is_active":"1","is_forked":"0"},
2234 {
2235 "more_hidden": false,
2236 "enable_hidden": true,
2237 "disable_hidden": false,
2238 "revert_hidden": true,
2239 "delete_hidden": false
2240 }
2241 ],
2242
2243 [
2244 {"is_active":"1","is_forked":"1"},
2245 {
2246 "more_hidden": false,
2247 "enable_hidden": true,
2248 "disable_hidden": false,
2249 "revert_hidden": false,
2250 "delete_hidden": false
2251 }
2252 ],
2253
2254 [
2255 {"is_active":"1"},
2256 {
2257 "more_hidden": false,
2258 "enable_hidden": true,
2259 "disable_hidden": false,
2260 "revert_hidden": true,
2261 "delete_hidden": false
2262 }
2263 ],
2264
2265 [
2266 {"is_reserved":0,"is_forked":0},
2267 {
2268 "more_hidden": false,
2269 "enable_hidden": false,
2270 "disable_hidden": true,
2271 "revert_hidden": true,
2272 "delete_hidden": false
2273 }
2274 ],
2275
2276 [
2277 {"is_reserved":0,"is_forked":1},
2278 {
2279 "more_hidden": false,
2280 "enable_hidden": false,
2281 "disable_hidden": true,
2282 "revert_hidden": false,
2283 "delete_hidden": false
2284 }
2285 ],
2286
2287 [
2288 {"is_reserved":0,"is_forked":"0"},
2289 {
2290 "more_hidden": false,
2291 "enable_hidden": false,
2292 "disable_hidden": true,
2293 "revert_hidden": true,
2294 "delete_hidden": false
2295 }
2296 ],
2297
2298 [
2299 {"is_reserved":0,"is_forked":"1"},
2300 {
2301 "more_hidden": false,
2302 "enable_hidden": false,
2303 "disable_hidden": true,
2304 "revert_hidden": false,
2305 "delete_hidden": false
2306 }
2307 ],
2308
2309 [
2310 {"is_reserved":0},
2311 {
2312 "more_hidden": false,
2313 "enable_hidden": false,
2314 "disable_hidden": true,
2315 "revert_hidden": true,
2316 "delete_hidden": false
2317 }
2318 ],
2319
2320 [
2321 {"is_reserved":1,"is_forked":0},
2322 {
2323 "more_hidden": false,
2324 "enable_hidden": false,
2325 "disable_hidden": true,
2326 "revert_hidden": true,
2327 "delete_hidden": true
2328 }
2329 ],
2330
2331 [
2332 {"is_reserved":1,"is_forked":1},
2333 {
2334 "more_hidden": false,
2335 "enable_hidden": false,
2336 "disable_hidden": true,
2337 "revert_hidden": false,
2338 "delete_hidden": true
2339 }
2340 ],
2341
2342 [
2343 {"is_reserved":1,"is_forked":"0"},
2344 {
2345 "more_hidden": false,
2346 "enable_hidden": false,
2347 "disable_hidden": true,
2348 "revert_hidden": true,
2349 "delete_hidden": true
2350 }
2351 ],
2352
2353 [
2354 {"is_reserved":1,"is_forked":"1"},
2355 {
2356 "more_hidden": false,
2357 "enable_hidden": false,
2358 "disable_hidden": true,
2359 "revert_hidden": false,
2360 "delete_hidden": true
2361 }
2362 ],
2363
2364 [
2365 {"is_reserved":1},
2366 {
2367 "more_hidden": false,
2368 "enable_hidden": false,
2369 "disable_hidden": true,
2370 "revert_hidden": true,
2371 "delete_hidden": true
2372 }
2373 ],
2374
2375 [
2376 {"is_reserved":"0","is_forked":0},
2377 {
2378 "more_hidden": false,
2379 "enable_hidden": false,
2380 "disable_hidden": true,
2381 "revert_hidden": true,
2382 "delete_hidden": false
2383 }
2384 ],
2385
2386 [
2387 {"is_reserved":"0","is_forked":1},
2388 {
2389 "more_hidden": false,
2390 "enable_hidden": false,
2391 "disable_hidden": true,
2392 "revert_hidden": false,
2393 "delete_hidden": false
2394 }
2395 ],
2396
2397 [
2398 {"is_reserved":"0","is_forked":"0"},
2399 {
2400 "more_hidden": false,
2401 "enable_hidden": false,
2402 "disable_hidden": true,
2403 "revert_hidden": true,
2404 "delete_hidden": false
2405 }
2406 ],
2407
2408 [
2409 {"is_reserved":"0","is_forked":"1"},
2410 {
2411 "more_hidden": false,
2412 "enable_hidden": false,
2413 "disable_hidden": true,
2414 "revert_hidden": false,
2415 "delete_hidden": false
2416 }
2417 ],
2418
2419 [
2420 {"is_reserved":"0"},
2421 {
2422 "more_hidden": false,
2423 "enable_hidden": false,
2424 "disable_hidden": true,
2425 "revert_hidden": true,
2426 "delete_hidden": false
2427 }
2428 ],
2429
2430 [
2431 {"is_reserved":"1","is_forked":0},
2432 {
2433 "more_hidden": false,
2434 "enable_hidden": false,
2435 "disable_hidden": true,
2436 "revert_hidden": true,
2437 "delete_hidden": true
2438 }
2439 ],
2440
2441 [
2442 {"is_reserved":"1","is_forked":1},
2443 {
2444 "more_hidden": false,
2445 "enable_hidden": false,
2446 "disable_hidden": true,
2447 "revert_hidden": false,
2448 "delete_hidden": true
2449 }
2450 ],
2451
2452 [
2453 {"is_reserved":"1","is_forked":"0"},
2454 {
2455 "more_hidden": false,
2456 "enable_hidden": false,
2457 "disable_hidden": true,
2458 "revert_hidden": true,
2459 "delete_hidden": true
2460 }
2461 ],
2462
2463 [
2464 {"is_reserved":"1","is_forked":"1"},
2465 {
2466 "more_hidden": false,
2467 "enable_hidden": false,
2468 "disable_hidden": true,
2469 "revert_hidden": false,
2470 "delete_hidden": true
2471 }
2472 ],
2473
2474 [
2475 {"is_reserved":"1"},
2476 {
2477 "more_hidden": false,
2478 "enable_hidden": false,
2479 "disable_hidden": true,
2480 "revert_hidden": true,
2481 "delete_hidden": true
2482 }
2483 ],
2484
2485 [
2486 {"is_forked":0},
2487 {
2488 "more_hidden": false,
2489 "enable_hidden": false,
2490 "disable_hidden": true,
2491 "revert_hidden": true,
2492 "delete_hidden": false
2493 }
2494 ],
2495
2496 [
2497 {"is_forked":1},
2498 {
2499 "more_hidden": false,
2500 "enable_hidden": false,
2501 "disable_hidden": true,
2502 "revert_hidden": false,
2503 "delete_hidden": false
2504 }
2505 ],
2506
2507 [
2508 {"is_forked":"0"},
2509 {
2510 "more_hidden": false,
2511 "enable_hidden": false,
2512 "disable_hidden": true,
2513 "revert_hidden": true,
2514 "delete_hidden": false
2515 }
2516 ],
2517
2518 [
2519 {"is_forked":"1"},
2520 {
2521 "more_hidden": false,
2522 "enable_hidden": false,
2523 "disable_hidden": true,
2524 "revert_hidden": false,
2525 "delete_hidden": false
2526 }
2527 ],
2528
2529 [
2530 {},
2531 {
2532 "more_hidden": false,
2533 "enable_hidden": false,
2534 "disable_hidden": true,
2535 "revert_hidden": true,
2536 "delete_hidden": false
2537 }
2538 ],
2539 ];
2540 caseTypeSimulations.forEach(function(simulation) {
2541 doTest(simulation[0], simulation[1]);
2542 });
2543 });
2544 });
2545 });
2546
2547 });