4827.1.1
by Gavin Panella
Update copyright headers. |
1 |
/* Copyright 2015-2016 Canonical Ltd. This software is licensed under the
|
3660.6.4
by Blake Rouse
Add tests for node details controller. |
2 |
* GNU Affero General Public License version 3 (see the file LICENSE).
|
3 |
*
|
|
4 |
* Unit tests for NodeDetailsController.
|
|
5 |
*/
|
|
4662.1.8
by Mike Pontillo
Fix lint. |
6 |
|
3844.3.3
by ubuntudotcom1
Tests. |
7 |
// Make a fake user.
|
8 |
var userId = 0; |
|
9 |
function makeUser() { |
|
10 |
return { |
|
11 |
id: userId++, |
|
12 |
username: makeName("username"), |
|
13 |
first_name: makeName("first_name"), |
|
14 |
last_name: makeName("last_name"), |
|
15 |
email: makeName("email"), |
|
16 |
is_superuser: false, |
|
17 |
sshkeys_count: 0 |
|
18 |
};
|
|
19 |
}
|
|
20 |
||
21 |
||
3660.6.4
by Blake Rouse
Add tests for node details controller. |
22 |
describe("NodeDetailsController", function() { |
23 |
||
24 |
// Load the MAAS module.
|
|
25 |
beforeEach(module("MAAS")); |
|
26 |
||
27 |
// Grab the needed angular pieces.
|
|
28 |
var $controller, $rootScope, $location, $scope, $q; |
|
29 |
beforeEach(inject(function($injector) { |
|
30 |
$controller = $injector.get("$controller"); |
|
31 |
$rootScope = $injector.get("$rootScope"); |
|
32 |
$location = $injector.get("$location"); |
|
33 |
$scope = $rootScope.$new(); |
|
34 |
$q = $injector.get("$q"); |
|
35 |
}));
|
|
36 |
||
3660.17.3
by Blake Rouse
Fix code review. |
37 |
// Load the required dependencies for the NodeDetails controller and
|
38 |
// mock the websocket connection.
|
|
4804.6.4
by Jeffrey C Jones
Simplify ServiceHandler |
39 |
var MachinesManager, ControllersManager, ServicesManager; |
4750.5.1
by Lee Trager
Allow changing the machine domain in the UI |
40 |
var DevicesManager, GeneralManager, UsersManager, DomainsManager; |
4600.2.22
by Blake Rouse
Merge rack-integration. |
41 |
var TagsManager, RegionConnection, ManagerHelperService, ErrorService; |
42 |
var webSocket; |
|
3660.6.4
by Blake Rouse
Add tests for node details controller. |
43 |
beforeEach(inject(function($injector) { |
4600.2.21
by Blake Rouse
Fix api tests up to test_machine. |
44 |
MachinesManager = $injector.get("MachinesManager"); |
4671.2.2
by Jeffrey C Jones
fix tests |
45 |
ControllersManager = $injector.get("ControllersManager"); |
3660.6.4
by Blake Rouse
Add tests for node details controller. |
46 |
ZonesManager = $injector.get("ZonesManager"); |
47 |
GeneralManager = $injector.get("GeneralManager"); |
|
3660.17.1
by Blake Rouse
Only show edit mode if super user. Fix how the manager service replaces items in the array. Have better logging on a failed action. |
48 |
UsersManager = $injector.get("UsersManager"); |
3942.6.1
by Blake Rouse
Use the ngTagsInput on the node details page to allow a user to add or remove tags from a node. |
49 |
TagsManager = $injector.get("TagsManager"); |
4750.5.1
by Lee Trager
Allow changing the machine domain in the UI |
50 |
DomainsManager = $injector.get("DomainsManager"); |
3660.6.4
by Blake Rouse
Add tests for node details controller. |
51 |
RegionConnection = $injector.get("RegionConnection"); |
52 |
ManagerHelperService = $injector.get("ManagerHelperService"); |
|
4804.6.4
by Jeffrey C Jones
Simplify ServiceHandler |
53 |
ServicesManager = $injector.get("ServicesManager"); |
3660.6.4
by Blake Rouse
Add tests for node details controller. |
54 |
ErrorService = $injector.get("ErrorService"); |
55 |
||
56 |
// Mock buildSocket so an actual connection is not made.
|
|
57 |
webSocket = new MockWebSocket(); |
|
58 |
spyOn(RegionConnection, "buildSocket").and.returnValue(webSocket); |
|
59 |
}));
|
|
60 |
||
61 |
// Make a fake zone.
|
|
62 |
function makeZone() { |
|
63 |
var zone = { |
|
64 |
id: makeInteger(0, 10000), |
|
65 |
name: makeName("zone") |
|
66 |
};
|
|
67 |
ZonesManager._items.push(zone); |
|
68 |
return zone; |
|
69 |
}
|
|
70 |
||
71 |
// Make a fake node.
|
|
72 |
function makeNode() { |
|
73 |
var zone = makeZone(); |
|
74 |
var node = { |
|
75 |
system_id: makeName("system_id"), |
|
3721.1.5
by Blake Rouse
Add the ability to rename a node in the header. |
76 |
hostname: makeName("hostname"), |
3660.6.4
by Blake Rouse
Add tests for node details controller. |
77 |
fqdn: makeName("fqdn"), |
78 |
actions: [], |
|
79 |
architecture: "amd64/generic", |
|
80 |
zone: angular.copy(zone), |
|
81 |
power_type: "", |
|
3660.14.10
by Blake Rouse
Add tests for node_details controller. |
82 |
power_parameters: null, |
83 |
summary_xml: null, |
|
84 |
summary_yaml: null, |
|
85 |
commissioning_results: [], |
|
5755.3.1
by Lee Trager
Add test result section to the UI. |
86 |
testing_results: [], |
3660.14.10
by Blake Rouse
Add tests for node_details controller. |
87 |
installation_results: [], |
3786.2.70
by Ricardo Banffy
Add interfaces and extra_macs to makeNode, add skeleton - not sure how to get a hold of the things $scope.saveAddInterface changes |
88 |
events: [], |
89 |
interfaces: [], |
|
90 |
extra_macs: [] |
|
3660.6.4
by Blake Rouse
Add tests for node details controller. |
91 |
};
|
4600.2.21
by Blake Rouse
Fix api tests up to test_machine. |
92 |
MachinesManager._items.push(node); |
3660.6.4
by Blake Rouse
Add tests for node details controller. |
93 |
return node; |
94 |
}
|
|
95 |
||
3660.14.10
by Blake Rouse
Add tests for node_details controller. |
96 |
// Make a fake event.
|
97 |
function makeEvent() { |
|
98 |
return { |
|
99 |
type: { |
|
100 |
description: makeName("type") |
|
101 |
},
|
|
102 |
description: makeName("description") |
|
103 |
};
|
|
104 |
}
|
|
105 |
||
3660.6.4
by Blake Rouse
Add tests for node details controller. |
106 |
// Create the node that will be used and set the routeParams.
|
107 |
var node, $routeParams; |
|
108 |
beforeEach(function() { |
|
109 |
node = makeNode(); |
|
110 |
$routeParams = { |
|
111 |
system_id: node.system_id |
|
112 |
};
|
|
113 |
});
|
|
114 |
||
115 |
// Makes the NodeDetailsController
|
|
116 |
function makeController(loadManagersDefer) { |
|
117 |
var loadManagers = spyOn(ManagerHelperService, "loadManagers"); |
|
118 |
if(angular.isObject(loadManagersDefer)) { |
|
119 |
loadManagers.and.returnValue(loadManagersDefer.promise); |
|
120 |
} else { |
|
121 |
loadManagers.and.returnValue($q.defer().promise); |
|
122 |
}
|
|
123 |
||
124 |
// Start the connection so a valid websocket is created in the
|
|
125 |
// RegionConnection.
|
|
126 |
RegionConnection.connect(""); |
|
127 |
||
3660.17.1
by Blake Rouse
Only show edit mode if super user. Fix how the manager service replaces items in the array. Have better logging on a failed action. |
128 |
// Set the authenticated user, and by default make them superuser.
|
129 |
UsersManager._authUser = { |
|
130 |
is_superuser: true |
|
131 |
};
|
|
132 |
||
3897.1.1
by Blake Rouse
Add to the osSelection model, allowing a controller to reset a directives defaults. |
133 |
// Create the controller.
|
134 |
var controller = $controller("NodeDetailsController", { |
|
3660.6.4
by Blake Rouse
Add tests for node details controller. |
135 |
$scope: $scope, |
136 |
$rootScope: $rootScope, |
|
137 |
$routeParams: $routeParams, |
|
138 |
$location: $location, |
|
4600.2.21
by Blake Rouse
Fix api tests up to test_machine. |
139 |
MachinesManager: MachinesManager, |
4671.2.2
by Jeffrey C Jones
fix tests |
140 |
ControllersManager: ControllersManager, |
3660.6.4
by Blake Rouse
Add tests for node details controller. |
141 |
ZonesManager: ZonesManager, |
142 |
GeneralManager: GeneralManager, |
|
3660.17.1
by Blake Rouse
Only show edit mode if super user. Fix how the manager service replaces items in the array. Have better logging on a failed action. |
143 |
UsersManager: UsersManager, |
3942.6.1
by Blake Rouse
Use the ngTagsInput on the node details page to allow a user to add or remove tags from a node. |
144 |
TagsManager: TagsManager, |
4750.5.1
by Lee Trager
Allow changing the machine domain in the UI |
145 |
DomainsManager: DomainsManager, |
3660.6.4
by Blake Rouse
Add tests for node details controller. |
146 |
ManagerHelperService: ManagerHelperService, |
4804.6.4
by Jeffrey C Jones
Simplify ServiceHandler |
147 |
ServicesManager: ServicesManager, |
3660.6.4
by Blake Rouse
Add tests for node details controller. |
148 |
ErrorService: ErrorService |
149 |
});
|
|
3897.1.1
by Blake Rouse
Add to the osSelection model, allowing a controller to reset a directives defaults. |
150 |
|
4671.2.2
by Jeffrey C Jones
fix tests |
151 |
$scope.nodesManager = MachinesManager; |
152 |
||
3897.1.1
by Blake Rouse
Add to the osSelection model, allowing a controller to reset a directives defaults. |
153 |
// Since the osSelection directive is not used in this test the
|
154 |
// osSelection item on the model needs to have $reset function added
|
|
155 |
// because it will be called throughout many of the tests.
|
|
156 |
$scope.osSelection.$reset = jasmine.createSpy("$reset"); |
|
157 |
||
158 |
return controller; |
|
3660.6.4
by Blake Rouse
Add tests for node details controller. |
159 |
}
|
160 |
||
3660.8.3
by Blake Rouse
Add more tests. |
161 |
// Make the controller and resolve the setActiveItem call.
|
162 |
function makeControllerResolveSetActiveItem() { |
|
163 |
var setActiveDefer = $q.defer(); |
|
4600.2.21
by Blake Rouse
Fix api tests up to test_machine. |
164 |
spyOn(MachinesManager, "setActiveItem").and.returnValue( |
3660.8.3
by Blake Rouse
Add more tests. |
165 |
setActiveDefer.promise); |
166 |
var defer = $q.defer(); |
|
167 |
var controller = makeController(defer); |
|
168 |
||
169 |
defer.resolve(); |
|
170 |
$rootScope.$digest(); |
|
171 |
setActiveDefer.resolve(node); |
|
172 |
$rootScope.$digest(); |
|
173 |
||
174 |
return controller; |
|
175 |
}
|
|
176 |
||
3660.6.4
by Blake Rouse
Add tests for node details controller. |
177 |
it("sets title to loading and page to nodes", function() { |
178 |
var controller = makeController(); |
|
179 |
expect($rootScope.title).toBe("Loading..."); |
|
180 |
expect($rootScope.page).toBe("nodes"); |
|
181 |
});
|
|
182 |
||
183 |
it("sets the initial $scope values", function() { |
|
184 |
var controller = makeController(); |
|
185 |
expect($scope.loaded).toBe(false); |
|
186 |
expect($scope.node).toBeNull(); |
|
187 |
expect($scope.actionOption).toBeNull(); |
|
5037.2.9
by Jeffrey C Jones
Fix actions not loading for regular Machines. |
188 |
expect($scope.allActionOptions).toBeNull(); |
3660.6.4
by Blake Rouse
Add tests for node details controller. |
189 |
expect($scope.availableActionOptions).toEqual([]); |
3660.17.2
by Blake Rouse
Fix and add tests. |
190 |
expect($scope.actionError).toBeNull(); |
3660.6.4
by Blake Rouse
Add tests for node details controller. |
191 |
expect($scope.osinfo).toBe(GeneralManager.getData("osinfo")); |
4600.1.31
by Blake Rouse
Fix getting power types in the websocket. |
192 |
expect($scope.power_types).toBe(GeneralManager.getData("power_types")); |
3897.1.1
by Blake Rouse
Add to the osSelection model, allowing a controller to reset a directives defaults. |
193 |
expect($scope.osSelection.osystem).toBeNull(); |
194 |
expect($scope.osSelection.release).toBeNull(); |
|
4286.7.1
by Blake Rouse
Add commissioning options to the WebUI. |
195 |
expect($scope.commissionOptions).toEqual({ |
196 |
enableSSH: false, |
|
197 |
skipNetworking: false, |
|
198 |
skipStorage: false |
|
199 |
});
|
|
5158.3.2
by Blake Rouse
Add release options for the WebUI for erasing, using secure erase and quick erase. Disable options based on global selections and select defaults based on global options. |
200 |
expect($scope.releaseOptions).toEqual({}); |
4465.1.1
by Blake Rouse
Add the children devices on the node details page. |
201 |
expect($scope.checkingPower).toBe(false); |
202 |
expect($scope.devices).toEqual([]); |
|
4804.6.6
by Jeffrey C Jones
linted and added test for updateServices() |
203 |
expect($scope.services).toEqual({}); |
3660.6.4
by Blake Rouse
Add tests for node details controller. |
204 |
});
|
205 |
||
206 |
it("sets initial values for summary section", function() { |
|
207 |
var controller = makeController(); |
|
208 |
expect($scope.summary).toEqual({ |
|
209 |
editing: false, |
|
210 |
architecture: { |
|
211 |
selected: null, |
|
212 |
options: GeneralManager.getData("architectures") |
|
213 |
},
|
|
4141.2.3
by Lee Trager
Fix all existing tests |
214 |
min_hwe_kernel: { |
215 |
selected: null, |
|
5268.2.4
by Lee Trager
Fix broken tests |
216 |
options: GeneralManager.getData("min_hwe_kernels") |
4141.2.3
by Lee Trager
Fix all existing tests |
217 |
},
|
3660.6.4
by Blake Rouse
Add tests for node details controller. |
218 |
zone: { |
219 |
selected: null, |
|
220 |
options: ZonesManager.getItems() |
|
3942.6.1
by Blake Rouse
Use the ngTagsInput on the node details page to allow a user to add or remove tags from a node. |
221 |
},
|
222 |
tags: [] |
|
3660.6.4
by Blake Rouse
Add tests for node details controller. |
223 |
});
|
224 |
expect($scope.summary.architecture.options).toBe( |
|
225 |
GeneralManager.getData("architectures")); |
|
4141.2.6
by Lee Trager
Modify list_all_usable_architectures to return only architectures |
226 |
expect($scope.summary.min_hwe_kernel.options).toBe( |
5268.2.4
by Lee Trager
Fix broken tests |
227 |
GeneralManager.getData("min_hwe_kernels")); |
3660.6.4
by Blake Rouse
Add tests for node details controller. |
228 |
expect($scope.summary.zone.options).toBe( |
229 |
ZonesManager.getItems()); |
|
230 |
});
|
|
231 |
||
232 |
it("sets initial values for power section", function() { |
|
233 |
var controller = makeController(); |
|
234 |
expect($scope.power).toEqual({ |
|
235 |
editing: false, |
|
236 |
type: null, |
|
4609.1.3
by Jeffrey C Jones
extract IP in BMC clean instead of Node |
237 |
bmc_node_count: 0, |
3660.6.4
by Blake Rouse
Add tests for node details controller. |
238 |
parameters: {} |
239 |
});
|
|
240 |
});
|
|
241 |
||
3660.14.10
by Blake Rouse
Add tests for node_details controller. |
242 |
it("sets initial values for events section", function() { |
243 |
var controller = makeController(); |
|
244 |
expect($scope.events).toEqual({ |
|
245 |
limit: 10 |
|
246 |
});
|
|
247 |
});
|
|
248 |
||
249 |
it("sets initial values for machine output section", function() { |
|
250 |
var controller = makeController(); |
|
251 |
expect($scope.machine_output).toEqual({ |
|
252 |
viewable: false, |
|
253 |
selectedView: null, |
|
254 |
views: [], |
|
255 |
showSummaryToggle: true, |
|
256 |
summaryType: 'yaml' |
|
257 |
});
|
|
258 |
});
|
|
259 |
||
3660.6.4
by Blake Rouse
Add tests for node details controller. |
260 |
it("calls loadManagers with all needed managers", function() { |
261 |
var controller = makeController(); |
|
5375.4.3
by Blake Rouse
Add PollingManager and base DiscoveriesManager off that manager. |
262 |
expect(ManagerHelperService.loadManagers).toHaveBeenCalledWith( |
263 |
$scope, [ |
|
264 |
MachinesManager, ControllersManager, ZonesManager, |
|
265 |
GeneralManager, UsersManager, TagsManager, DomainsManager, |
|
266 |
ServicesManager]); |
|
3660.6.4
by Blake Rouse
Add tests for node details controller. |
267 |
});
|
268 |
||
3721.2.1
by Blake Rouse
Add NodeResultController, to show output from a commissioning script. |
269 |
it("doesnt call setActiveItem if node is loaded", function() { |
4600.2.21
by Blake Rouse
Fix api tests up to test_machine. |
270 |
spyOn(MachinesManager, "setActiveItem").and.returnValue( |
3721.2.1
by Blake Rouse
Add NodeResultController, to show output from a commissioning script. |
271 |
$q.defer().promise); |
272 |
var defer = $q.defer(); |
|
273 |
var controller = makeController(defer); |
|
4600.2.21
by Blake Rouse
Fix api tests up to test_machine. |
274 |
MachinesManager._activeItem = node; |
3721.2.1
by Blake Rouse
Add NodeResultController, to show output from a commissioning script. |
275 |
|
276 |
defer.resolve(); |
|
277 |
$rootScope.$digest(); |
|
278 |
||
279 |
expect($scope.node).toBe(node); |
|
280 |
expect($scope.loaded).toBe(true); |
|
4600.2.21
by Blake Rouse
Fix api tests up to test_machine. |
281 |
expect(MachinesManager.setActiveItem).not.toHaveBeenCalled(); |
3721.2.1
by Blake Rouse
Add NodeResultController, to show output from a commissioning script. |
282 |
});
|
283 |
||
284 |
it("calls setActiveItem if node is not active", function() { |
|
4600.2.21
by Blake Rouse
Fix api tests up to test_machine. |
285 |
spyOn(MachinesManager, "setActiveItem").and.returnValue( |
3660.6.4
by Blake Rouse
Add tests for node details controller. |
286 |
$q.defer().promise); |
287 |
var defer = $q.defer(); |
|
288 |
var controller = makeController(defer); |
|
289 |
||
290 |
defer.resolve(); |
|
291 |
$rootScope.$digest(); |
|
292 |
||
4600.2.21
by Blake Rouse
Fix api tests up to test_machine. |
293 |
expect(MachinesManager.setActiveItem).toHaveBeenCalledWith( |
3660.6.4
by Blake Rouse
Add tests for node details controller. |
294 |
node.system_id); |
295 |
});
|
|
296 |
||
297 |
it("sets node and loaded once setActiveItem resolves", function() { |
|
3660.8.3
by Blake Rouse
Add more tests. |
298 |
var controller = makeControllerResolveSetActiveItem(); |
3660.6.4
by Blake Rouse
Add tests for node details controller. |
299 |
expect($scope.node).toBe(node); |
300 |
expect($scope.loaded).toBe(true); |
|
301 |
});
|
|
302 |
||
5521.5.1
by Lee Trager
Show controller events and refresh results in UI |
303 |
it("sets machine values on load", function () { |
304 |
spyOn(MachinesManager, "setActiveItem").and.returnValue( |
|
305 |
$q.defer().promise); |
|
306 |
var defer = $q.defer(); |
|
307 |
var controller = makeController(defer); |
|
308 |
||
309 |
defer.resolve(); |
|
310 |
$rootScope.$digest(); |
|
311 |
||
312 |
expect($scope.nodesManager).toBe(MachinesManager); |
|
313 |
expect($scope.isController).toBe(false); |
|
314 |
expect($scope.type_name).toBe('machine'); |
|
5521.5.2
by Lee Trager
blake_r corrections |
315 |
expect($scope.type_name_title).toBe('Machine'); |
5521.5.1
by Lee Trager
Show controller events and refresh results in UI |
316 |
});
|
317 |
||
318 |
it("sets controller values on load", function () { |
|
319 |
$routeParams.type = 'controller'; |
|
320 |
spyOn(MachinesManager, "setActiveItem").and.returnValue( |
|
321 |
$q.defer().promise); |
|
322 |
spyOn(ControllersManager, "setActiveItem").and.returnValue( |
|
323 |
$q.defer().promise); |
|
324 |
var defer = $q.defer(); |
|
325 |
var controller = makeController(defer); |
|
326 |
||
327 |
defer.resolve(); |
|
328 |
$rootScope.$digest(); |
|
329 |
||
330 |
expect($scope.nodesManager).toBe(ControllersManager); |
|
331 |
expect($scope.isController).toBe(true); |
|
332 |
expect($scope.type_name).toBe('controller'); |
|
5521.5.2
by Lee Trager
blake_r corrections |
333 |
expect($scope.type_name_title).toBe('Controller'); |
5521.5.1
by Lee Trager
Show controller events and refresh results in UI |
334 |
});
|
335 |
||
4804.6.6
by Jeffrey C Jones
linted and added test for updateServices() |
336 |
it("updateServices sets $scope.services when node is loaded", function() { |
337 |
spyOn(ControllersManager, "getServices").and.returnValue([ |
|
338 |
{ "status": "unknown", "name": "tgt" }, |
|
339 |
{ "status": "running", "name": "rackd" } |
|
340 |
]);
|
|
341 |
spyOn(ControllersManager, "setActiveItem").and.returnValue( |
|
342 |
$q.defer().promise); |
|
343 |
||
344 |
var defer = $q.defer(); |
|
345 |
$routeParams.type = 'controller'; |
|
346 |
var controller = makeController(defer); |
|
347 |
ControllersManager._activeItem = node; |
|
348 |
||
349 |
defer.resolve(); |
|
350 |
$rootScope.$digest(); |
|
351 |
||
352 |
expect($scope.node).toBe(node); |
|
4804.6.2
by Jeffrey C Jones
Add ServicesManagerFactory to node_details.js. |
353 |
expect($scope.loaded).toBe(true); |
4804.6.6
by Jeffrey C Jones
linted and added test for updateServices() |
354 |
|
355 |
expect(ControllersManager.getServices).toHaveBeenCalledWith(node); |
|
5037.2.8
by Jeffrey C Jones
review fixes |
356 |
expect($scope.services).not.toBeNull(); |
4804.6.6
by Jeffrey C Jones
linted and added test for updateServices() |
357 |
expect(Object.keys($scope.services).length).toBe(2); |
4804.7.2
by Jeffrey C Jones
Fix missing </li> and newly broken test. |
358 |
expect($scope.services.tgt.status).toBe('unknown'); |
359 |
expect($scope.services.rackd.status).toBe('running'); |
|
4804.6.2
by Jeffrey C Jones
Add ServicesManagerFactory to node_details.js. |
360 |
});
|
361 |
||
5037.2.8
by Jeffrey C Jones
review fixes |
362 |
it("getAllActionOptions called when node is loaded", function() { |
363 |
spyOn(ControllersManager, "setActiveItem").and.returnValue( |
|
364 |
$q.defer().promise); |
|
365 |
var defer = $q.defer(); |
|
366 |
$routeParams.type = 'controller'; |
|
367 |
var controller = makeController(defer); |
|
368 |
var getAllActionOptions = spyOn($scope, "getAllActionOptions"); |
|
369 |
var myNode = angular.copy(node); |
|
370 |
// Make node a rack controller.
|
|
371 |
myNode.node_type = 2; |
|
372 |
ControllersManager._activeItem = myNode; |
|
373 |
defer.resolve(); |
|
374 |
$rootScope.$digest(); |
|
375 |
expect(getAllActionOptions).toHaveBeenCalledWith(2); |
|
376 |
});
|
|
377 |
||
3660.6.4
by Blake Rouse
Add tests for node details controller. |
378 |
it("title is updated once setActiveItem resolves", function() { |
3660.8.3
by Blake Rouse
Add more tests. |
379 |
var controller = makeControllerResolveSetActiveItem(); |
3660.6.4
by Blake Rouse
Add tests for node details controller. |
380 |
expect($rootScope.title).toBe(node.fqdn); |
381 |
});
|
|
382 |
||
3660.8.3
by Blake Rouse
Add more tests. |
383 |
it("summary section placed in edit mode if architecture blank", |
384 |
function() { |
|
385 |
node.architecture = ""; |
|
4892.1.1
by Blake Rouse
Fix handling no connected rack controllers on the machine details page. Cleanup error messages on the machine details page. Fix power_type options from being reset mid type. |
386 |
GeneralManager._data.power_types.data = [{}]; |
387 |
GeneralManager._data.architectures.data = ["amd64/generic"]; |
|
3660.8.3
by Blake Rouse
Add more tests. |
388 |
|
389 |
var controller = makeControllerResolveSetActiveItem(); |
|
390 |
expect($scope.summary.editing).toBe(true); |
|
391 |
});
|
|
392 |
||
4892.1.1
by Blake Rouse
Fix handling no connected rack controllers on the machine details page. Cleanup error messages on the machine details page. Fix power_type options from being reset mid type. |
393 |
it("summary section not placed in edit mode if no usable architectures", |
394 |
function() { |
|
395 |
node.architecture = ""; |
|
396 |
GeneralManager._data.power_types.data = [{}]; |
|
397 |
||
398 |
var controller = makeControllerResolveSetActiveItem(); |
|
399 |
expect($scope.summary.editing).toBe(false); |
|
400 |
});
|
|
401 |
||
3660.8.3
by Blake Rouse
Add more tests. |
402 |
it("summary section not placed in edit mode if architecture present", |
403 |
function() { |
|
404 |
GeneralManager._data.architectures.data = [node.architecture]; |
|
405 |
||
406 |
var controller = makeControllerResolveSetActiveItem(); |
|
407 |
expect($scope.summary.editing).toBe(false); |
|
408 |
});
|
|
409 |
||
3660.6.4
by Blake Rouse
Add tests for node details controller. |
410 |
it("summary section is updated once setActiveItem resolves", function() { |
3660.8.3
by Blake Rouse
Add more tests. |
411 |
var controller = makeControllerResolveSetActiveItem(); |
3660.6.4
by Blake Rouse
Add tests for node details controller. |
412 |
expect($scope.summary.zone.selected).toBe( |
413 |
ZonesManager.getItemFromList(node.zone.id)); |
|
414 |
expect($scope.summary.architecture.selected).toBe(node.architecture); |
|
3942.6.1
by Blake Rouse
Use the ngTagsInput on the node details page to allow a user to add or remove tags from a node. |
415 |
expect($scope.summary.tags).toEqual(node.tags); |
3660.6.4
by Blake Rouse
Add tests for node details controller. |
416 |
});
|
417 |
||
3660.8.3
by Blake Rouse
Add more tests. |
418 |
it("power section placed in edit mode if power_type blank", function() { |
4892.1.1
by Blake Rouse
Fix handling no connected rack controllers on the machine details page. Cleanup error messages on the machine details page. Fix power_type options from being reset mid type. |
419 |
GeneralManager._data.power_types.data = [{}]; |
420 |
||
3660.8.3
by Blake Rouse
Add more tests. |
421 |
var controller = makeControllerResolveSetActiveItem(); |
422 |
expect($scope.power.editing).toBe(true); |
|
423 |
});
|
|
424 |
||
4892.1.1
by Blake Rouse
Fix handling no connected rack controllers on the machine details page. Cleanup error messages on the machine details page. Fix power_type options from being reset mid type. |
425 |
it("power section not placed in edit mode if no power_types", function() { |
426 |
var controller = makeControllerResolveSetActiveItem(); |
|
427 |
expect($scope.power.editing).toBe(false); |
|
428 |
});
|
|
429 |
||
3660.8.3
by Blake Rouse
Add more tests. |
430 |
it("power section not placed in edit mode if power_type", function() { |
431 |
node.power_type = makeName("power"); |
|
4892.1.1
by Blake Rouse
Fix handling no connected rack controllers on the machine details page. Cleanup error messages on the machine details page. Fix power_type options from being reset mid type. |
432 |
GeneralManager._data.power_types.data = [{}]; |
3660.8.3
by Blake Rouse
Add more tests. |
433 |
|
434 |
var controller = makeControllerResolveSetActiveItem(); |
|
435 |
expect($scope.power.editing).toBe(false); |
|
436 |
});
|
|
437 |
||
3660.14.10
by Blake Rouse
Add tests for node_details controller. |
438 |
it("machine output not visible if all required data missing", function() { |
439 |
var controller = makeControllerResolveSetActiveItem(); |
|
440 |
expect($scope.machine_output.viewable).toBe(false); |
|
441 |
});
|
|
442 |
||
443 |
it("machine output visible if summary_xml and summary_yaml", function() { |
|
444 |
node.summary_xml = node.summary_yaml = "summary"; |
|
445 |
var controller = makeControllerResolveSetActiveItem(); |
|
446 |
expect($scope.machine_output.viewable).toBe(true); |
|
447 |
});
|
|
448 |
||
449 |
it("machine output visible if commissioning_results", function() { |
|
450 |
node.commissioning_results.push({}); |
|
451 |
var controller = makeControllerResolveSetActiveItem(); |
|
452 |
expect($scope.machine_output.viewable).toBe(true); |
|
453 |
});
|
|
454 |
||
3989.2.3
by Blake Rouse
Add tests. |
455 |
it("machine output not visible if commissioning_results not an array", |
456 |
function() { |
|
457 |
node.commissioning_results = undefined; |
|
458 |
var controller = makeControllerResolveSetActiveItem(); |
|
459 |
expect($scope.machine_output.viewable).toBe(false); |
|
460 |
});
|
|
461 |
||
3660.14.10
by Blake Rouse
Add tests for node_details controller. |
462 |
it("machine output visible if installation_results", function() { |
463 |
node.installation_results.push({}); |
|
464 |
var controller = makeControllerResolveSetActiveItem(); |
|
465 |
expect($scope.machine_output.viewable).toBe(true); |
|
466 |
});
|
|
467 |
||
3989.2.3
by Blake Rouse
Add tests. |
468 |
it("machine output not visible if installation_results not an array", |
469 |
function() { |
|
470 |
node.installation_results = undefined; |
|
471 |
var controller = makeControllerResolveSetActiveItem(); |
|
472 |
expect($scope.machine_output.viewable).toBe(false); |
|
473 |
});
|
|
474 |
||
3660.14.10
by Blake Rouse
Add tests for node_details controller. |
475 |
it("machine output summary view available if summary_xml and summary_yaml", |
476 |
function() { |
|
477 |
node.summary_xml = node.summary_yaml = "summary"; |
|
478 |
var controller = makeControllerResolveSetActiveItem(); |
|
479 |
expect($scope.machine_output.views).toEqual([{ |
|
480 |
name: "summary", |
|
481 |
title: "Commissioning Summary" |
|
482 |
}]);
|
|
483 |
});
|
|
484 |
||
5755.3.1
by Lee Trager
Add test result section to the UI. |
485 |
it("machine output commissioning view available if commissioning_results", |
3660.14.10
by Blake Rouse
Add tests for node_details controller. |
486 |
function() { |
487 |
node.commissioning_results.push({}); |
|
488 |
var controller = makeControllerResolveSetActiveItem(); |
|
489 |
expect($scope.machine_output.views).toEqual([{ |
|
5755.3.1
by Lee Trager
Add test result section to the UI. |
490 |
name: "commissioning", |
491 |
title: "Commissioning Results" |
|
492 |
}]);
|
|
493 |
});
|
|
494 |
||
495 |
it("machine output installation view available if installation_results", |
|
3660.14.10
by Blake Rouse
Add tests for node_details controller. |
496 |
function() { |
497 |
node.installation_results.push({}); |
|
498 |
var controller = makeControllerResolveSetActiveItem(); |
|
499 |
expect($scope.machine_output.views).toEqual([{ |
|
5755.3.1
by Lee Trager
Add test result section to the UI. |
500 |
name: "installation", |
3660.14.10
by Blake Rouse
Add tests for node_details controller. |
501 |
title: "Installation Output" |
502 |
}]);
|
|
503 |
});
|
|
504 |
||
505 |
it("machine output first available view is set as selectedView", |
|
506 |
function() { |
|
507 |
node.commissioning_results.push({}); |
|
508 |
var controller = makeControllerResolveSetActiveItem(); |
|
509 |
expect($scope.machine_output.selectedView).toEqual({ |
|
5755.3.1
by Lee Trager
Add test result section to the UI. |
510 |
name: "commissioning", |
511 |
title: "Commissioning Results" |
|
3660.14.10
by Blake Rouse
Add tests for node_details controller. |
512 |
});
|
513 |
});
|
|
514 |
||
515 |
it("machine output previous selected view is still selected", |
|
516 |
function() { |
|
517 |
node.commissioning_results.push({}); |
|
518 |
var controller = makeControllerResolveSetActiveItem(); |
|
519 |
||
520 |
// Add summary output and make updateMachineOutput be called
|
|
521 |
// again, but forcing a digest cycle.
|
|
522 |
node.summary_xml = node.summary_yaml = "summary"; |
|
523 |
$rootScope.$digest(); |
|
524 |
||
525 |
// Output view should still be selected as it was initially
|
|
526 |
// selected.
|
|
527 |
expect($scope.machine_output.selectedView).toEqual({ |
|
5755.3.1
by Lee Trager
Add test result section to the UI. |
528 |
name: "commissioning", |
529 |
title: "Commissioning Results" |
|
3660.14.10
by Blake Rouse
Add tests for node_details controller. |
530 |
});
|
531 |
});
|
|
532 |
||
533 |
it("machine output install view is always selected first if possible", |
|
534 |
function() { |
|
535 |
node.commissioning_results.push({}); |
|
5755.3.1
by Lee Trager
Add test result section to the UI. |
536 |
node.testing_results.push({}); |
3660.14.10
by Blake Rouse
Add tests for node_details controller. |
537 |
node.installation_results.push({}); |
538 |
var controller = makeControllerResolveSetActiveItem(); |
|
539 |
expect($scope.machine_output.selectedView).toEqual({ |
|
5755.3.1
by Lee Trager
Add test result section to the UI. |
540 |
name: "installation", |
3660.14.10
by Blake Rouse
Add tests for node_details controller. |
541 |
title: "Installation Output" |
542 |
});
|
|
543 |
});
|
|
544 |
||
545 |
it("machine output summary toggle is viewable when summary view selected", |
|
546 |
function() { |
|
547 |
node.summary_xml = node.summary_yaml = "summary"; |
|
548 |
var controller = makeControllerResolveSetActiveItem(); |
|
549 |
expect($scope.machine_output.showSummaryToggle).toBe(true); |
|
550 |
});
|
|
551 |
||
552 |
it("machine output summary toggle is not viewable when not summary view", |
|
553 |
function() { |
|
554 |
node.commissioning_results.push({}); |
|
555 |
var controller = makeControllerResolveSetActiveItem(); |
|
556 |
expect($scope.machine_output.showSummaryToggle).toBe(false); |
|
557 |
});
|
|
558 |
||
3660.6.4
by Blake Rouse
Add tests for node details controller. |
559 |
it("starts watching once setActiveItem resolves", function() { |
560 |
var setActiveDefer = $q.defer(); |
|
4600.2.21
by Blake Rouse
Fix api tests up to test_machine. |
561 |
spyOn(MachinesManager, "setActiveItem").and.returnValue( |
3660.6.4
by Blake Rouse
Add tests for node details controller. |
562 |
setActiveDefer.promise); |
563 |
var defer = $q.defer(); |
|
564 |
var controller = makeController(defer); |
|
565 |
||
566 |
spyOn($scope, "$watch"); |
|
567 |
spyOn($scope, "$watchCollection"); |
|
568 |
||
569 |
defer.resolve(); |
|
570 |
$rootScope.$digest(); |
|
571 |
setActiveDefer.resolve(node); |
|
572 |
$rootScope.$digest(); |
|
573 |
||
574 |
var watches = []; |
|
575 |
var i, calls = $scope.$watch.calls.allArgs(); |
|
576 |
for(i = 0; i < calls.length; i++) { |
|
577 |
watches.push(calls[i][0]); |
|
578 |
}
|
|
579 |
||
580 |
var watchCollections = []; |
|
581 |
calls = $scope.$watchCollection.calls.allArgs(); |
|
582 |
for(i = 0; i < calls.length; i++) { |
|
583 |
watchCollections.push(calls[i][0]); |
|
584 |
}
|
|
585 |
||
586 |
expect(watches).toEqual([ |
|
587 |
"node.fqdn", |
|
4465.1.1
by Blake Rouse
Add the children devices on the node details page. |
588 |
"node.devices", |
3660.6.4
by Blake Rouse
Add tests for node details controller. |
589 |
"node.actions", |
590 |
"node.architecture", |
|
4141.2.3
by Lee Trager
Fix all existing tests |
591 |
"node.min_hwe_kernel", |
3660.6.4
by Blake Rouse
Add tests for node details controller. |
592 |
"node.zone.id", |
593 |
"node.power_type", |
|
3660.14.10
by Blake Rouse
Add tests for node_details controller. |
594 |
"node.power_parameters", |
4804.7.2
by Jeffrey C Jones
Fix missing </li> and newly broken test. |
595 |
"node.service_ids", |
3660.14.10
by Blake Rouse
Add tests for node_details controller. |
596 |
"node.summary_xml", |
597 |
"node.summary_yaml", |
|
598 |
"node.commissioning_results", |
|
599 |
"node.installation_results"
|
|
3660.6.4
by Blake Rouse
Add tests for node details controller. |
600 |
]);
|
601 |
expect(watchCollections).toEqual([ |
|
602 |
$scope.summary.architecture.options, |
|
4141.2.3
by Lee Trager
Fix all existing tests |
603 |
$scope.summary.min_hwe_kernel.options, |
4892.1.1
by Blake Rouse
Fix handling no connected rack controllers on the machine details page. Cleanup error messages on the machine details page. Fix power_type options from being reset mid type. |
604 |
$scope.summary.zone.options, |
605 |
"power_types"
|
|
3660.6.4
by Blake Rouse
Add tests for node details controller. |
606 |
]);
|
607 |
});
|
|
608 |
||
4804.6.4
by Jeffrey C Jones
Simplify ServiceHandler |
609 |
it("calls startPolling once managers loaded", function() { |
4600.2.21
by Blake Rouse
Fix api tests up to test_machine. |
610 |
spyOn(MachinesManager, "setActiveItem").and.returnValue( |
3660.6.4
by Blake Rouse
Add tests for node details controller. |
611 |
$q.defer().promise); |
612 |
spyOn(GeneralManager, "startPolling"); |
|
613 |
var defer = $q.defer(); |
|
614 |
var controller = makeController(defer); |
|
615 |
||
616 |
defer.resolve(); |
|
617 |
$rootScope.$digest(); |
|
618 |
||
3660.6.5
by Blake Rouse
Fix up the tests. |
619 |
expect(GeneralManager.startPolling.calls.allArgs()).toEqual( |
4600.1.31
by Blake Rouse
Fix getting power types in the websocket. |
620 |
[["architectures"], ["hwe_kernels"], ["osinfo"], ["power_types"]]); |
3660.6.4
by Blake Rouse
Add tests for node details controller. |
621 |
});
|
622 |
||
623 |
it("calls stopPolling when the $scope is destroyed", function() { |
|
624 |
spyOn(GeneralManager, "stopPolling"); |
|
625 |
var controller = makeController(); |
|
626 |
$scope.$destroy(); |
|
627 |
expect(GeneralManager.stopPolling.calls.allArgs()).toEqual( |
|
4600.1.31
by Blake Rouse
Fix getting power types in the websocket. |
628 |
[["architectures"], ["hwe_kernels"], ["osinfo"], ["power_types"]]); |
3660.6.4
by Blake Rouse
Add tests for node details controller. |
629 |
});
|
630 |
||
4465.1.1
by Blake Rouse
Add the children devices on the node details page. |
631 |
it("updates $scope.devices", function() { |
632 |
var setActiveDefer = $q.defer(); |
|
4600.2.21
by Blake Rouse
Fix api tests up to test_machine. |
633 |
spyOn(MachinesManager, "setActiveItem").and.returnValue( |
4465.1.1
by Blake Rouse
Add the children devices on the node details page. |
634 |
setActiveDefer.promise); |
635 |
var defer = $q.defer(); |
|
636 |
var controller = makeController(defer); |
|
637 |
||
638 |
node.devices = [ |
|
639 |
{
|
|
640 |
fqdn: "device1.maas", |
|
641 |
interfaces: [] |
|
642 |
},
|
|
643 |
{
|
|
644 |
fqdn: "device2.maas", |
|
645 |
interfaces: [ |
|
646 |
{
|
|
647 |
mac_address: "00:11:22:33:44:55", |
|
648 |
links: [] |
|
649 |
}
|
|
650 |
]
|
|
651 |
},
|
|
652 |
{
|
|
653 |
fqdn: "device3.maas", |
|
654 |
interfaces: [ |
|
655 |
{
|
|
656 |
mac_address: "00:11:22:33:44:66", |
|
657 |
links: [] |
|
658 |
},
|
|
659 |
{
|
|
660 |
mac_address: "00:11:22:33:44:77", |
|
661 |
links: [ |
|
662 |
{
|
|
663 |
ip_address: "192.168.122.1" |
|
664 |
},
|
|
665 |
{
|
|
666 |
ip_address: "192.168.122.2" |
|
667 |
},
|
|
668 |
{
|
|
669 |
ip_address: "192.168.122.3" |
|
670 |
}
|
|
671 |
]
|
|
672 |
}
|
|
673 |
]
|
|
674 |
}
|
|
675 |
];
|
|
676 |
||
677 |
defer.resolve(); |
|
678 |
$rootScope.$digest(); |
|
679 |
setActiveDefer.resolve(node); |
|
680 |
$rootScope.$digest(); |
|
681 |
||
682 |
expect($scope.devices).toEqual([ |
|
683 |
{
|
|
684 |
name: "device1.maas" |
|
685 |
},
|
|
686 |
{
|
|
687 |
name: "device2.maas", |
|
688 |
mac_address: "00:11:22:33:44:55" |
|
689 |
},
|
|
690 |
{
|
|
691 |
name: "device3.maas", |
|
692 |
mac_address: "00:11:22:33:44:66" |
|
693 |
},
|
|
694 |
{
|
|
695 |
name: "", |
|
696 |
mac_address: "00:11:22:33:44:77", |
|
697 |
ip_address: "192.168.122.1" |
|
698 |
},
|
|
699 |
{
|
|
700 |
name: "", |
|
701 |
mac_address: "", |
|
702 |
ip_address: "192.168.122.2" |
|
703 |
},
|
|
704 |
{
|
|
705 |
name: "", |
|
706 |
mac_address: "", |
|
707 |
ip_address: "192.168.122.3" |
|
708 |
}
|
|
709 |
]);
|
|
710 |
});
|
|
711 |
||
3942.6.1
by Blake Rouse
Use the ngTagsInput on the node details page to allow a user to add or remove tags from a node. |
712 |
describe("tagsAutocomplete", function() { |
713 |
||
714 |
it("calls TagsManager.autocomplete with query", function() { |
|
715 |
var controller = makeController(); |
|
716 |
spyOn(TagsManager, "autocomplete"); |
|
717 |
var query = makeName("query"); |
|
718 |
$scope.tagsAutocomplete(query); |
|
719 |
expect(TagsManager.autocomplete).toHaveBeenCalledWith(query); |
|
720 |
});
|
|
721 |
});
|
|
722 |
||
4444.1.1
by Lee Trager
Only allow the storage section to be edited if the node is Ready or Allocated |
723 |
describe("isSuperUser", function() { |
724 |
it("returns true if the user is a superuser", function() { |
|
725 |
var controller = makeController(); |
|
726 |
spyOn(UsersManager, "getAuthUser").and.returnValue( |
|
727 |
{ is_superuser: true }); |
|
728 |
expect($scope.isSuperUser()).toBe(true); |
|
729 |
});
|
|
730 |
||
731 |
it("returns false if the user is not a superuser", function() { |
|
732 |
var controller = makeController(); |
|
733 |
spyOn(UsersManager, "getAuthUser").and.returnValue( |
|
734 |
{ is_superuser: false }); |
|
735 |
expect($scope.isSuperUser()).toBe(false); |
|
736 |
});
|
|
737 |
});
|
|
738 |
||
3721.1.4
by Blake Rouse
Add tests for all the adjusted and new code. |
739 |
describe("getPowerStateClass", function() { |
740 |
||
741 |
it("returns blank if no node", function() { |
|
742 |
var controller = makeController(); |
|
743 |
expect($scope.getPowerStateClass()).toBe(""); |
|
744 |
});
|
|
745 |
||
746 |
it("returns check if checkingPower is true", function() { |
|
747 |
var controller = makeController(); |
|
748 |
$scope.node = node; |
|
749 |
$scope.checkingPower = true; |
|
750 |
expect($scope.getPowerStateClass()).toBe("checking"); |
|
751 |
});
|
|
752 |
||
753 |
it("returns power_state from node ", function() { |
|
754 |
var controller = makeController(); |
|
755 |
var state = makeName("state"); |
|
756 |
$scope.node = node; |
|
757 |
node.power_state = state; |
|
758 |
expect($scope.getPowerStateClass()).toBe(state); |
|
759 |
});
|
|
760 |
});
|
|
761 |
||
3660.6.4
by Blake Rouse
Add tests for node details controller. |
762 |
describe("getPowerStateText", function() { |
763 |
||
764 |
it("returns blank if no node", function() { |
|
765 |
var controller = makeController(); |
|
766 |
expect($scope.getPowerStateText()).toBe(""); |
|
767 |
});
|
|
768 |
||
3721.1.4
by Blake Rouse
Add tests for all the adjusted and new code. |
769 |
it("returns 'Checking' if checkingPower is true", function() { |
770 |
var controller = makeController(); |
|
771 |
$scope.node = node; |
|
772 |
$scope.checkingPower = true; |
|
773 |
node.power_state = "unknown"; |
|
774 |
expect($scope.getPowerStateText()).toBe("Checking power"); |
|
775 |
});
|
|
776 |
||
3660.6.4
by Blake Rouse
Add tests for node details controller. |
777 |
it("returns blank if power_state is unknown", function() { |
778 |
var controller = makeController(); |
|
779 |
$scope.node = node; |
|
780 |
node.power_state = "unknown"; |
|
781 |
expect($scope.getPowerStateText()).toBe(""); |
|
782 |
});
|
|
783 |
||
784 |
it("returns power_state prefixed with Power ", function() { |
|
785 |
var controller = makeController(); |
|
786 |
var state = makeName("state"); |
|
787 |
$scope.node = node; |
|
788 |
node.power_state = state; |
|
789 |
expect($scope.getPowerStateText()).toBe("Power " + state); |
|
790 |
});
|
|
791 |
});
|
|
792 |
||
3721.1.4
by Blake Rouse
Add tests for all the adjusted and new code. |
793 |
describe("canCheckPowerState", function() { |
794 |
||
795 |
it("returns false if no node", function() { |
|
796 |
var controller = makeController(); |
|
797 |
expect($scope.canCheckPowerState()).toBe(false); |
|
798 |
});
|
|
799 |
||
800 |
it("returns false if power_state is unknown", function() { |
|
801 |
var controller = makeController(); |
|
802 |
$scope.node = node; |
|
803 |
node.power_state = "unknown"; |
|
804 |
expect($scope.canCheckPowerState()).toBe(false); |
|
805 |
});
|
|
806 |
||
807 |
it("returns false if checkingPower is true", function() { |
|
808 |
var controller = makeController(); |
|
809 |
$scope.node = node; |
|
810 |
$scope.checkingPower = true; |
|
811 |
expect($scope.canCheckPowerState()).toBe(false); |
|
812 |
});
|
|
813 |
||
814 |
it("returns true if not checkingPower and power_state not unknown", |
|
815 |
function() { |
|
816 |
var controller = makeController(); |
|
817 |
$scope.node = node; |
|
818 |
expect($scope.canCheckPowerState()).toBe(true); |
|
819 |
});
|
|
820 |
});
|
|
821 |
||
822 |
describe("checkPowerState", function() { |
|
823 |
||
824 |
it("sets checkingPower to true", function() { |
|
825 |
var controller = makeController(); |
|
4600.2.21
by Blake Rouse
Fix api tests up to test_machine. |
826 |
spyOn(MachinesManager, "checkPowerState").and.returnValue( |
3721.1.4
by Blake Rouse
Add tests for all the adjusted and new code. |
827 |
$q.defer().promise); |
828 |
$scope.checkPowerState(); |
|
829 |
expect($scope.checkingPower).toBe(true); |
|
830 |
});
|
|
831 |
||
832 |
it("sets checkingPower to false once checkPowerState resolves", |
|
833 |
function() { |
|
834 |
var controller = makeController(); |
|
835 |
var defer = $q.defer(); |
|
4600.2.21
by Blake Rouse
Fix api tests up to test_machine. |
836 |
spyOn(MachinesManager, "checkPowerState").and.returnValue( |
3721.1.4
by Blake Rouse
Add tests for all the adjusted and new code. |
837 |
defer.promise); |
838 |
$scope.checkPowerState(); |
|
839 |
defer.resolve(); |
|
840 |
$rootScope.$digest(); |
|
841 |
expect($scope.checkingPower).toBe(false); |
|
842 |
});
|
|
843 |
});
|
|
844 |
||
3660.6.4
by Blake Rouse
Add tests for node details controller. |
845 |
describe("getOSText", function() { |
846 |
||
847 |
it("returns blank if no node", function() { |
|
848 |
var controller = makeController(); |
|
849 |
expect($scope.getOSText()).toBe(""); |
|
850 |
});
|
|
851 |
||
852 |
it("returns osystem/series if no osinfo", function() { |
|
853 |
var controller = makeController(); |
|
854 |
var osystem = makeName("osystem"); |
|
855 |
var series = makeName("distro_series"); |
|
3660.6.5
by Blake Rouse
Fix up the tests. |
856 |
var os_series = osystem + "/" + series; |
857 |
$scope.node = node; |
|
858 |
node.osystem = osystem; |
|
859 |
node.distro_series = series; |
|
860 |
expect($scope.getOSText()).toBe(os_series); |
|
861 |
});
|
|
862 |
||
863 |
it("returns release title if osinfo", function() { |
|
864 |
var controller = makeController(); |
|
865 |
var osystem = makeName("osystem"); |
|
866 |
var series = makeName("distro_series"); |
|
867 |
var os_series = osystem + "/" + series; |
|
868 |
var title = makeName("title"); |
|
869 |
$scope.node = node; |
|
870 |
$scope.osinfo = { |
|
871 |
releases: [ |
|
872 |
[os_series, title] |
|
873 |
]
|
|
874 |
};
|
|
875 |
node.osystem = osystem; |
|
876 |
node.distro_series = series; |
|
877 |
expect($scope.getOSText()).toBe(title); |
|
878 |
});
|
|
879 |
||
880 |
it("returns osystem/series not in osinfo", function() { |
|
881 |
var controller = makeController(); |
|
882 |
var osystem = makeName("osystem"); |
|
883 |
var series = makeName("distro_series"); |
|
884 |
var os_series = osystem + "/" + series; |
|
885 |
$scope.node = node; |
|
886 |
$scope.osinfo = { |
|
887 |
releases: [ |
|
888 |
[makeName("release"), makeName("title")] |
|
889 |
]
|
|
890 |
};
|
|
891 |
node.osystem = osystem; |
|
892 |
node.distro_series = series; |
|
893 |
expect($scope.getOSText()).toBe(os_series); |
|
894 |
});
|
|
895 |
});
|
|
896 |
||
4419.1.2
by Lee Trager
Make corrections suggested by blake_r. Fix intermittent test failure |
897 |
describe("isUbuntuOS", function() { |
4419.1.1
by Lee Trager
Only pass custom storage and networking options to curtin if the OS is supported |
898 |
it("returns true when ubuntu", function() { |
899 |
var controller = makeController(); |
|
900 |
$scope.node = node; |
|
901 |
node.osystem = 'ubuntu'; |
|
902 |
node.distro_series = makeName("distro_series"); |
|
4419.1.2
by Lee Trager
Make corrections suggested by blake_r. Fix intermittent test failure |
903 |
expect($scope.isUbuntuOS()).toBe(true); |
4419.1.1
by Lee Trager
Only pass custom storage and networking options to curtin if the OS is supported |
904 |
});
|
905 |
||
906 |
it("returns false when otheros", function() { |
|
907 |
var controller = makeController(); |
|
908 |
$scope.node = node; |
|
909 |
node.osystem = makeName("osystem"); |
|
910 |
node.distro_series = makeName("distro_series"); |
|
4419.1.2
by Lee Trager
Make corrections suggested by blake_r. Fix intermittent test failure |
911 |
expect($scope.isUbuntuOS()).toBe(false); |
4419.1.1
by Lee Trager
Only pass custom storage and networking options to curtin if the OS is supported |
912 |
});
|
913 |
});
|
|
914 |
||
3660.17.2
by Blake Rouse
Fix and add tests. |
915 |
describe("isActionError", function() { |
916 |
||
917 |
it("returns true if actionError", function() { |
|
918 |
var controller = makeController(); |
|
919 |
$scope.actionError = makeName("error"); |
|
920 |
expect($scope.isActionError()).toBe(true); |
|
921 |
});
|
|
922 |
||
923 |
it("returns false if not actionError", function() { |
|
924 |
var controller = makeController(); |
|
925 |
$scope.actionError = null; |
|
926 |
expect($scope.isActionError()).toBe(false); |
|
927 |
});
|
|
928 |
});
|
|
929 |
||
3660.6.5
by Blake Rouse
Fix up the tests. |
930 |
describe("isDeployError", function() { |
931 |
||
3660.17.2
by Blake Rouse
Fix and add tests. |
932 |
it("returns false if already actionError", function() { |
933 |
var controller = makeController(); |
|
934 |
$scope.actionError = makeName("error"); |
|
935 |
expect($scope.isDeployError()).toBe(false); |
|
936 |
});
|
|
937 |
||
3660.6.5
by Blake Rouse
Fix up the tests. |
938 |
it("returns true if deploy action and missing osinfo", function() { |
939 |
var controller = makeController(); |
|
940 |
$scope.actionOption = { |
|
941 |
name: "deploy" |
|
942 |
};
|
|
943 |
expect($scope.isDeployError()).toBe(true); |
|
944 |
});
|
|
945 |
||
946 |
it("returns true if deploy action and no osystems", function() { |
|
947 |
var controller = makeController(); |
|
948 |
$scope.actionOption = { |
|
949 |
name: "deploy" |
|
950 |
};
|
|
951 |
$scope.osinfo = { |
|
952 |
osystems: [] |
|
953 |
};
|
|
954 |
expect($scope.isDeployError()).toBe(true); |
|
955 |
});
|
|
956 |
||
957 |
it("returns false if actionOption null", function() { |
|
958 |
var controller = makeController(); |
|
959 |
expect($scope.isDeployError()).toBe(false); |
|
960 |
});
|
|
961 |
||
962 |
it("returns false if not deploy action", function() { |
|
963 |
var controller = makeController(); |
|
964 |
$scope.actionOption = { |
|
965 |
name: "release" |
|
966 |
};
|
|
967 |
expect($scope.isDeployError()).toBe(false); |
|
968 |
});
|
|
969 |
||
970 |
it("returns false if osystems present", function() { |
|
971 |
var controller = makeController(); |
|
972 |
$scope.actionOption = { |
|
973 |
name: "deploy" |
|
974 |
};
|
|
975 |
$scope.osinfo = { |
|
976 |
osystems: [makeName("os")] |
|
977 |
};
|
|
978 |
expect($scope.isDeployError()).toBe(false); |
|
979 |
});
|
|
980 |
});
|
|
981 |
||
3844.3.3
by ubuntudotcom1
Tests. |
982 |
|
983 |
describe("isSSHKeyError", function() { |
|
984 |
||
985 |
it("returns true if deploy action and missing ssh keys", function() { |
|
986 |
var controller = makeController(); |
|
987 |
$scope.actionOption = { |
|
988 |
name: "deploy" |
|
989 |
};
|
|
990 |
var firstUser = makeUser(); |
|
991 |
firstUser.sshkeys_count = 0; |
|
992 |
UsersManager._authUser = firstUser; |
|
993 |
expect($scope.isSSHKeyError()).toBe(true); |
|
994 |
});
|
|
995 |
||
996 |
it("returns false if actionOption null", function() { |
|
997 |
var controller = makeController(); |
|
3844.3.4
by ubuntudotcom1
Tests. |
998 |
var firstUser = makeUser(); |
999 |
firstUser.sshkeys_count = 1; |
|
1000 |
UsersManager._authUser = firstUser; |
|
3844.3.3
by ubuntudotcom1
Tests. |
1001 |
expect($scope.isSSHKeyError()).toBe(false); |
1002 |
});
|
|
1003 |
||
1004 |
it("returns false if not deploy action", function() { |
|
1005 |
var controller = makeController(); |
|
1006 |
$scope.actionOption = { |
|
1007 |
name: "release" |
|
1008 |
};
|
|
3844.3.4
by ubuntudotcom1
Tests. |
1009 |
var firstUser = makeUser(); |
1010 |
firstUser.sshkeys_count = 1; |
|
1011 |
UsersManager._authUser = firstUser; |
|
3844.3.3
by ubuntudotcom1
Tests. |
1012 |
expect($scope.isSSHKeyError()).toBe(false); |
1013 |
});
|
|
1014 |
||
1015 |
it("returns false if ssh keys present", function() { |
|
1016 |
var controller = makeController(); |
|
1017 |
$scope.actionOption = { |
|
1018 |
name: "deploy" |
|
1019 |
};
|
|
1020 |
var firstUser = makeUser(); |
|
1021 |
firstUser.sshkeys_count = 1; |
|
1022 |
UsersManager._authUser = firstUser; |
|
1023 |
expect($scope.isSSHKeyError()).toBe(false); |
|
1024 |
});
|
|
1025 |
});
|
|
1026 |
||
3660.17.2
by Blake Rouse
Fix and add tests. |
1027 |
describe("actionOptionChanged", function() { |
1028 |
||
1029 |
it("clears actionError", function() { |
|
1030 |
var controller = makeController(); |
|
1031 |
$scope.actionError = makeName("error"); |
|
1032 |
$scope.actionOptionChanged(); |
|
1033 |
expect($scope.actionError).toBeNull(); |
|
1034 |
});
|
|
1035 |
});
|
|
1036 |
||
3660.6.5
by Blake Rouse
Fix up the tests. |
1037 |
describe("actionCancel", function() { |
1038 |
||
1039 |
it("sets actionOption to null", function() { |
|
1040 |
var controller = makeController(); |
|
1041 |
$scope.actionOption = {}; |
|
1042 |
$scope.actionCancel(); |
|
1043 |
expect($scope.actionOption).toBeNull(); |
|
1044 |
});
|
|
3660.17.2
by Blake Rouse
Fix and add tests. |
1045 |
|
1046 |
it("clears actionError", function() { |
|
1047 |
var controller = makeController(); |
|
1048 |
$scope.actionError = makeName("error"); |
|
1049 |
$scope.actionCancel(); |
|
1050 |
expect($scope.actionError).toBeNull(); |
|
1051 |
});
|
|
3660.6.5
by Blake Rouse
Fix up the tests. |
1052 |
});
|
1053 |
||
1054 |
describe("actionGo", function() { |
|
1055 |
||
1056 |
it("calls performAction with node and actionOption name", function() { |
|
1057 |
var controller = makeController(); |
|
4600.2.21
by Blake Rouse
Fix api tests up to test_machine. |
1058 |
spyOn(MachinesManager, "performAction").and.returnValue( |
3660.6.5
by Blake Rouse
Fix up the tests. |
1059 |
$q.defer().promise); |
1060 |
$scope.node = node; |
|
1061 |
$scope.actionOption = { |
|
5158.3.2
by Blake Rouse
Add release options for the WebUI for erasing, using secure erase and quick erase. Disable options based on global selections and select defaults based on global options. |
1062 |
name: "power_off" |
3830.1.1
by Blake Rouse
Send the osSelection for the deploy action on the node details page. |
1063 |
};
|
1064 |
$scope.actionGo(); |
|
4600.2.21
by Blake Rouse
Fix api tests up to test_machine. |
1065 |
expect(MachinesManager.performAction).toHaveBeenCalledWith( |
5158.3.2
by Blake Rouse
Add release options for the WebUI for erasing, using secure erase and quick erase. Disable options based on global selections and select defaults based on global options. |
1066 |
node, "power_off", {}); |
3830.1.1
by Blake Rouse
Send the osSelection for the deploy action on the node details page. |
1067 |
});
|
1068 |
||
1069 |
it("calls performAction with osystem and distro_series", function() { |
|
1070 |
var controller = makeController(); |
|
4600.2.21
by Blake Rouse
Fix api tests up to test_machine. |
1071 |
spyOn(MachinesManager, "performAction").and.returnValue( |
3830.1.1
by Blake Rouse
Send the osSelection for the deploy action on the node details page. |
1072 |
$q.defer().promise); |
1073 |
$scope.node = node; |
|
1074 |
$scope.actionOption = { |
|
3660.6.5
by Blake Rouse
Fix up the tests. |
1075 |
name: "deploy" |
1076 |
};
|
|
3897.1.1
by Blake Rouse
Add to the osSelection model, allowing a controller to reset a directives defaults. |
1077 |
$scope.osSelection.osystem = "ubuntu"; |
1078 |
$scope.osSelection.release = "ubuntu/trusty"; |
|
3660.6.5
by Blake Rouse
Fix up the tests. |
1079 |
$scope.actionGo(); |
4600.2.21
by Blake Rouse
Fix api tests up to test_machine. |
1080 |
expect(MachinesManager.performAction).toHaveBeenCalledWith( |
3830.1.1
by Blake Rouse
Send the osSelection for the deploy action on the node details page. |
1081 |
node, "deploy", { |
1082 |
osystem: "ubuntu", |
|
1083 |
distro_series: "trusty" |
|
1084 |
});
|
|
3660.6.5
by Blake Rouse
Fix up the tests. |
1085 |
});
|
1086 |
||
5624.1.1
by Lee Trager
Allow GA kernels to be selected when deploying on the node-details page. |
1087 |
it("calls performAction with hwe kernel", function() { |
1088 |
var controller = makeController(); |
|
1089 |
spyOn(MachinesManager, "performAction").and.returnValue( |
|
1090 |
$q.defer().promise); |
|
1091 |
$scope.node = node; |
|
1092 |
$scope.actionOption = { |
|
1093 |
name: "deploy" |
|
1094 |
};
|
|
1095 |
$scope.osSelection.osystem = "ubuntu"; |
|
1096 |
$scope.osSelection.release = "ubuntu/xenial"; |
|
1097 |
$scope.osSelection.hwe_kernel = "hwe-16.04-edge"; |
|
1098 |
$scope.actionGo(); |
|
1099 |
expect(MachinesManager.performAction).toHaveBeenCalledWith( |
|
1100 |
node, "deploy", { |
|
1101 |
osystem: "ubuntu", |
|
1102 |
distro_series: "xenial", |
|
1103 |
hwe_kernel: "hwe-16.04-edge" |
|
1104 |
});
|
|
1105 |
});
|
|
1106 |
||
1107 |
it("calls performAction with ga kernel", function() { |
|
1108 |
var controller = makeController(); |
|
1109 |
spyOn(MachinesManager, "performAction").and.returnValue( |
|
1110 |
$q.defer().promise); |
|
1111 |
$scope.node = node; |
|
1112 |
$scope.actionOption = { |
|
1113 |
name: "deploy" |
|
1114 |
};
|
|
1115 |
$scope.osSelection.osystem = "ubuntu"; |
|
1116 |
$scope.osSelection.release = "ubuntu/xenial"; |
|
1117 |
$scope.osSelection.hwe_kernel = "ga-16.04"; |
|
1118 |
$scope.actionGo(); |
|
1119 |
expect(MachinesManager.performAction).toHaveBeenCalledWith( |
|
1120 |
node, "deploy", { |
|
1121 |
osystem: "ubuntu", |
|
1122 |
distro_series: "xenial", |
|
1123 |
hwe_kernel: "ga-16.04" |
|
1124 |
});
|
|
1125 |
});
|
|
1126 |
||
4286.7.1
by Blake Rouse
Add commissioning options to the WebUI. |
1127 |
it("calls performAction with commissionOptions", function() { |
1128 |
var controller = makeController(); |
|
4600.2.21
by Blake Rouse
Fix api tests up to test_machine. |
1129 |
spyOn(MachinesManager, "performAction").and.returnValue( |
4286.7.1
by Blake Rouse
Add commissioning options to the WebUI. |
1130 |
$q.defer().promise); |
1131 |
$scope.node = node; |
|
1132 |
$scope.actionOption = { |
|
1133 |
name: "commission" |
|
1134 |
};
|
|
1135 |
$scope.commissionOptions.enableSSH = true; |
|
1136 |
$scope.commissionOptions.skipNetworking = false; |
|
1137 |
$scope.commissionOptions.skipStorage = false; |
|
1138 |
$scope.actionGo(); |
|
4600.2.21
by Blake Rouse
Fix api tests up to test_machine. |
1139 |
expect(MachinesManager.performAction).toHaveBeenCalledWith( |
4286.7.1
by Blake Rouse
Add commissioning options to the WebUI. |
1140 |
node, "commission", { |
1141 |
enable_ssh: true, |
|
1142 |
skip_networking: false, |
|
1143 |
skip_storage: false |
|
1144 |
});
|
|
1145 |
});
|
|
1146 |
||
5158.3.2
by Blake Rouse
Add release options for the WebUI for erasing, using secure erase and quick erase. Disable options based on global selections and select defaults based on global options. |
1147 |
it("calls performAction with releaseOptions", function() { |
1148 |
var controller = makeController(); |
|
1149 |
spyOn(MachinesManager, "performAction").and.returnValue( |
|
1150 |
$q.defer().promise); |
|
1151 |
$scope.node = node; |
|
1152 |
$scope.actionOption = { |
|
1153 |
name: "release" |
|
1154 |
};
|
|
5158.3.4
by Blake Rouse
Fix code review. |
1155 |
var secureErase = makeName("secureErase"); |
1156 |
var quickErase = makeName("quickErase"); |
|
5158.3.2
by Blake Rouse
Add release options for the WebUI for erasing, using secure erase and quick erase. Disable options based on global selections and select defaults based on global options. |
1157 |
$scope.releaseOptions.erase = true; |
5158.3.4
by Blake Rouse
Fix code review. |
1158 |
$scope.releaseOptions.secureErase = secureErase; |
1159 |
$scope.releaseOptions.quickErase = quickErase; |
|
5158.3.2
by Blake Rouse
Add release options for the WebUI for erasing, using secure erase and quick erase. Disable options based on global selections and select defaults based on global options. |
1160 |
$scope.actionGo(); |
1161 |
expect(MachinesManager.performAction).toHaveBeenCalledWith( |
|
1162 |
node, "release", { |
|
1163 |
erase: true, |
|
5158.3.4
by Blake Rouse
Fix code review. |
1164 |
secure_erase: secureErase, |
1165 |
quick_erase: quickErase |
|
5158.3.2
by Blake Rouse
Add release options for the WebUI for erasing, using secure erase and quick erase. Disable options based on global selections and select defaults based on global options. |
1166 |
});
|
1167 |
});
|
|
1168 |
||
3660.6.5
by Blake Rouse
Fix up the tests. |
1169 |
it("clears actionOption on resolve", function() { |
1170 |
var controller = makeController(); |
|
1171 |
var defer = $q.defer(); |
|
4600.2.21
by Blake Rouse
Fix api tests up to test_machine. |
1172 |
spyOn(MachinesManager, "performAction").and.returnValue( |
3660.6.5
by Blake Rouse
Fix up the tests. |
1173 |
defer.promise); |
1174 |
$scope.node = node; |
|
1175 |
$scope.actionOption = { |
|
1176 |
name: "deploy" |
|
1177 |
};
|
|
1178 |
$scope.actionGo(); |
|
1179 |
defer.resolve(); |
|
1180 |
$rootScope.$digest(); |
|
1181 |
expect($scope.actionOption).toBeNull(); |
|
1182 |
});
|
|
1183 |
||
3830.1.1
by Blake Rouse
Send the osSelection for the deploy action on the node details page. |
1184 |
it("clears osSelection on resolve", function() { |
1185 |
var controller = makeController(); |
|
1186 |
var defer = $q.defer(); |
|
4600.2.21
by Blake Rouse
Fix api tests up to test_machine. |
1187 |
spyOn(MachinesManager, "performAction").and.returnValue( |
3830.1.1
by Blake Rouse
Send the osSelection for the deploy action on the node details page. |
1188 |
defer.promise); |
1189 |
$scope.node = node; |
|
1190 |
$scope.actionOption = { |
|
1191 |
name: "deploy" |
|
1192 |
};
|
|
3897.1.1
by Blake Rouse
Add to the osSelection model, allowing a controller to reset a directives defaults. |
1193 |
$scope.osSelection.osystem = "ubuntu"; |
1194 |
$scope.osSelection.release = "ubuntu/trusty"; |
|
3830.1.1
by Blake Rouse
Send the osSelection for the deploy action on the node details page. |
1195 |
$scope.actionGo(); |
1196 |
defer.resolve(); |
|
1197 |
$rootScope.$digest(); |
|
3897.1.1
by Blake Rouse
Add to the osSelection model, allowing a controller to reset a directives defaults. |
1198 |
expect($scope.osSelection.$reset).toHaveBeenCalled(); |
3830.1.1
by Blake Rouse
Send the osSelection for the deploy action on the node details page. |
1199 |
});
|
1200 |
||
4286.7.1
by Blake Rouse
Add commissioning options to the WebUI. |
1201 |
it("clears commissionOptions on resolve", function() { |
1202 |
var controller = makeController(); |
|
1203 |
var defer = $q.defer(); |
|
4600.2.21
by Blake Rouse
Fix api tests up to test_machine. |
1204 |
spyOn(MachinesManager, "performAction").and.returnValue( |
4286.7.1
by Blake Rouse
Add commissioning options to the WebUI. |
1205 |
defer.promise); |
1206 |
$scope.node = node; |
|
1207 |
$scope.actionOption = { |
|
1208 |
name: "commission" |
|
1209 |
};
|
|
1210 |
$scope.commissionOptions.enableSSH = true; |
|
1211 |
$scope.commissionOptions.skipNetworking = true; |
|
1212 |
$scope.commissionOptions.skipStorage = true; |
|
1213 |
$scope.actionGo(); |
|
1214 |
defer.resolve(); |
|
1215 |
$rootScope.$digest(); |
|
1216 |
expect($scope.commissionOptions).toEqual({ |
|
1217 |
enableSSH: false, |
|
1218 |
skipNetworking: false, |
|
1219 |
skipStorage: false |
|
1220 |
});
|
|
1221 |
});
|
|
1222 |
||
3660.17.2
by Blake Rouse
Fix and add tests. |
1223 |
it("clears actionError on resolve", function() { |
1224 |
var controller = makeController(); |
|
1225 |
var defer = $q.defer(); |
|
4600.2.21
by Blake Rouse
Fix api tests up to test_machine. |
1226 |
spyOn(MachinesManager, "performAction").and.returnValue( |
3660.17.2
by Blake Rouse
Fix and add tests. |
1227 |
defer.promise); |
1228 |
$scope.node = node; |
|
1229 |
$scope.actionOption = { |
|
1230 |
name: "deploy" |
|
1231 |
};
|
|
1232 |
$scope.actionError = makeName("error"); |
|
1233 |
$scope.actionGo(); |
|
1234 |
defer.resolve(); |
|
1235 |
$rootScope.$digest(); |
|
1236 |
expect($scope.actionError).toBeNull(); |
|
1237 |
});
|
|
1238 |
||
3660.6.5
by Blake Rouse
Fix up the tests. |
1239 |
it("changes path to node listing on delete", function() { |
1240 |
var controller = makeController(); |
|
1241 |
var defer = $q.defer(); |
|
4600.2.21
by Blake Rouse
Fix api tests up to test_machine. |
1242 |
spyOn(MachinesManager, "performAction").and.returnValue( |
3660.6.5
by Blake Rouse
Fix up the tests. |
1243 |
defer.promise); |
1244 |
spyOn($location, "path"); |
|
1245 |
$scope.node = node; |
|
1246 |
$scope.actionOption = { |
|
1247 |
name: "delete" |
|
1248 |
};
|
|
1249 |
$scope.actionGo(); |
|
1250 |
defer.resolve(); |
|
1251 |
$rootScope.$digest(); |
|
1252 |
expect($location.path).toHaveBeenCalledWith("/nodes"); |
|
1253 |
});
|
|
3660.17.2
by Blake Rouse
Fix and add tests. |
1254 |
|
1255 |
it("sets actionError when rejected", function() { |
|
1256 |
var controller = makeController(); |
|
1257 |
var defer = $q.defer(); |
|
4600.2.21
by Blake Rouse
Fix api tests up to test_machine. |
1258 |
spyOn(MachinesManager, "performAction").and.returnValue( |
3660.17.2
by Blake Rouse
Fix and add tests. |
1259 |
defer.promise); |
1260 |
$scope.node = node; |
|
1261 |
$scope.actionOption = { |
|
1262 |
name: "deploy" |
|
1263 |
};
|
|
1264 |
var error = makeName("error"); |
|
1265 |
$scope.actionGo(); |
|
1266 |
defer.reject(error); |
|
1267 |
$rootScope.$digest(); |
|
1268 |
expect($scope.actionError).toBe(error); |
|
1269 |
});
|
|
1270 |
});
|
|
1271 |
||
1272 |
describe("isSuperUser", function() { |
|
1273 |
||
1274 |
it("returns false if no authUser", function() { |
|
1275 |
var controller = makeController(); |
|
1276 |
UsersManager._authUser = null; |
|
1277 |
expect($scope.isSuperUser()).toBe(false); |
|
1278 |
});
|
|
1279 |
||
1280 |
it("returns false if authUser.is_superuser is false", function() { |
|
1281 |
var controller = makeController(); |
|
1282 |
UsersManager._authUser.is_superuser = false; |
|
1283 |
expect($scope.isSuperUser()).toBe(false); |
|
1284 |
});
|
|
1285 |
||
1286 |
it("returns true if authUser.is_superuser is true", function() { |
|
1287 |
var controller = makeController(); |
|
1288 |
UsersManager._authUser.is_superuser = true; |
|
1289 |
expect($scope.isSuperUser()).toBe(true); |
|
1290 |
});
|
|
3660.6.5
by Blake Rouse
Fix up the tests. |
1291 |
});
|
1292 |
||
4892.1.1
by Blake Rouse
Fix handling no connected rack controllers on the machine details page. Cleanup error messages on the machine details page. Fix power_type options from being reset mid type. |
1293 |
describe("hasUsableArchitectures", function() { |
1294 |
||
1295 |
it("returns true if architecture available", function() { |
|
1296 |
var controller = makeController(); |
|
1297 |
$scope.summary.architecture.options = ["amd64/generic"]; |
|
1298 |
expect($scope.hasUsableArchitectures()).toBe(true); |
|
1299 |
});
|
|
1300 |
||
1301 |
it("returns false if no architecture available", function() { |
|
1302 |
var controller = makeController(); |
|
1303 |
$scope.summary.architecture.options = []; |
|
1304 |
expect($scope.hasUsableArchitectures()).toBe(false); |
|
1305 |
});
|
|
1306 |
});
|
|
1307 |
||
1308 |
describe("getArchitecturePlaceholder", function() { |
|
1309 |
||
1310 |
it("returns choose if architecture available", function() { |
|
1311 |
var controller = makeController(); |
|
1312 |
$scope.summary.architecture.options = ["amd64/generic"]; |
|
1313 |
expect($scope.getArchitecturePlaceholder()).toBe( |
|
1314 |
"Choose an architecture"); |
|
1315 |
});
|
|
1316 |
||
1317 |
it("returns error if no architecture available", function() { |
|
1318 |
var controller = makeController(); |
|
1319 |
$scope.summary.architecture.options = []; |
|
1320 |
expect($scope.getArchitecturePlaceholder()).toBe( |
|
1321 |
"-- No usable architectures --"); |
|
1322 |
});
|
|
1323 |
});
|
|
1324 |
||
1325 |
describe("hasInvalidArchitecture", function() { |
|
1326 |
||
1327 |
it("returns false if node is null", function() { |
|
1328 |
var controller = makeController(); |
|
1329 |
$scope.node = null; |
|
1330 |
$scope.summary.architecture.options = ["amd64/generic"]; |
|
1331 |
expect($scope.hasInvalidArchitecture()).toBe(false); |
|
1332 |
});
|
|
1333 |
||
1334 |
it("returns true if node.architecture is blank", function() { |
|
1335 |
var controller = makeController(); |
|
1336 |
$scope.node = { |
|
1337 |
architecture: "" |
|
1338 |
};
|
|
1339 |
$scope.summary.architecture.options = ["amd64/generic"]; |
|
1340 |
expect($scope.hasInvalidArchitecture()).toBe(true); |
|
1341 |
});
|
|
1342 |
||
1343 |
it("returns true if node.architecture not in options", function() { |
|
1344 |
var controller = makeController(); |
|
1345 |
$scope.node = { |
|
1346 |
architecture: "i386/generic" |
|
1347 |
};
|
|
1348 |
$scope.summary.architecture.options = ["amd64/generic"]; |
|
1349 |
expect($scope.hasInvalidArchitecture()).toBe(true); |
|
1350 |
});
|
|
1351 |
||
1352 |
it("returns false if node.architecture in options", function() { |
|
1353 |
var controller = makeController(); |
|
1354 |
$scope.node = { |
|
1355 |
architecture: "amd64/generic" |
|
1356 |
};
|
|
1357 |
$scope.summary.architecture.options = ["amd64/generic"]; |
|
1358 |
expect($scope.hasInvalidArchitecture()).toBe(false); |
|
1359 |
});
|
|
1360 |
});
|
|
1361 |
||
3660.8.3
by Blake Rouse
Add more tests. |
1362 |
describe("invalidArchitecture", function() { |
1363 |
||
1364 |
it("returns true if selected architecture empty", function() { |
|
1365 |
var controller = makeController(); |
|
1366 |
$scope.summary.architecture.selected = ""; |
|
1367 |
expect($scope.invalidArchitecture()).toBe(true); |
|
1368 |
});
|
|
1369 |
||
1370 |
it("returns true if selected architecture not in options", function() { |
|
1371 |
var controller = makeController(); |
|
1372 |
$scope.summary.architecture.options = [makeName("arch")]; |
|
1373 |
$scope.summary.architecture.selected = makeName("arch"); |
|
1374 |
expect($scope.invalidArchitecture()).toBe(true); |
|
1375 |
});
|
|
1376 |
||
1377 |
it("returns false if selected architecture in options", function() { |
|
1378 |
var controller = makeController(); |
|
1379 |
var arch = makeName("arch"); |
|
1380 |
$scope.summary.architecture.options = [arch]; |
|
1381 |
$scope.summary.architecture.selected = arch; |
|
1382 |
expect($scope.invalidArchitecture()).toBe(false); |
|
1383 |
});
|
|
1384 |
});
|
|
1385 |
||
4892.1.1
by Blake Rouse
Fix handling no connected rack controllers on the machine details page. Cleanup error messages on the machine details page. Fix power_type options from being reset mid type. |
1386 |
describe("isRackControllerConnected", function() { |
1387 |
||
1388 |
it("returns false no power_types", function() { |
|
1389 |
var controller = makeController(); |
|
1390 |
$scope.power_types = []; |
|
1391 |
expect($scope.isRackControllerConnected()).toBe(false); |
|
1392 |
});
|
|
1393 |
||
1394 |
it("returns true if power_types", function() { |
|
1395 |
var controller = makeController(); |
|
1396 |
$scope.power_types = [{}]; |
|
1397 |
expect($scope.isRackControllerConnected()).toBe(true); |
|
1398 |
});
|
|
1399 |
});
|
|
1400 |
||
3660.17.2
by Blake Rouse
Fix and add tests. |
1401 |
describe("canEdit", function() { |
1402 |
||
4892.1.1
by Blake Rouse
Fix handling no connected rack controllers on the machine details page. Cleanup error messages on the machine details page. Fix power_type options from being reset mid type. |
1403 |
it("returns false if not super user", function() { |
3660.17.2
by Blake Rouse
Fix and add tests. |
1404 |
var controller = makeController(); |
4699.3.14
by Blake Rouse
Fix the WebUI to prevent modifing controllers hostname. Allow modifing only the fabric on a controller interface, both in the WebUI and the API. |
1405 |
$scope.isController = false; |
3660.17.2
by Blake Rouse
Fix and add tests. |
1406 |
spyOn($scope, "isSuperUser").and.returnValue(false); |
4892.1.1
by Blake Rouse
Fix handling no connected rack controllers on the machine details page. Cleanup error messages on the machine details page. Fix power_type options from being reset mid type. |
1407 |
spyOn( |
1408 |
$scope, |
|
1409 |
"isRackControllerConnected").and.returnValue(true); |
|
3660.17.2
by Blake Rouse
Fix and add tests. |
1410 |
expect($scope.canEdit()).toBe(false); |
1411 |
});
|
|
1412 |
||
4892.1.1
by Blake Rouse
Fix handling no connected rack controllers on the machine details page. Cleanup error messages on the machine details page. Fix power_type options from being reset mid type. |
1413 |
it("returns false if controller", function() { |
4699.3.14
by Blake Rouse
Fix the WebUI to prevent modifing controllers hostname. Allow modifing only the fabric on a controller interface, both in the WebUI and the API. |
1414 |
var controller = makeController(); |
1415 |
$scope.isController = true; |
|
4892.1.1
by Blake Rouse
Fix handling no connected rack controllers on the machine details page. Cleanup error messages on the machine details page. Fix power_type options from being reset mid type. |
1416 |
spyOn( |
1417 |
$scope, |
|
1418 |
"isRackControllerConnected").and.returnValue(true); |
|
1419 |
expect($scope.canEdit()).toBe(false); |
|
1420 |
});
|
|
1421 |
||
1422 |
it("returns false if rack disconnected", function() { |
|
1423 |
var controller = makeController(); |
|
1424 |
$scope.isController = false; |
|
1425 |
spyOn( |
|
1426 |
$scope, |
|
1427 |
"isRackControllerConnected").and.returnValue(false); |
|
1428 |
expect($scope.canEdit()).toBe(false); |
|
1429 |
});
|
|
1430 |
||
1431 |
it("returns true if super user, rack connected, not controller", |
|
3660.17.2
by Blake Rouse
Fix and add tests. |
1432 |
function() { |
1433 |
var controller = makeController(); |
|
4699.3.14
by Blake Rouse
Fix the WebUI to prevent modifing controllers hostname. Allow modifing only the fabric on a controller interface, both in the WebUI and the API. |
1434 |
$scope.isController = false; |
4892.1.1
by Blake Rouse
Fix handling no connected rack controllers on the machine details page. Cleanup error messages on the machine details page. Fix power_type options from being reset mid type. |
1435 |
spyOn( |
1436 |
$scope, |
|
1437 |
"isRackControllerConnected").and.returnValue(true); |
|
3660.17.2
by Blake Rouse
Fix and add tests. |
1438 |
expect($scope.canEdit()).toBe(true); |
1439 |
});
|
|
1440 |
});
|
|
1441 |
||
4750.5.1
by Lee Trager
Allow changing the machine domain in the UI |
1442 |
describe("editHeader", function() { |
3721.1.5
by Blake Rouse
Add the ability to rename a node in the header. |
1443 |
|
4750.5.1
by Lee Trager
Allow changing the machine domain in the UI |
1444 |
it("doesnt set editing to true if cannot edit", function() { |
3721.1.5
by Blake Rouse
Add the ability to rename a node in the header. |
1445 |
var controller = makeController(); |
1446 |
spyOn($scope, "canEdit").and.returnValue(false); |
|
4750.5.1
by Lee Trager
Allow changing the machine domain in the UI |
1447 |
$scope.header.editing = false; |
1448 |
$scope.editHeader(); |
|
1449 |
expect($scope.header.editing).toBe(false); |
|
1450 |
});
|
|
1451 |
||
1452 |
it("sets editing to true if able", function() { |
|
1453 |
var controller = makeController(); |
|
1454 |
$scope.node = node; |
|
1455 |
spyOn($scope, "canEdit").and.returnValue(true); |
|
1456 |
$scope.header.editing = false; |
|
1457 |
$scope.editHeader(); |
|
1458 |
expect($scope.header.editing).toBe(true); |
|
1459 |
});
|
|
1460 |
||
1461 |
it("sets header.hostname.value to node hostname", function() { |
|
1462 |
var controller = makeController(); |
|
1463 |
$scope.node = node; |
|
1464 |
spyOn($scope, "canEdit").and.returnValue(true); |
|
1465 |
$scope.editHeader(); |
|
1466 |
expect($scope.header.hostname.value).toBe(node.hostname); |
|
1467 |
});
|
|
1468 |
||
1469 |
it("doesnt reset header.hostname.value on multiple calls", function() { |
|
1470 |
var controller = makeController(); |
|
1471 |
$scope.node = node; |
|
1472 |
spyOn($scope, "canEdit").and.returnValue(true); |
|
1473 |
$scope.editHeader(); |
|
3721.1.5
by Blake Rouse
Add the ability to rename a node in the header. |
1474 |
var updatedName = makeName("name"); |
4750.5.1
by Lee Trager
Allow changing the machine domain in the UI |
1475 |
$scope.header.hostname.value = updatedName; |
1476 |
$scope.editHeader(); |
|
1477 |
expect($scope.header.hostname.value).toBe(updatedName); |
|
3721.1.5
by Blake Rouse
Add the ability to rename a node in the header. |
1478 |
});
|
1479 |
});
|
|
1480 |
||
4750.5.1
by Lee Trager
Allow changing the machine domain in the UI |
1481 |
describe("editHeaderInvalid", function() { |
3721.1.5
by Blake Rouse
Add the ability to rename a node in the header. |
1482 |
|
3786.1.1
by Blake Rouse
Fix selection of node on click to go to node details. Fix inconsistent button text on node listing. Fix query parameter to be used by NodesListController. |
1483 |
it("returns false if not editing", function() { |
1484 |
var controller = makeController(); |
|
4750.5.1
by Lee Trager
Allow changing the machine domain in the UI |
1485 |
$scope.header.editing = false; |
1486 |
$scope.header.hostname.value = "abc_invalid.local"; |
|
1487 |
expect($scope.editHeaderInvalid()).toBe(false); |
|
3786.1.1
by Blake Rouse
Fix selection of node on click to go to node details. Fix inconsistent button text on node listing. Fix query parameter to be used by NodesListController. |
1488 |
});
|
1489 |
||
3721.1.9
by Blake Rouse
Show error when the hostname for a node is invalid, instead of striping the characters. |
1490 |
it("returns true for bad values", function() { |
3721.1.5
by Blake Rouse
Add the ability to rename a node in the header. |
1491 |
var controller = makeController(); |
4750.5.1
by Lee Trager
Allow changing the machine domain in the UI |
1492 |
$scope.header.editing = true; |
3721.1.5
by Blake Rouse
Add the ability to rename a node in the header. |
1493 |
var values = [ |
1494 |
{
|
|
3608.4.40
by ubuntudotcom1
Merge trunk. |
1495 |
input: "aB0-z", |
1496 |
output: false |
|
1497 |
},
|
|
1498 |
{
|
|
1499 |
input: "abc_alpha", |
|
1500 |
output: true |
|
1501 |
},
|
|
1502 |
{
|
|
1503 |
input: "ab^&c", |
|
1504 |
output: true |
|
1505 |
},
|
|
1506 |
{
|
|
1507 |
input: "abc.local", |
|
1508 |
output: true |
|
3721.1.7
by Blake Rouse
Fix lint. |
1509 |
}
|
3721.1.5
by Blake Rouse
Add the ability to rename a node in the header. |
1510 |
];
|
1511 |
angular.forEach(values, function(value) { |
|
4750.5.1
by Lee Trager
Allow changing the machine domain in the UI |
1512 |
$scope.header.hostname.value = value.input; |
1513 |
expect($scope.editHeaderInvalid()).toBe(value.output); |
|
3721.1.5
by Blake Rouse
Add the ability to rename a node in the header. |
1514 |
});
|
1515 |
});
|
|
1516 |
});
|
|
1517 |
||
4750.5.1
by Lee Trager
Allow changing the machine domain in the UI |
1518 |
describe("cancelEditHeader", function() { |
3721.1.5
by Blake Rouse
Add the ability to rename a node in the header. |
1519 |
|
1520 |
it("sets editing to false for nameHeader section", function() { |
|
1521 |
var controller = makeController(); |
|
1522 |
$scope.node = node; |
|
4750.5.1
by Lee Trager
Allow changing the machine domain in the UI |
1523 |
$scope.header.editing = true; |
1524 |
$scope.cancelEditHeader(); |
|
1525 |
expect($scope.header.editing).toBe(false); |
|
3721.1.5
by Blake Rouse
Add the ability to rename a node in the header. |
1526 |
});
|
1527 |
||
4750.5.1
by Lee Trager
Allow changing the machine domain in the UI |
1528 |
it("sets header.hostname.value back to fqdn", function() { |
3721.1.5
by Blake Rouse
Add the ability to rename a node in the header. |
1529 |
var controller = makeController(); |
1530 |
$scope.node = node; |
|
4750.5.1
by Lee Trager
Allow changing the machine domain in the UI |
1531 |
$scope.header.editing = true; |
1532 |
$scope.header.hostname.value = makeName("name"); |
|
1533 |
$scope.cancelEditHeader(); |
|
1534 |
expect($scope.header.hostname.value).toBe(node.fqdn); |
|
3721.1.5
by Blake Rouse
Add the ability to rename a node in the header. |
1535 |
});
|
1536 |
});
|
|
1537 |
||
4750.5.1
by Lee Trager
Allow changing the machine domain in the UI |
1538 |
describe("saveEditHeader", function() { |
3721.1.5
by Blake Rouse
Add the ability to rename a node in the header. |
1539 |
|
3721.1.9
by Blake Rouse
Show error when the hostname for a node is invalid, instead of striping the characters. |
1540 |
it("does nothing if value is invalid", function() { |
3721.1.5
by Blake Rouse
Add the ability to rename a node in the header. |
1541 |
var controller = makeController(); |
1542 |
$scope.node = node; |
|
4750.5.1
by Lee Trager
Allow changing the machine domain in the UI |
1543 |
spyOn($scope, "editHeaderInvalid").and.returnValue(true); |
3721.1.9
by Blake Rouse
Show error when the hostname for a node is invalid, instead of striping the characters. |
1544 |
var sentinel = {}; |
4750.5.1
by Lee Trager
Allow changing the machine domain in the UI |
1545 |
$scope.header.editing = sentinel; |
1546 |
$scope.saveEditHeader(); |
|
1547 |
expect($scope.header.editing).toBe(sentinel); |
|
3721.1.5
by Blake Rouse
Add the ability to rename a node in the header. |
1548 |
});
|
1549 |
||
1550 |
it("sets editing to false", function() { |
|
1551 |
var controller = makeController(); |
|
4600.2.21
by Blake Rouse
Fix api tests up to test_machine. |
1552 |
spyOn(MachinesManager, "updateItem").and.returnValue( |
3721.1.5
by Blake Rouse
Add the ability to rename a node in the header. |
1553 |
$q.defer().promise); |
4750.5.1
by Lee Trager
Allow changing the machine domain in the UI |
1554 |
spyOn($scope, "editHeaderInvalid").and.returnValue(false); |
3721.1.5
by Blake Rouse
Add the ability to rename a node in the header. |
1555 |
|
1556 |
$scope.node = node; |
|
4750.5.1
by Lee Trager
Allow changing the machine domain in the UI |
1557 |
$scope.header.editing = true; |
1558 |
$scope.header.hostname.value = makeName("name"); |
|
1559 |
$scope.saveEditHeader(); |
|
3721.1.5
by Blake Rouse
Add the ability to rename a node in the header. |
1560 |
|
4750.5.1
by Lee Trager
Allow changing the machine domain in the UI |
1561 |
expect($scope.header.editing).toBe(false); |
3721.1.5
by Blake Rouse
Add the ability to rename a node in the header. |
1562 |
});
|
1563 |
||
1564 |
it("calls updateItem with copy of node", function() { |
|
1565 |
var controller = makeController(); |
|
4600.2.21
by Blake Rouse
Fix api tests up to test_machine. |
1566 |
spyOn(MachinesManager, "updateItem").and.returnValue( |
3721.1.5
by Blake Rouse
Add the ability to rename a node in the header. |
1567 |
$q.defer().promise); |
4750.5.1
by Lee Trager
Allow changing the machine domain in the UI |
1568 |
spyOn($scope, "editHeaderInvalid").and.returnValue(false); |
3721.1.5
by Blake Rouse
Add the ability to rename a node in the header. |
1569 |
|
1570 |
$scope.node = node; |
|
4750.5.1
by Lee Trager
Allow changing the machine domain in the UI |
1571 |
$scope.header.editing = true; |
1572 |
$scope.header.hostname.value = makeName("name"); |
|
1573 |
$scope.saveEditHeader(); |
|
3721.1.5
by Blake Rouse
Add the ability to rename a node in the header. |
1574 |
|
4600.2.21
by Blake Rouse
Fix api tests up to test_machine. |
1575 |
var calledWithNode = MachinesManager.updateItem.calls.argsFor(0)[0]; |
3721.1.5
by Blake Rouse
Add the ability to rename a node in the header. |
1576 |
expect(calledWithNode).not.toBe(node); |
1577 |
});
|
|
1578 |
||
1579 |
it("calls updateItem with new hostname on node", function() { |
|
1580 |
var controller = makeController(); |
|
4600.2.21
by Blake Rouse
Fix api tests up to test_machine. |
1581 |
spyOn(MachinesManager, "updateItem").and.returnValue( |
3721.1.5
by Blake Rouse
Add the ability to rename a node in the header. |
1582 |
$q.defer().promise); |
4750.5.1
by Lee Trager
Allow changing the machine domain in the UI |
1583 |
spyOn($scope, "editHeaderInvalid").and.returnValue(false); |
3721.1.5
by Blake Rouse
Add the ability to rename a node in the header. |
1584 |
|
1585 |
var newName = makeName("name"); |
|
1586 |
$scope.node = node; |
|
4750.5.1
by Lee Trager
Allow changing the machine domain in the UI |
1587 |
$scope.header.editing = true; |
1588 |
$scope.header.hostname.value = newName; |
|
1589 |
$scope.saveEditHeader(); |
|
3721.1.5
by Blake Rouse
Add the ability to rename a node in the header. |
1590 |
|
4600.2.21
by Blake Rouse
Fix api tests up to test_machine. |
1591 |
var calledWithNode = MachinesManager.updateItem.calls.argsFor(0)[0]; |
3721.1.5
by Blake Rouse
Add the ability to rename a node in the header. |
1592 |
expect(calledWithNode.hostname).toBe(newName); |
1593 |
});
|
|
1594 |
||
1595 |
it("calls updateName once updateItem resolves", function() { |
|
1596 |
var controller = makeController(); |
|
1597 |
var defer = $q.defer(); |
|
4600.2.21
by Blake Rouse
Fix api tests up to test_machine. |
1598 |
spyOn(MachinesManager, "updateItem").and.returnValue( |
3721.1.5
by Blake Rouse
Add the ability to rename a node in the header. |
1599 |
defer.promise); |
4750.5.1
by Lee Trager
Allow changing the machine domain in the UI |
1600 |
spyOn($scope, "editHeaderInvalid").and.returnValue(false); |
3721.1.5
by Blake Rouse
Add the ability to rename a node in the header. |
1601 |
|
1602 |
$scope.node = node; |
|
4750.5.1
by Lee Trager
Allow changing the machine domain in the UI |
1603 |
$scope.header.editing = true; |
1604 |
$scope.header.hostname.value = makeName("name"); |
|
1605 |
$scope.saveEditHeader(); |
|
3721.1.5
by Blake Rouse
Add the ability to rename a node in the header. |
1606 |
|
1607 |
defer.resolve(node); |
|
1608 |
$rootScope.$digest(); |
|
1609 |
||
1610 |
// Since updateName is private in the controller, check
|
|
4750.5.1
by Lee Trager
Allow changing the machine domain in the UI |
1611 |
// that the header.hostname.value is set to the nodes fqdn.
|
1612 |
expect($scope.header.hostname.value).toBe(node.fqdn); |
|
3721.1.5
by Blake Rouse
Add the ability to rename a node in the header. |
1613 |
});
|
1614 |
});
|
|
1615 |
||
3660.6.5
by Blake Rouse
Fix up the tests. |
1616 |
describe("editSummary", function() { |
1617 |
||
3660.18.3
by Blake Rouse
Don't allow editSummary or editPower to turn on editing unless its possible to edit. |
1618 |
it("doesnt sets editing to true if cannot edit", function() { |
1619 |
var controller = makeController(); |
|
1620 |
spyOn($scope, "canEdit").and.returnValue(false); |
|
1621 |
$scope.summary.editing = false; |
|
1622 |
$scope.editSummary(); |
|
1623 |
expect($scope.summary.editing).toBe(false); |
|
1624 |
});
|
|
1625 |
||
3660.6.5
by Blake Rouse
Fix up the tests. |
1626 |
it("sets editing to true for summary section", function() { |
1627 |
var controller = makeController(); |
|
3660.18.3
by Blake Rouse
Don't allow editSummary or editPower to turn on editing unless its possible to edit. |
1628 |
spyOn($scope, "canEdit").and.returnValue(true); |
3660.6.5
by Blake Rouse
Fix up the tests. |
1629 |
$scope.summary.editing = false; |
1630 |
$scope.editSummary(); |
|
1631 |
expect($scope.summary.editing).toBe(true); |
|
1632 |
});
|
|
1633 |
});
|
|
1634 |
||
1635 |
describe("cancelEditSummary", function() { |
|
1636 |
||
1637 |
it("sets editing to false for summary section", function() { |
|
1638 |
var controller = makeController(); |
|
1639 |
$scope.node = node; |
|
3660.8.3
by Blake Rouse
Add more tests. |
1640 |
$scope.summary.architecture.options = [node.architecture]; |
3660.6.5
by Blake Rouse
Fix up the tests. |
1641 |
$scope.summary.editing = true; |
1642 |
$scope.cancelEditSummary(); |
|
1643 |
expect($scope.summary.editing).toBe(false); |
|
1644 |
});
|
|
1645 |
||
3660.8.8
by Blake Rouse
Fix code review. |
1646 |
it("doesnt set editing to false if invalid architecture", function() { |
3660.8.3
by Blake Rouse
Add more tests. |
1647 |
var controller = makeController(); |
1648 |
$scope.node = node; |
|
1649 |
$scope.summary.editing = true; |
|
1650 |
$scope.cancelEditSummary(); |
|
1651 |
expect($scope.summary.editing).toBe(true); |
|
1652 |
});
|
|
1653 |
||
3660.6.5
by Blake Rouse
Fix up the tests. |
1654 |
it("calls updateSummary", function() { |
1655 |
var controller = makeController(); |
|
1656 |
$scope.node = node; |
|
3660.8.3
by Blake Rouse
Add more tests. |
1657 |
$scope.summary.architecture.options = [node.architecture]; |
3660.6.5
by Blake Rouse
Fix up the tests. |
1658 |
$scope.summary.editing = true; |
1659 |
$scope.cancelEditSummary(); |
|
1660 |
});
|
|
1661 |
});
|
|
1662 |
||
1663 |
describe("saveEditSummary", function() { |
|
1664 |
||
4600.2.21
by Blake Rouse
Fix api tests up to test_machine. |
1665 |
// Configures the summary area in the scope to have a zone, and
|
1666 |
// architecture.
|
|
3660.8.8
by Blake Rouse
Fix code review. |
1667 |
function configureSummary() { |
1668 |
$scope.summary.editing = true; |
|
1669 |
$scope.summary.zone.selected = makeZone(); |
|
1670 |
$scope.summary.architecture.selected = makeName("architecture"); |
|
3942.6.1
by Blake Rouse
Use the ngTagsInput on the node details page to allow a user to add or remove tags from a node. |
1671 |
$scope.summary.tags = [ |
1672 |
{ text: makeName("tag") }, |
|
1673 |
{ text: makeName("tag") } |
|
1674 |
];
|
|
3660.8.8
by Blake Rouse
Fix code review. |
1675 |
}
|
1676 |
||
3660.8.3
by Blake Rouse
Add more tests. |
1677 |
it("does nothing if invalidArchitecture", function() { |
1678 |
var controller = makeController(); |
|
1679 |
spyOn($scope, "invalidArchitecture").and.returnValue(true); |
|
1680 |
$scope.node = node; |
|
3660.8.8
by Blake Rouse
Fix code review. |
1681 |
var editing = {}; |
1682 |
$scope.summary.editing = editing; |
|
3660.8.3
by Blake Rouse
Add more tests. |
1683 |
$scope.saveEditSummary(); |
1684 |
||
1685 |
// Editing remains the same then the method exited early.
|
|
3660.8.8
by Blake Rouse
Fix code review. |
1686 |
expect($scope.summary.editing).toBe(editing); |
3660.8.3
by Blake Rouse
Add more tests. |
1687 |
});
|
1688 |
||
1689 |
it("sets editing to false", function() { |
|
1690 |
var controller = makeController(); |
|
1691 |
spyOn($scope, "invalidArchitecture").and.returnValue(false); |
|
4600.2.21
by Blake Rouse
Fix api tests up to test_machine. |
1692 |
spyOn(MachinesManager, "updateItem").and.returnValue( |
3660.8.3
by Blake Rouse
Add more tests. |
1693 |
$q.defer().promise); |
1694 |
||
1695 |
$scope.node = node; |
|
1696 |
$scope.summary.editing = true; |
|
1697 |
$scope.saveEditSummary(); |
|
1698 |
||
3660.6.5
by Blake Rouse
Fix up the tests. |
1699 |
expect($scope.summary.editing).toBe(false); |
1700 |
});
|
|
1701 |
||
3660.8.3
by Blake Rouse
Add more tests. |
1702 |
it("calls updateItem with copy of node", function() { |
1703 |
var controller = makeController(); |
|
1704 |
spyOn($scope, "invalidArchitecture").and.returnValue(false); |
|
4600.2.21
by Blake Rouse
Fix api tests up to test_machine. |
1705 |
spyOn(MachinesManager, "updateItem").and.returnValue( |
3660.8.3
by Blake Rouse
Add more tests. |
1706 |
$q.defer().promise); |
1707 |
||
1708 |
$scope.node = node; |
|
1709 |
$scope.summary.editing = true; |
|
1710 |
$scope.saveEditSummary(); |
|
1711 |
||
4600.2.21
by Blake Rouse
Fix api tests up to test_machine. |
1712 |
var calledWithNode = MachinesManager.updateItem.calls.argsFor(0)[0]; |
3660.8.3
by Blake Rouse
Add more tests. |
1713 |
expect(calledWithNode).not.toBe(node); |
1714 |
});
|
|
1715 |
||
1716 |
it("calls updateItem with new copied values on node", function() { |
|
1717 |
var controller = makeController(); |
|
1718 |
spyOn($scope, "invalidArchitecture").and.returnValue(false); |
|
4600.2.21
by Blake Rouse
Fix api tests up to test_machine. |
1719 |
spyOn(MachinesManager, "updateItem").and.returnValue( |
3660.8.3
by Blake Rouse
Add more tests. |
1720 |
$q.defer().promise); |
1721 |
||
1722 |
$scope.node = node; |
|
3660.8.8
by Blake Rouse
Fix code review. |
1723 |
configureSummary(); |
1724 |
var newZone = $scope.summary.zone.selected; |
|
1725 |
var newArchitecture = $scope.summary.architecture.selected; |
|
3942.6.1
by Blake Rouse
Use the ngTagsInput on the node details page to allow a user to add or remove tags from a node. |
1726 |
var newTags = []; |
1727 |
angular.forEach($scope.summary.tags, function(tag) { |
|
1728 |
newTags.push(tag.text); |
|
1729 |
});
|
|
3660.8.3
by Blake Rouse
Add more tests. |
1730 |
$scope.saveEditSummary(); |
1731 |
||
4600.2.21
by Blake Rouse
Fix api tests up to test_machine. |
1732 |
var calledWithNode = MachinesManager.updateItem.calls.argsFor(0)[0]; |
3660.8.3
by Blake Rouse
Add more tests. |
1733 |
expect(calledWithNode.zone).toEqual(newZone); |
1734 |
expect(calledWithNode.zone).not.toBe(newZone); |
|
1735 |
expect(calledWithNode.architecture).toBe(newArchitecture); |
|
3942.6.1
by Blake Rouse
Use the ngTagsInput on the node details page to allow a user to add or remove tags from a node. |
1736 |
expect(calledWithNode.tags).toEqual(newTags); |
3660.8.3
by Blake Rouse
Add more tests. |
1737 |
});
|
1738 |
||
1739 |
it("logs error if not disconnected error", function() { |
|
1740 |
var controller = makeController(); |
|
1741 |
spyOn($scope, "invalidArchitecture").and.returnValue(false); |
|
1742 |
||
1743 |
var defer = $q.defer(); |
|
4600.2.21
by Blake Rouse
Fix api tests up to test_machine. |
1744 |
spyOn(MachinesManager, "updateItem").and.returnValue( |
3660.8.3
by Blake Rouse
Add more tests. |
1745 |
defer.promise); |
1746 |
||
1747 |
$scope.node = node; |
|
3660.8.8
by Blake Rouse
Fix code review. |
1748 |
configureSummary(); |
3660.8.3
by Blake Rouse
Add more tests. |
1749 |
$scope.saveEditSummary(); |
1750 |
||
1751 |
spyOn(console, "log"); |
|
1752 |
var error = makeName("error"); |
|
1753 |
defer.reject(error); |
|
1754 |
$rootScope.$digest(); |
|
1755 |
||
1756 |
expect(console.log).toHaveBeenCalledWith(error); |
|
1757 |
});
|
|
3660.6.5
by Blake Rouse
Fix up the tests. |
1758 |
});
|
1759 |
||
3660.8.4
by Blake Rouse
Merge node-details-amends. |
1760 |
describe("invalidPowerType", function() { |
1761 |
||
1762 |
it("returns true if missing power type", function() { |
|
1763 |
var controller = makeController(); |
|
1764 |
$scope.power.type = null; |
|
1765 |
expect($scope.invalidPowerType()).toBe(true); |
|
1766 |
});
|
|
1767 |
||
1768 |
it("returns false if selected power type", function() { |
|
1769 |
var controller = makeController(); |
|
1770 |
$scope.power.type = { |
|
1771 |
name: makeName("power") |
|
1772 |
};
|
|
1773 |
expect($scope.invalidPowerType()).toBe(false); |
|
1774 |
});
|
|
1775 |
});
|
|
1776 |
||
3660.6.5
by Blake Rouse
Fix up the tests. |
1777 |
describe("editPower", function() { |
1778 |
||
3660.18.3
by Blake Rouse
Don't allow editSummary or editPower to turn on editing unless its possible to edit. |
1779 |
it("doesnt sets editing to true if cannot edit", function() { |
1780 |
var controller = makeController(); |
|
1781 |
spyOn($scope, "canEdit").and.returnValue(false); |
|
1782 |
$scope.power.editing = false; |
|
1783 |
$scope.editPower(); |
|
1784 |
expect($scope.power.editing).toBe(false); |
|
1785 |
});
|
|
1786 |
||
3660.6.5
by Blake Rouse
Fix up the tests. |
1787 |
it("sets editing to true for power section", function() { |
1788 |
var controller = makeController(); |
|
3660.18.3
by Blake Rouse
Don't allow editSummary or editPower to turn on editing unless its possible to edit. |
1789 |
spyOn($scope, "canEdit").and.returnValue(true); |
3660.6.5
by Blake Rouse
Fix up the tests. |
1790 |
$scope.power.editing = false; |
1791 |
$scope.editPower(); |
|
1792 |
expect($scope.power.editing).toBe(true); |
|
1793 |
});
|
|
1794 |
});
|
|
1795 |
||
1796 |
describe("cancelEditPower", function() { |
|
1797 |
||
1798 |
it("sets editing to false for power section", function() { |
|
1799 |
var controller = makeController(); |
|
3660.8.3
by Blake Rouse
Add more tests. |
1800 |
node.power_type = makeName("power"); |
3660.6.5
by Blake Rouse
Fix up the tests. |
1801 |
$scope.node = node; |
1802 |
$scope.power.editing = true; |
|
1803 |
$scope.cancelEditPower(); |
|
1804 |
expect($scope.power.editing).toBe(false); |
|
1805 |
});
|
|
1806 |
||
3660.8.3
by Blake Rouse
Add more tests. |
1807 |
it("doesnt sets editing to false when no power_type", function() { |
1808 |
var controller = makeController(); |
|
1809 |
$scope.node = node; |
|
1810 |
$scope.power.editing = true; |
|
1811 |
$scope.cancelEditPower(); |
|
1812 |
expect($scope.power.editing).toBe(true); |
|
1813 |
});
|
|
3660.6.5
by Blake Rouse
Fix up the tests. |
1814 |
});
|
1815 |
||
1816 |
describe("saveEditPower", function() { |
|
1817 |
||
3660.8.3
by Blake Rouse
Add more tests. |
1818 |
it("does nothing if no selected power_type", function() { |
1819 |
var controller = makeController(); |
|
1820 |
$scope.node = node; |
|
3660.8.8
by Blake Rouse
Fix code review. |
1821 |
var editing = {}; |
1822 |
$scope.power.editing = editing; |
|
3660.8.3
by Blake Rouse
Add more tests. |
1823 |
$scope.power.type = null; |
1824 |
$scope.saveEditPower(); |
|
1825 |
// Editing should still be true, because the function exitted
|
|
1826 |
// early.
|
|
3660.8.8
by Blake Rouse
Fix code review. |
1827 |
expect($scope.power.editing).toBe(editing); |
3660.8.3
by Blake Rouse
Add more tests. |
1828 |
});
|
1829 |
||
1830 |
it("sets editing to false", function() { |
|
1831 |
var controller = makeController(); |
|
4600.2.21
by Blake Rouse
Fix api tests up to test_machine. |
1832 |
spyOn(MachinesManager, "updateItem").and.returnValue( |
3660.8.3
by Blake Rouse
Add more tests. |
1833 |
$q.defer().promise); |
1834 |
||
1835 |
$scope.node = node; |
|
1836 |
$scope.power.editing = true; |
|
1837 |
$scope.power.type = { |
|
1838 |
name: makeName("power") |
|
1839 |
};
|
|
1840 |
$scope.saveEditPower(); |
|
1841 |
||
3660.6.5
by Blake Rouse
Fix up the tests. |
1842 |
expect($scope.power.editing).toBe(false); |
1843 |
});
|
|
1844 |
||
3660.8.3
by Blake Rouse
Add more tests. |
1845 |
it("calls updateItem with copy of node", function() { |
1846 |
var controller = makeController(); |
|
4600.2.21
by Blake Rouse
Fix api tests up to test_machine. |
1847 |
spyOn(MachinesManager, "updateItem").and.returnValue( |
3660.8.3
by Blake Rouse
Add more tests. |
1848 |
$q.defer().promise); |
1849 |
||
1850 |
$scope.node = node; |
|
1851 |
$scope.power.editing = true; |
|
1852 |
$scope.power.type = { |
|
1853 |
name: makeName("power") |
|
1854 |
};
|
|
1855 |
$scope.saveEditPower(); |
|
1856 |
||
4600.2.21
by Blake Rouse
Fix api tests up to test_machine. |
1857 |
var calledWithNode = MachinesManager.updateItem.calls.argsFor(0)[0]; |
3660.8.3
by Blake Rouse
Add more tests. |
1858 |
expect(calledWithNode).not.toBe(node); |
1859 |
});
|
|
1860 |
||
1861 |
it("calls updateItem with new copied values on node", function() { |
|
1862 |
var controller = makeController(); |
|
4600.2.21
by Blake Rouse
Fix api tests up to test_machine. |
1863 |
spyOn(MachinesManager, "updateItem").and.returnValue( |
3660.8.3
by Blake Rouse
Add more tests. |
1864 |
$q.defer().promise); |
1865 |
||
1866 |
var newPowerType = { |
|
1867 |
name: makeName("power") |
|
1868 |
};
|
|
1869 |
var newPowerParameters = { |
|
1870 |
foo: makeName("bar") |
|
1871 |
};
|
|
1872 |
||
1873 |
$scope.node = node; |
|
1874 |
$scope.power.editing = true; |
|
1875 |
$scope.power.type = newPowerType; |
|
1876 |
$scope.power.parameters = newPowerParameters; |
|
1877 |
$scope.saveEditPower(); |
|
1878 |
||
4600.2.21
by Blake Rouse
Fix api tests up to test_machine. |
1879 |
var calledWithNode = MachinesManager.updateItem.calls.argsFor(0)[0]; |
3660.8.3
by Blake Rouse
Add more tests. |
1880 |
expect(calledWithNode.power_type).toBe(newPowerType.name); |
1881 |
expect(calledWithNode.power_parameters).toEqual( |
|
1882 |
newPowerParameters); |
|
1883 |
expect(calledWithNode.power_parameters).not.toBe( |
|
1884 |
newPowerParameters); |
|
1885 |
});
|
|
1886 |
||
1887 |
it("calls handleSaveError once updateItem is rejected", function() { |
|
1888 |
var controller = makeController(); |
|
1889 |
||
1890 |
var defer = $q.defer(); |
|
4600.2.21
by Blake Rouse
Fix api tests up to test_machine. |
1891 |
spyOn(MachinesManager, "updateItem").and.returnValue( |
3660.8.3
by Blake Rouse
Add more tests. |
1892 |
defer.promise); |
1893 |
||
1894 |
$scope.node = node; |
|
1895 |
$scope.power.editing = true; |
|
1896 |
$scope.power.type = { |
|
1897 |
name: makeName("power") |
|
1898 |
};
|
|
1899 |
$scope.power.parameters = { |
|
1900 |
foo: makeName("bar") |
|
1901 |
};
|
|
1902 |
$scope.saveEditPower(); |
|
1903 |
||
1904 |
spyOn(console, "log"); |
|
1905 |
var error = makeName("error"); |
|
1906 |
defer.reject(error); |
|
1907 |
$rootScope.$digest(); |
|
1908 |
||
1909 |
// If the error message was logged to the console then
|
|
1910 |
// handleSaveError was called.
|
|
1911 |
expect(console.log).toHaveBeenCalledWith(error); |
|
3660.6.5
by Blake Rouse
Fix up the tests. |
1912 |
});
|
1913 |
});
|
|
3660.14.10
by Blake Rouse
Add tests for node_details controller. |
1914 |
|
1915 |
describe("allowShowMoreEvents", function() { |
|
1916 |
||
1917 |
it("returns false if node is null", function() { |
|
1918 |
var controller = makeController(); |
|
1919 |
$scope.node = null; |
|
1920 |
expect($scope.allowShowMoreEvents()).toBe(false); |
|
1921 |
});
|
|
1922 |
||
3989.2.3
by Blake Rouse
Add tests. |
1923 |
it("returns false if node.events is not array", function() { |
1924 |
var controller = makeController(); |
|
1925 |
$scope.node = node; |
|
1926 |
$scope.node.events = undefined; |
|
1927 |
expect($scope.allowShowMoreEvents()).toBe(false); |
|
1928 |
});
|
|
1929 |
||
3660.14.10
by Blake Rouse
Add tests for node_details controller. |
1930 |
it("returns false if node has no events", function() { |
1931 |
var controller = makeController(); |
|
1932 |
$scope.node = node; |
|
1933 |
expect($scope.allowShowMoreEvents()).toBe(false); |
|
1934 |
});
|
|
1935 |
||
1936 |
it("returns false if node events less then the limit", function() { |
|
1937 |
var controller = makeController(); |
|
1938 |
$scope.node = node; |
|
1939 |
$scope.node.events = [ |
|
1940 |
makeEvent(), |
|
1941 |
makeEvent() |
|
1942 |
];
|
|
1943 |
$scope.events.limit = 10; |
|
1944 |
expect($scope.allowShowMoreEvents()).toBe(false); |
|
1945 |
});
|
|
1946 |
||
1947 |
it("returns false if events limit greater than 50", function() { |
|
1948 |
var controller = makeController(); |
|
1949 |
$scope.node = node; |
|
1950 |
var i; |
|
1951 |
for(i = 0; i < 50; i++) { |
|
1952 |
$scope.node.events.push(makeEvent()); |
|
1953 |
}
|
|
1954 |
$scope.events.limit = 50; |
|
1955 |
expect($scope.allowShowMoreEvents()).toBe(false); |
|
1956 |
});
|
|
1957 |
||
1958 |
it("returns true if more events than limit", function() { |
|
1959 |
var controller = makeController(); |
|
1960 |
$scope.node = node; |
|
1961 |
var i; |
|
1962 |
for(i = 0; i < 20; i++) { |
|
1963 |
$scope.node.events.push(makeEvent()); |
|
1964 |
}
|
|
1965 |
$scope.events.limit = 10; |
|
1966 |
expect($scope.allowShowMoreEvents()).toBe(true); |
|
1967 |
});
|
|
1968 |
});
|
|
1969 |
||
1970 |
describe("showMoreEvents", function() { |
|
1971 |
||
1972 |
it("increments events limit by 10", function() { |
|
1973 |
var controller = makeController(); |
|
3660.14.13
by Blake Rouse
Fix lint. |
1974 |
$scope.showMoreEvents(); |
3660.14.10
by Blake Rouse
Add tests for node_details controller. |
1975 |
expect($scope.events.limit).toBe(20); |
3660.14.13
by Blake Rouse
Fix lint. |
1976 |
$scope.showMoreEvents(); |
3660.14.10
by Blake Rouse
Add tests for node_details controller. |
1977 |
expect($scope.events.limit).toBe(30); |
1978 |
});
|
|
1979 |
});
|
|
1980 |
||
1981 |
describe("getEventText", function() { |
|
1982 |
||
1983 |
it("returns just event type description without dash", function() { |
|
1984 |
var controller = makeController(); |
|
1985 |
var evt = makeEvent(); |
|
1986 |
delete evt.description; |
|
1987 |
expect($scope.getEventText(evt)).toBe(evt.type.description); |
|
1988 |
});
|
|
1989 |
||
1990 |
it("returns event type description with event description", |
|
1991 |
function() { |
|
1992 |
var controller = makeController(); |
|
1993 |
var evt = makeEvent(); |
|
1994 |
expect($scope.getEventText(evt)).toBe( |
|
1995 |
evt.type.description + " - " + evt.description); |
|
1996 |
});
|
|
1997 |
});
|
|
1998 |
||
4929.4.2
by newell.jensen at canonical
Review fixes. Update tests. |
1999 |
describe("getPowerEventError", function() { |
2000 |
||
2001 |
it("returns event if there is a power event error", function() { |
|
2002 |
var controller = makeController(); |
|
2003 |
var evt = makeEvent(); |
|
2004 |
evt.type.level = "warning"; |
|
2005 |
evt.type.description = "Failed to query node's BMC"; |
|
2006 |
$scope.node = node; |
|
2007 |
$scope.node.events = [ |
|
2008 |
makeEvent(), |
|
2009 |
evt
|
|
2010 |
];
|
|
2011 |
expect($scope.getPowerEventError()).toBe(evt); |
|
2012 |
});
|
|
2013 |
||
2014 |
it("returns nothing if there is no power event error", function() { |
|
2015 |
var controller = makeController(); |
|
2016 |
var evt_info = makeEvent(); |
|
2017 |
var evt_error = makeEvent(); |
|
2018 |
evt_info.type.level = "info"; |
|
2019 |
evt_info.type.description = "Queried node's BMC"; |
|
2020 |
evt_error.type.level = "warning"; |
|
2021 |
evt_error.type.description = "Failed to query node's BMC"; |
|
2022 |
$scope.node = node; |
|
2023 |
$scope.node.events = [ |
|
2024 |
makeEvent(), |
|
2025 |
evt_info, |
|
2026 |
evt_error
|
|
2027 |
];
|
|
2028 |
expect($scope.getPowerEventError()).toBe(); |
|
2029 |
});
|
|
2030 |
});
|
|
2031 |
||
2032 |
describe("hasPowerEventError", function() { |
|
4929.4.1
by newell.jensen at canonical
Do a power query when the power parameters are saved in the UI and if there is an error, display it. Added power querying to the event log. |
2033 |
|
2034 |
it("returns true if last event is an error", function() { |
|
2035 |
var controller = makeController(); |
|
2036 |
var evt = makeEvent(); |
|
2037 |
evt.type.level = "warning"; |
|
2038 |
evt.type.description = "Failed to query node's BMC"; |
|
2039 |
$scope.node = node; |
|
2040 |
$scope.node.events = [evt]; |
|
4929.4.2
by newell.jensen at canonical
Review fixes. Update tests. |
2041 |
expect($scope.hasPowerEventError()).toBe(true); |
4929.4.1
by newell.jensen at canonical
Do a power query when the power parameters are saved in the UI and if there is an error, display it. Added power querying to the event log. |
2042 |
});
|
2043 |
||
2044 |
it("returns false if last event is not an error", function() { |
|
2045 |
var controller = makeController(); |
|
2046 |
$scope.node = node; |
|
4929.4.2
by newell.jensen at canonical
Review fixes. Update tests. |
2047 |
$scope.node.events = [makeEvent()]; |
2048 |
expect($scope.hasPowerEventError()).toBe(false); |
|
4929.4.1
by newell.jensen at canonical
Do a power query when the power parameters are saved in the UI and if there is an error, display it. Added power querying to the event log. |
2049 |
});
|
2050 |
});
|
|
2051 |
||
4929.4.2
by newell.jensen at canonical
Review fixes. Update tests. |
2052 |
describe("getPowerEventErrorText", function() { |
4929.4.1
by newell.jensen at canonical
Do a power query when the power parameters are saved in the UI and if there is an error, display it. Added power querying to the event log. |
2053 |
|
2054 |
it("returns just empty string", function() { |
|
2055 |
var controller = makeController(); |
|
2056 |
$scope.node = node; |
|
4929.4.2
by newell.jensen at canonical
Review fixes. Update tests. |
2057 |
$scope.node.events = [makeEvent()]; |
2058 |
expect($scope.getPowerEventErrorText()).toBe(""); |
|
4929.4.1
by newell.jensen at canonical
Do a power query when the power parameters are saved in the UI and if there is an error, display it. Added power querying to the event log. |
2059 |
});
|
2060 |
||
2061 |
it("returns event description", function() { |
|
2062 |
var controller = makeController(); |
|
2063 |
var evt = makeEvent(); |
|
2064 |
evt.type.level = "warning"; |
|
2065 |
evt.type.description = "Failed to query node's BMC"; |
|
2066 |
$scope.node = node; |
|
2067 |
$scope.node.events = [evt]; |
|
4929.4.2
by newell.jensen at canonical
Review fixes. Update tests. |
2068 |
expect($scope.getPowerEventErrorText()).toBe(evt.description); |
4929.4.1
by newell.jensen at canonical
Do a power query when the power parameters are saved in the UI and if there is an error, display it. Added power querying to the event log. |
2069 |
});
|
2070 |
});
|
|
2071 |
||
3660.14.10
by Blake Rouse
Add tests for node_details controller. |
2072 |
describe("machineOutputViewChanged", function() { |
2073 |
||
2074 |
it("sets showSummaryToggle to false if no selectedView", function() { |
|
2075 |
var controller = makeController(); |
|
2076 |
$scope.machine_output.selectedView = null; |
|
2077 |
$scope.machineOutputViewChanged(); |
|
2078 |
expect($scope.machine_output.showSummaryToggle).toBe(false); |
|
2079 |
});
|
|
2080 |
||
2081 |
it("sets showSummaryToggle to false if not summary view", function() { |
|
2082 |
var controller = makeController(); |
|
2083 |
$scope.machine_output.selectedView = { |
|
2084 |
name: "output" |
|
2085 |
};
|
|
2086 |
$scope.machineOutputViewChanged(); |
|
2087 |
expect($scope.machine_output.showSummaryToggle).toBe(false); |
|
2088 |
});
|
|
2089 |
||
2090 |
it("sets showSummaryToggle to true if summary view", function() { |
|
2091 |
var controller = makeController(); |
|
2092 |
$scope.machine_output.selectedView = { |
|
2093 |
name: "summary" |
|
2094 |
};
|
|
2095 |
$scope.machineOutputViewChanged(); |
|
2096 |
expect($scope.machine_output.showSummaryToggle).toBe(true); |
|
2097 |
});
|
|
2098 |
});
|
|
2099 |
||
2100 |
describe("getSummaryData", function() { |
|
2101 |
||
2102 |
it("returns blank string if node is null", function() { |
|
2103 |
var controller = makeController(); |
|
2104 |
expect($scope.getSummaryData()).toBe(""); |
|
2105 |
});
|
|
2106 |
||
2107 |
it("returns summary_xml when summaryType equal xml", function() { |
|
2108 |
var controller = makeController(); |
|
2109 |
$scope.node = makeNode(); |
|
2110 |
var summary_xml = {}; |
|
2111 |
$scope.node.summary_xml = summary_xml; |
|
2112 |
$scope.machine_output.summaryType = "xml"; |
|
3752.1.1
by Blake Rouse
Fix missing newline for commissioning summary and installation output. Fix not updating title in NodeResultController. |
2113 |
expect($scope.getSummaryData()).toBe("\n" + summary_xml); |
3660.14.10
by Blake Rouse
Add tests for node_details controller. |
2114 |
});
|
2115 |
||
2116 |
it("returns summary_yaml when summaryType equal yaml", function() { |
|
2117 |
var controller = makeController(); |
|
2118 |
$scope.node = makeNode(); |
|
2119 |
var summary_yaml = {}; |
|
2120 |
$scope.node.summary_yaml = summary_yaml; |
|
2121 |
$scope.machine_output.summaryType = "yaml"; |
|
3752.1.1
by Blake Rouse
Fix missing newline for commissioning summary and installation output. Fix not updating title in NodeResultController. |
2122 |
expect($scope.getSummaryData()).toBe("\n" + summary_yaml); |
3660.14.10
by Blake Rouse
Add tests for node_details controller. |
2123 |
});
|
2124 |
});
|
|
2125 |
||
2126 |
describe("getInstallationData", function() { |
|
2127 |
||
2128 |
it("returns blank string if node is null", function() { |
|
2129 |
var controller = makeController(); |
|
2130 |
expect($scope.getInstallationData()).toBe(""); |
|
2131 |
});
|
|
2132 |
||
3989.2.3
by Blake Rouse
Add tests. |
2133 |
it("returns blank string if installation results not an array", |
2134 |
function() { |
|
2135 |
var controller = makeController(); |
|
2136 |
$scope.node = makeNode(); |
|
2137 |
$scope.node.installation_results = undefined; |
|
2138 |
expect($scope.getInstallationData()).toBe(""); |
|
2139 |
});
|
|
2140 |
||
3660.14.10
by Blake Rouse
Add tests for node_details controller. |
2141 |
it("returns blank string if no installation results", function() { |
2142 |
var controller = makeController(); |
|
2143 |
$scope.node = makeNode(); |
|
2144 |
expect($scope.getInstallationData()).toBe(""); |
|
2145 |
});
|
|
2146 |
||
2147 |
it("returns first installation result data", function() { |
|
2148 |
var controller = makeController(); |
|
2149 |
$scope.node = makeNode(); |
|
2150 |
var install_result = {}; |
|
2151 |
$scope.node.installation_results.push({ |
|
5755.3.1
by Lee Trager
Add test result section to the UI. |
2152 |
output: install_result |
3660.14.10
by Blake Rouse
Add tests for node_details controller. |
2153 |
});
|
2154 |
$scope.node.installation_results.push({ |
|
5755.3.1
by Lee Trager
Add test result section to the UI. |
2155 |
output: {} |
3660.14.10
by Blake Rouse
Add tests for node_details controller. |
2156 |
});
|
3752.1.1
by Blake Rouse
Fix missing newline for commissioning summary and installation output. Fix not updating title in NodeResultController. |
2157 |
expect($scope.getInstallationData()).toBe("\n" + install_result); |
3660.14.10
by Blake Rouse
Add tests for node_details controller. |
2158 |
});
|
2159 |
});
|
|
4828.1.1
by Blake Rouse
Fix the service status on the controllers page to include success and degraded state. Add controller status to the controllers listing. |
2160 |
|
2161 |
describe("getServiceClass", function() { |
|
2162 |
||
2163 |
it("returns 'none' if null", function() { |
|
2164 |
var controller = makeController(); |
|
2165 |
expect($scope.getServiceClass(null)).toBe("none"); |
|
2166 |
});
|
|
2167 |
||
2168 |
it("returns 'success' when running", function() { |
|
2169 |
var controller = makeController(); |
|
2170 |
expect($scope.getServiceClass({ |
|
2171 |
status: "running" |
|
2172 |
})).toBe("success"); |
|
2173 |
});
|
|
2174 |
||
2175 |
it("returns 'error' when dead", function() { |
|
2176 |
var controller = makeController(); |
|
2177 |
expect($scope.getServiceClass({ |
|
2178 |
status: "dead" |
|
2179 |
})).toBe("error"); |
|
2180 |
});
|
|
2181 |
||
4828.2.1
by Blake Rouse
Fix incorrect spelling of degraded in the services model. |
2182 |
it("returns 'warning' when degraded", function() { |
4828.1.1
by Blake Rouse
Fix the service status on the controllers page to include success and degraded state. Add controller status to the controllers listing. |
2183 |
var controller = makeController(); |
2184 |
expect($scope.getServiceClass({ |
|
4828.2.1
by Blake Rouse
Fix incorrect spelling of degraded in the services model. |
2185 |
status: "degraded" |
4828.1.1
by Blake Rouse
Fix the service status on the controllers page to include success and degraded state. Add controller status to the controllers listing. |
2186 |
})).toBe("warning"); |
2187 |
});
|
|
2188 |
||
2189 |
it("returns 'none' for anything else", function() { |
|
2190 |
var controller = makeController(); |
|
2191 |
expect($scope.getServiceClass({ |
|
2192 |
status: makeName("status") |
|
2193 |
})).toBe("none"); |
|
2194 |
});
|
|
2195 |
});
|
|
3660.6.4
by Blake Rouse
Add tests for node details controller. |
2196 |
});
|