Skip to content

Commit c531d19

Browse files
committed
fix: do not show link if onConfigureConnection not provided
1 parent 9727f2d commit c531d19

File tree

2 files changed

+42
-3
lines changed

2 files changed

+42
-3
lines changed

lib/components/Output/Output.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,14 +231,14 @@ function ErrorBanner({
231231
description,
232232
actionLabel,
233233
actionUrl = '#',
234-
onActionClick = () => {}
234+
onActionClick
235235
}) {
236236
return (
237237
<div className="output__error">
238238
<div className="output__error--title">
239239
<span>{title}</span>
240240
{
241-
actionLabel && <div className="output__error--action">
241+
actionLabel && onActionClick && <div className="output__error--action">
242242
<Link href={ actionUrl } onClick={ () => onActionClick() }>
243243
{ actionLabel }
244244
</Link>

test/components/Output/Output.spec.js

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,45 @@ describe('Output', function() {
3636
});
3737

3838

39+
describe('error banner', function() {
40+
41+
it('should render action link when onConfigureConnection is provided', async function() {
42+
43+
// when
44+
const { queryByText } = renderWithProps({
45+
isConnectionConfigured: false,
46+
configureConnectionBannerTitle: 'Foo',
47+
configureConnectionBannerDescription: 'Bar',
48+
configureConnectionLabel: 'Baz',
49+
onConfigureConnection: () => {}
50+
});
51+
52+
// then
53+
expect(queryByText(/Foo/i)).to.exist;
54+
expect(queryByText(/Bar/i)).to.exist;
55+
expect(queryByText(/Baz/i)).to.exist;
56+
});
57+
58+
59+
it('should not render action link when onConfigureConnection is not provided', async function() {
60+
61+
// when
62+
const { queryByText } = renderWithProps({
63+
isConnectionConfigured: false,
64+
configureConnectionBannerTitle: 'Foo',
65+
configureConnectionBannerDescription: 'Bar',
66+
configureConnectionLabel: 'Baz'
67+
});
68+
69+
// then
70+
expect(queryByText(/Foo/i)).to.exist;
71+
expect(queryByText(/Bar/i)).to.exist;
72+
expect(queryByText(/Baz/i)).to.not.exist;
73+
});
74+
75+
});
76+
77+
3978
describe('pickVariables', function() {
4079

4180
it('should pick variables by scope', function() {
@@ -162,7 +201,7 @@ function renderWithProps(props) {
162201
configureConnectionBannerTitle = 'Configure Connection',
163202
configureConnectionBannerDescription = 'Please configure your connection settings.',
164203
configureConnectionLabel = 'Configure Connection',
165-
onConfigureConnection = () => {},
204+
onConfigureConnection,
166205
isTaskExecuting = false,
167206
output = {},
168207
onResetOutput = () => {},

0 commit comments

Comments
 (0)