Skip to content

Commit 9f99be8

Browse files
committed
Add unit tests
1 parent 0099766 commit 9f99be8

File tree

2 files changed

+36
-3
lines changed

2 files changed

+36
-3
lines changed

x-pack/plugins/triggers_actions_ui/public/application/sections/alert_form/alert_form.test.tsx

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ describe('alert_form', () => {
3131
id: 'my-alert-type',
3232
iconClass: 'test',
3333
name: 'test-alert',
34-
description: 'test',
35-
documentationUrl: null,
34+
description: 'Alert when testing',
35+
documentationUrl: 'https://localhost.local/docs',
3636
validate: (): ValidationResult => {
3737
return { errors: {} };
3838
},
@@ -184,6 +184,22 @@ describe('alert_form', () => {
184184
);
185185
expect(alertTypeSelectOptions.exists()).toBeFalsy();
186186
});
187+
188+
it('renders alert type description', async () => {
189+
await setup();
190+
wrapper.find('[data-test-subj="my-alert-type-SelectOption"]').first().simulate('click');
191+
const alertDescription = wrapper.find('[data-test-subj="alertDescription"]');
192+
expect(alertDescription.exists()).toBeTruthy();
193+
expect(alertDescription.first().text()).toBe('Alert when testing');
194+
});
195+
196+
it('renders alert type documentation link', async () => {
197+
await setup();
198+
wrapper.find('[data-test-subj="my-alert-type-SelectOption"]').first().simulate('click');
199+
const alertDocumentationLink = wrapper.find('[data-test-subj="alertDocumentationLink"]');
200+
expect(alertDocumentationLink.exists()).toBeTruthy();
201+
expect(alertDocumentationLink.first().prop('href')).toBe('https://localhost.local/docs');
202+
});
187203
});
188204

189205
describe('alert_form create alert non alerting consumer and producer', () => {
@@ -427,5 +443,19 @@ describe('alert_form', () => {
427443
const throttleFieldAfterUpdate = wrapper.find('[data-test-subj="throttleInput"]');
428444
expect(throttleFieldAfterUpdate.at(1).prop('value')).toEqual(newThrottle);
429445
});
446+
447+
it('renders alert type description', async () => {
448+
await setup();
449+
const alertDescription = wrapper.find('[data-test-subj="alertDescription"]');
450+
expect(alertDescription.exists()).toBeTruthy();
451+
expect(alertDescription.first().text()).toBe('Alert when testing');
452+
});
453+
454+
it('renders alert type documentation link', async () => {
455+
await setup();
456+
const alertDocumentationLink = wrapper.find('[data-test-subj="alertDocumentationLink"]');
457+
expect(alertDocumentationLink.exists()).toBeTruthy();
458+
expect(alertDocumentationLink.first().prop('href')).toBe('https://localhost.local/docs');
459+
});
430460
});
431461
});

x-pack/plugins/triggers_actions_ui/public/application/sections/alert_form/alert_form.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,9 @@ export const AlertForm = ({
252252
{alertTypeModel?.description && (
253253
<EuiFlexGroup>
254254
<EuiFlexItem>
255-
<EuiText color="subdued">{alertTypeModel.description}</EuiText>
255+
<EuiText color="subdued" data-test-subj="alertDescription">
256+
{alertTypeModel.description}
257+
</EuiText>
256258
</EuiFlexItem>
257259
</EuiFlexGroup>
258260
)}
@@ -262,6 +264,7 @@ export const AlertForm = ({
262264
<EuiLink
263265
external
264266
target="_blank"
267+
data-test-subj="alertDocumentationLink"
265268
href={
266269
typeof alertTypeModel.documentationUrl === 'function'
267270
? alertTypeModel.documentationUrl(docLinks)

0 commit comments

Comments
 (0)