Files
ironic-ui/ironic_ui/static/dashboard/admin/ironic/node-details/node-details.controller.spec.js
Peter Piela eeaa2ecf06 Incorporate driver-validation into node-detail panels
Driver validation information has been added to the node-details/
configuration page. The driver validation information is located
in close proximity to the driver properties section, and will
update as property values are changed.

To accomodate the driver validation information the following
changes have been made to the layout and organization of the
node-details/configuration page:
(1) The list of Extra properties has been removed from the General
section and is now treated as a separate collection in a similar
manner to Properties and Instance_info.
(2) The new grid layout is:
  Row 1 (top) General, Ports
  Row 2 Driver Info, Driver Validation
  Row 3 Properties, Instance Info
  Row 4 Extra
(3) The list of instance_info items displayed for the pxe_ssh
driver has been enhanced.

Change-Id: I0ba8ac0fc1e4a1b0f2f4b03b738f56ed380a11c7
2016-11-21 13:32:22 -05:00

143 lines
4.2 KiB
JavaScript
Executable File

/*
* Copyright 2015 Hewlett Packard Enterprise Development Company LP
* Copyright 2016 Cray Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
(function () {
'use strict';
describe('horizon.dashboard.admin.ironic.node-details', function () {
var ctrl, $q;
var nodeUuid = "0123abcd-0123-4567-abcd-0123456789ab";
var nodeName = "herp";
var numPorts = 2;
function portUuid(nodeUuid, index) {
return '' + index + index + nodeUuid.substring(2);
}
function createPort(nodeUuid, index, extra) {
var uuid = portUuid(nodeUuid, index);
var port = {uuid: uuid, id: uuid};
if (angular.isDefined(extra)) {
port.extra = extra;
}
return port;
}
function createNode(name, uuid) {
return {name: name, uuid: uuid, id: uuid};
}
var ironicAPI = {
getNode: function (uuid) {
var node = createNode(nodeName, uuid);
return $q.when({data: node});
},
getPortsWithNode: function (uuid) {
var ports = [];
for (var i = 0; i < numPorts; i++) {
ports.push(createPort(uuid, i));
}
return $q.when({data: {items: ports}});
},
validateNode: function() {
return $q.when({});
}
};
beforeEach(module('horizon.dashboard.admin.ironic'));
beforeEach(module(function($provide) {
$provide.value('horizon.app.core.openstack-service-api.ironic',
ironicAPI);
}));
beforeEach(module(function($provide) {
$provide.value('horizon.framework.widgets.toast.service',
{});
}));
beforeEach(module(function($provide) {
$provide.value('horizon.dashboard.admin.ironic.edit-node.service',
{});
}));
beforeEach(module(function($provide) {
$provide.value('horizon.dashboard.admin.ironic.maintenance.service',
{});
}));
beforeEach(inject(function ($injector, _$rootScope_, _$location_) {
var scope = _$rootScope_.$new();
$q = $injector.get('$q');
var controller = $injector.get('$controller');
var $location = _$location_;
$location.path('/admin/ironic/' + nodeUuid + '/');
ctrl = controller(
'horizon.dashboard.admin.ironic.NodeDetailsController',
{$scope: scope,
$location: $location,
'horizon.dashboard.admin.ironic.actions': {}});
scope.$apply();
}));
it('should be defined', function () {
expect(ctrl).toBeDefined();
});
it('should have a basePath', function () {
expect(ctrl.basePath).toBeDefined();
});
it('should have a node', function () {
expect(ctrl.node).toBeDefined();
expect(ctrl.node).toEqual(createNode(nodeName, nodeUuid));
});
it('should have ports', function () {
expect(ctrl.portsSrc).toBeDefined();
expect(ctrl.portsSrc.length).toEqual(numPorts);
var ports = [];
for (var i = 0; i < numPorts; i++) {
ports.push(createPort(ctrl.node.uuid, i));
}
expect(ctrl.portsSrc).toEqual(ports);
});
it('should have a uuid regular expression pattern', function () {
expect(ctrl.re_uuid).toBeDefined();
});
it('should have an isUuid function', function () {
expect(ctrl.isUuid).toBeDefined();
expect(ctrl.isUuid(ctrl.node.uuid)).toEqual(true);
expect(ctrl.isUuid("not a uuid")).toEqual(false);
});
it('should have a getVifPortId function', function () {
expect(ctrl.getVifPortId).toBeDefined();
expect(ctrl.getVifPortId(createPort(ctrl.node.uuid, 1))).toEqual("");
var extra = {vif_port_id: "port_uuid"};
expect(ctrl.getVifPortId(createPort(ctrl.node.uuid, 1, extra))).
toEqual("port_uuid");
});
});
})();