Tabs may not appear in angular instance wizard

In the launch instance wizard, when a specific tab is disabled
(by example not matching the required policy) then some other
tabs may not be displayed.

After a long analysis :
Each tabs resolved itself if it should or shouldn't be displayed
(ready or not). But at the first rejection (first tab ready=false),
the wizard will display all "ready" tabs without waiting for other
tabs to be ready or not.
If all tabs had been resolved before the first reject, the display
is correct, but sometimes when the reject finishes first, a lot of
tabs are missing.

This bugs is not current because I think it is not common to hide tabs.

Closes-Bug: #1752604
Change-Id: I67f96092d9f82374087fc0c87b857292e188b675
This commit is contained in:
David Gutman 2018-03-07 14:09:57 +01:00
parent d1b4b0f4b0
commit f4f497246d
4 changed files with 32 additions and 10 deletions

View File

@ -208,8 +208,8 @@
if (step.checkReadiness) {
var promise = step.checkReadiness();
stepReadyPromises.push(promise);
promise.then(function() {
step.ready = true;
promise.then(function(isReady) {
step.ready = isReady;
});
}
});

View File

@ -225,9 +225,9 @@
expect(checkedStep.checkReadiness).toHaveBeenCalled();
});
it("should remove steps when readiness is false", function() {
it("should remove steps when readiness doesn't resolve with true parameter", function() {
var checkReadinessPromises = [$q.defer(), $q.defer(), $q.defer(), $q.defer()];
var checkReadinessPromises = [$q.defer(), $q.defer(), $q.defer(), $q.defer(), $q.defer()];
$scope.workflow = {
steps: [
@ -247,20 +247,25 @@
{
id: 'five',
checkReadiness: function() { return checkReadinessPromises[3].promise; }
},
{
id: 'six',
checkReadiness: function() { return checkReadinessPromises[4].promise; }
}
]
};
checkReadinessPromises[0].reject();
checkReadinessPromises[1].resolve();
checkReadinessPromises[1].resolve(true);
checkReadinessPromises[2].reject();
checkReadinessPromises[3].resolve();
checkReadinessPromises[3].resolve(false);
checkReadinessPromises[4].resolve(true);
$scope.$apply();
expect($scope.steps.length).toBe(3);
expect($scope.steps[0].id).toBe('one');
expect($scope.steps[1].id).toBe('three');
expect($scope.steps[2].id).toBe('five');
expect($scope.steps[2].id).toBe('six');
});
it('should pass result of submit function on to close function', function () {

View File

@ -87,7 +87,13 @@
}
if (promises.length > 0) {
step.checkReadiness = function () {
return $q.all(promises);
return $q.all(promises).then(function() {
// all promises have succeeded, return the readiness status to true
return true;
}, function() {
// at least one promise has failed, return the readiness status to false
return false;
});
};
}
}

View File

@ -67,7 +67,7 @@
expect(novaExtensionsService.ifNameEnabled).toHaveBeenCalledWith('foo-novaExtension');
});
it('step checkReadiness function returns correct results', function() {
it('step checkReadiness function returns true when promise is resolved', function() {
decoratorService(spec);
var readinessResult;
deferred.resolve('foo');
@ -75,7 +75,18 @@
readinessResult = result;
});
$scope.$apply();
expect(readinessResult).toEqual(['foo']);
expect(readinessResult).toEqual(true);
});
it('step checkReadiness function returns false when promise is rejected', function() {
decoratorService(spec);
var readinessResult;
deferred.reject();
steps[1].checkReadiness().then(function(result) {
readinessResult = result;
});
$scope.$apply();
expect(readinessResult).toEqual(false);
});
});