Skip to content

Commit

Permalink
fix(provider/cf): Fix provider selection for resize stage in pipeline (
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonjchu authored and jkschneider committed Apr 3, 2019
1 parent 2039b34 commit 476e0dd
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ export interface ICloudfoundryResizeAsgStageConfigState {
application: Application;
capacity?: Partial<ICapacity>;
cloudProvider?: string;
cloudProviderType?: string;
credentials: string;
diskQuota?: number;
instanceCount?: number;
Expand Down Expand Up @@ -59,7 +58,6 @@ export class CloudfoundryResizeAsgStageConfig extends React.Component<
action: 'scale_exact',
capacity: props.stage.capacity,
cloudProvider: 'cloudfoundry',
cloudProviderType: props.stage.cloudProvider,
diskQuota: props.stage.diskQuota || 1024,
instanceCount: props.stage.instanceCount || 1,
interestingHealthProviderNames: interestingHealthProviderNames,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ describe('<AccountRegionClusterSelector />', () => {
it('retrieves the correct list of regions when account is changed', () => {
let credentials = '';
let region = 'SHOULD-CHANGE';
let regions = ['SHOULD-CHANGE'];
let cluster = 'SHOULD-CHANGE';
const accountRegionClusterProps: IAccountRegionClusterSelectorProps = {
accounts: [
{
Expand All @@ -107,6 +109,8 @@ describe('<AccountRegionClusterSelector />', () => {
onComponentUpdate: (value: any) => {
credentials = value.credentials;
region = value.region;
regions = value.regions;
cluster = value.cluster;
},
component: {
cluster: 'app-stack-detailOne',
Expand Down Expand Up @@ -138,12 +142,15 @@ describe('<AccountRegionClusterSelector />', () => {
expect(component.state().availableRegions.length).toBe(1, 'number of available regions does not match');
expect(component.state().availableRegions).toContain('region-two');
expect(component.state().clusters.length).toBe(0, 'number of clusters does not match');
expect(region).toEqual('');
expect(region).toEqual('', 'selected region is not cleared');
expect(regions.length).toBe(0, 'selected regions list is not cleared');
expect(credentials).toContain('account-name-two');
expect(cluster).toBeUndefined('selected cluster is not cleared');
});

it('retrieves the correct list of clusters when the selector is multi-region and the region is changed', () => {
let regions: string[] = [];
let cluster = 'SHOULD-CHANGE';
const accountRegionClusterProps: IAccountRegionClusterSelectorProps = {
accounts: [
{
Expand All @@ -161,11 +168,12 @@ describe('<AccountRegionClusterSelector />', () => {
],
application,
cloudProvider: 'cloud-provider',
clusterField: 'newCluster',
onComponentUpdate: (value: any) => {
regions = value.regions;
cluster = value.newCluster;
},
component: {
cluster: 'app-stack-detailOne',
credentials: 'account-name-one',
regions: ['region-one'],
},
Expand Down Expand Up @@ -194,6 +202,7 @@ describe('<AccountRegionClusterSelector />', () => {
expect(component.state().clusters).toContain('app-stack-detailOne');
expect(component.state().clusters).toContain('app-stack-detailThree');
expect(component.state().clusters).toContain('app-stack-detailFour');
expect(cluster).toBeUndefined('selected cluster is not cleared');
expect(regions.length).toBe(2);
expect(regions).toContain('region-one');
expect(regions).toContain('region-three');
Expand Down Expand Up @@ -293,10 +302,10 @@ describe('<AccountRegionClusterSelector />', () => {
expect(component.state().clusters).toContain('app-stack-detailOne');
expect(component.state().clusters).toContain('app-stack-detailThree');

const accountSelectComponent = component.find('Select[name="newCluster"] .Select-control input');
accountSelectComponent.simulate('mouseDown');
accountSelectComponent.simulate('change', { target: { value: 'app-stack-detailThree' } });
accountSelectComponent.simulate('keyDown', { keyCode: 9, key: 'Tab' });
const clusterSelectComponent = component.find('Select[name="newCluster"] .Select-control input');
clusterSelectComponent.simulate('mouseDown');
clusterSelectComponent.simulate('change', { target: { value: 'app-stack-detailThree' } });
clusterSelectComponent.simulate('keyDown', { keyCode: 9, key: 'Tab' });
$scope.$digest();

expect(cluster).toBe('app-stack-detailThree');
Expand Down

0 comments on commit 476e0dd

Please sign in to comment.