Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(appengine): fix rendering of StageArtifactSelector when artifacts…
… are created (#8516) * fix for GAE artifacts * WIP tests * fixeded testssed * fix(appengine): fix rendering of StageArtifactSelector when artifacts are created * fix(appengine): fix rendering of StageArtifactSelector when artifacts are created * fix(appengine): included support for expected artifact within deploy stage Co-authored-by: Dan Peach <daniel.peach@armory.io> Co-authored-by: Kevin Woo <kevinawoo@gmail.com>
- Loading branch information
1 parent
fbe0e54
commit 1a20a4a
Showing
3 changed files
with
114 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
96 changes: 96 additions & 0 deletions
96
...cripts/modules/appengine/src/serverGroup/configure/wizard/configFileArtifactList.spec.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
import React from 'react'; | ||
import { mock } from 'angular'; | ||
import { mount } from 'enzyme'; | ||
|
||
import { API, IArtifactAccount, IArtifactAccountPair, StageArtifactSelector } from '@spinnaker/core'; | ||
import { mockDeployStage, mockPipeline } from '@spinnaker/mocks'; | ||
import { ConfigFileArtifactList } from './ConfigFileArtifactList'; | ||
|
||
describe('<ConfigFileArtifactList/>', () => { | ||
let $http: ng.IHttpBackendService; | ||
beforeEach( | ||
mock.inject(function($httpBackend: ng.IHttpBackendService) { | ||
$http = $httpBackend; | ||
}), | ||
); | ||
|
||
it('renders empty children when null/empty artifacts are passed in', () => { | ||
const configArtifacts: IArtifactAccountPair[] = []; | ||
const wrapper = mount( | ||
<ConfigFileArtifactList | ||
configArtifacts={configArtifacts} | ||
pipeline={mockPipeline} | ||
stage={mockDeployStage} | ||
updateConfigArtifacts={() => {}} | ||
/>, | ||
); | ||
expect(wrapper.find(StageArtifactSelector).length).toBe(0); | ||
}); | ||
|
||
it('renders 2 children of StageArtifactSelector when 2 artifacts are passed in', () => { | ||
const body: IArtifactAccount[] = [ | ||
{ | ||
name: 'http-acc', | ||
types: ['http'], | ||
}, | ||
]; | ||
$http.expectGET(`${API.baseUrl}/artifacts/credentials`).respond(200, body); | ||
|
||
const configArtifacts = [ | ||
{ | ||
account: 'http-acc', | ||
id: '123abc', | ||
artifact: { | ||
id: '123abc', | ||
}, | ||
}, | ||
{ | ||
account: 'http-acc', | ||
id: '1234abcd', | ||
artifact: { | ||
id: '1234abcd', | ||
}, | ||
}, | ||
]; | ||
|
||
const wrapper = mount( | ||
<ConfigFileArtifactList | ||
configArtifacts={configArtifacts} | ||
pipeline={mockPipeline} | ||
stage={mockDeployStage} | ||
updateConfigArtifacts={() => {}} | ||
/>, | ||
); | ||
expect(wrapper.find(StageArtifactSelector).length).toBe(2); | ||
$http.flush(); | ||
}); | ||
|
||
fit('renders 1 children of StageArtifactSelector when 1 expectedArtifacts are passed in', () => { | ||
const body: IArtifactAccount[] = [ | ||
{ | ||
name: 'http-acc', | ||
types: ['http'], | ||
}, | ||
]; | ||
$http.expectGET(`${API.baseUrl}/artifacts/credentials`).respond(200, body); | ||
|
||
// artifact intentionally left null indicating an expected artifact | ||
const configArtifacts = [ | ||
{ | ||
account: 'http-acc', | ||
id: '123abc', | ||
}, | ||
]; | ||
|
||
const wrapper = mount( | ||
<ConfigFileArtifactList | ||
configArtifacts={configArtifacts} | ||
pipeline={mockPipeline} | ||
stage={mockDeployStage} | ||
updateConfigArtifacts={() => {}} | ||
/>, | ||
); | ||
expect(wrapper.find(StageArtifactSelector).length).toBe(1); | ||
$http.flush(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters