Skip to content

Commit

Permalink
Additional stability improvements for CreatePipelineRun tests
Browse files Browse the repository at this point in the history
  • Loading branch information
AlanGreene authored and tekton-robot committed Jan 24, 2020
1 parent d74f4f2 commit 312a9be
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 deletions.
8 changes: 5 additions & 3 deletions src/containers/CreatePipelineRun/CreatePipelineRun.js
Original file line number Diff line number Diff line change
Expand Up @@ -585,9 +585,11 @@ CreatePipelineRun.defaultProps = {
onSuccess: () => {}
};

const mapStateToProps = (state, ownProps) => {
/* istanbul ignore next */
function mapStateToProps(state, ownProps) {
const { pipelineRef, namespace } = ownProps;
return parsePipelineInfo(state, pipelineRef, namespace);
};
}

export default connect(mapStateToProps)(injectIntl(CreatePipelineRun));
export const CreatePipelineRunWithIntl = injectIntl(CreatePipelineRun);
export default connect(mapStateToProps)(CreatePipelineRunWithIntl);
22 changes: 16 additions & 6 deletions src/containers/CreatePipelineRun/CreatePipelineRun.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import thunk from 'redux-thunk';
import configureStore from 'redux-mock-store';
import { ALL_NAMESPACES } from '@tektoncd/dashboard-utils';
import { renderWithIntl, rerenderWithIntl } from '../../utils/test';
import CreatePipelineRun from './CreatePipelineRun';
import { CreatePipelineRunWithIntl as CreatePipelineRun } from './CreatePipelineRun';
import * as API from '../../api';
import * as store from '../../store';
import * as reducers from '../../reducers';
Expand Down Expand Up @@ -414,14 +414,24 @@ describe('CreatePipelineRun', () => {
testPipelineSpec('id-pipeline-2', queryByText, queryByValue);
});

it('renders pipeline controlled', () => {
it('renders pipeline controlled', async () => {
// Display with pipeline-1 selected
const mockTestStore = mockStore(testStore);
const { rerender, queryByText, queryByValue } = renderWithIntl(

const { resources, params } = pipelinesTestStore.pipelines.byId[
'id-pipeline-1'
].spec;
const { getByText, queryByText, queryByValue, rerender } = renderWithIntl(
<Provider store={mockTestStore}>
<CreatePipelineRun {...props} pipelineRef="pipeline-1" />
<CreatePipelineRun
{...props}
resourceSpecs={resources}
paramSpecs={params}
pipelineRef="pipeline-1"
/>
</Provider>
);
await waitForElement(() => getByText(/pipeline-1/i));
expect(queryByText(/namespace-1/i)).toBeFalsy();
expect(queryByText(/pipeline-1/i)).toBeTruthy();
// Verify spec details are displayed
Expand Down Expand Up @@ -660,12 +670,12 @@ describe('CreatePipelineRun', () => {
});

it('handles error getting pipeline controlled', () => {
jest.spyOn(reducers, 'getPipeline').mockImplementation(() => null);
const { queryByText } = renderWithIntl(
<Provider store={mockStore(testStore)}>
<CreatePipelineRun {...props} pipelineRef="pipeline-1" />
<CreatePipelineRun {...props} pipelineError pipelineRef="pipeline-1" />
</Provider>
);

expect(queryByText(/error retrieving pipeline information/i)).toBeTruthy();
});
});

0 comments on commit 312a9be

Please sign in to comment.