Skip to content
This repository has been archived by the owner on Aug 30, 2024. It is now read-only.

Commit

Permalink
GUI-2809 test various interactions between widgets on instances tab
Browse files Browse the repository at this point in the history
  • Loading branch information
dkavanagh committed Nov 11, 2016
1 parent 0a17031 commit afec641
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 5 deletions.
51 changes: 48 additions & 3 deletions eucaconsole/static/js/jasmine-spec/elb-wizard/spec_elb_wizard.js
Original file line number Diff line number Diff line change
Expand Up @@ -268,9 +268,9 @@ describe('ELB Wizard Module', function () {
$templateCache.put('/_template/elbs/wizard/instances', template);
}));

var $controller, $routeParams, controller;
var $controller, $scope, $routeParams, controller;
beforeEach(inject(function (_$controller_, _$routeParams_) {
var $scope = $rootScope.$new();
$scope = $rootScope.$new();

$controller = _$controller_;
$routeParams = _$routeParams_;
Expand All @@ -287,9 +287,10 @@ describe('ELB Wizard Module', function () {
{availability_zone: 'one', subnet_id: 'subnet-10000001', selected: false},
{availability_zone: 'two', subnet_id: 'subnet-10000002', selected: false}
];
controller.vpcNetwork = 'vpc-abcdefg';
});

it('should deselect instance', function() {
it('should deselect instance when zone deselected', function() {
// select 1 from each zone
controller.instances[0].selected = true;
controller.instances[2].selected = true;
Expand All @@ -303,6 +304,50 @@ describe('ELB Wizard Module', function () {
expect(controller.instances[1].selected).toBe(false);
expect(controller.instances[2].selected).toBe(false);
});

it('should deselect instance when subnet deselected', function() {
// select 1 from each zone
controller.instances[0].selected = true;
controller.instances[2].selected = true;
// set 2 subnets in model
var subnets = [
{id:'subnet-10000001', label:'subnet1'},
{id:'subnet-10000002', label:'subnet2'}
];
controller.handleDeselectionDueToSubnets([subnets[0]], subnets);
expect(controller.instances[0].selected).toBe(true);
expect(controller.instances[1].selected).toBe(false);
expect(controller.instances[2].selected).toBe(false);
});

it('should select zone when instance selected', function() {
controller.vpcNetwork = 'None';
// set 2 zones in model
controller.availabilityZoneChoices = [
{id:'one', label:'one'},
{id:'two', label:'two'}
];
controller.availabilityZones = [];
// select 1 instance
controller.instances[0].selected = true;
controller.handleInstanceSelectionChange(controller.instances, controller.instances);
expect(controller.availabilityZones.length).toEqual(1);
expect(controller.availabilityZones[0].label).toEqual('one : 1 instances');
});

it('should select subnet when instance selected', function() {
// set 2 subnets in model
controller.vpcSubnetChoices = [
{id:'subnet-10000001', label:'subnet1', labelBak:'subnet1'},
{id:'subnet-10000002', label:'subnet2', labelBak:'subnet2'}
];
controller.vpcSubnets = [];
// select 1 instance
controller.instances[0].selected = true;
controller.handleInstanceSelectionChange(controller.instances, controller.instances);
expect(controller.vpcSubnets.length).toEqual(1);
expect(controller.vpcSubnets[0].label).toEqual('subnet1 : 1 instances');
});
});

describe('Advanced tab controller', function () {
Expand Down
2 changes: 1 addition & 1 deletion eucaconsole/static/js/pages/elb-wizard/instances.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ angular.module('ELBWizard')
vm.handleInstanceSelectionChange(newval, oldval);
}, true);
vm.handleInstanceSelectionChange = function(newval, oldval) {
if (vm.vpcNetwork == 'None') {
if (vm.vpcNetwork === 'None') {
// update labels, accumulate zones for selection
var zonesToSelect = [];
vm.availabilityZoneChoices.forEach(function (zone) {
Expand Down
2 changes: 1 addition & 1 deletion eucaconsole/static/js/pages/elb-wizard/wizard.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ angular.module('ELBWizard', [
certsAvailable: [],
policies: [],
values: {
vpcNetwork: 'vpc-d318f491', //'None',
vpcNetwork: 'None',
vpcNetworkChoices: [],
vpcSubnets: [],
vpcSubnetChoices: [],
Expand Down

0 comments on commit afec641

Please sign in to comment.