-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Renders email action message text as html from markdown (#41006)
* uses `message` passed to action as text/plain message, and renders `message` as markdown to html as the text/html message * fix jest test
- Loading branch information
Showing
4 changed files
with
47 additions
and
13 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
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
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
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 |
---|---|---|
|
@@ -102,14 +102,35 @@ export default function emailTest({ getService }: KibanaFunctionalTestDefaultPro | |
cc: null, | ||
bcc: null, | ||
subject: 'email-subject', | ||
html: 'email-message', | ||
html: '<p>email-message</p>\n', | ||
text: 'email-message', | ||
headers: {}, | ||
}, | ||
}); | ||
}); | ||
}); | ||
|
||
it('should render html from markdown', async () => { | ||
await supertest | ||
.post(`/api/action/${createdActionId}/_fire`) | ||
.set('kbn-xsrf', 'foo') | ||
.send({ | ||
params: { | ||
to: ['[email protected]'], | ||
subject: 'message with markdown', | ||
message: '_italic_ **bold** https://elastic.co link', | ||
}, | ||
}) | ||
.expect(200) | ||
.then((resp: any) => { | ||
const { text, html } = resp.body.message; | ||
expect(text).to.eql('_italic_ **bold** https://elastic.co link'); | ||
expect(html).to.eql( | ||
'<p><em>italic</em> <strong>bold</strong> <a href="https://elastic.co">https://elastic.co</a> link</p>\n' | ||
); | ||
}); | ||
}); | ||
|
||
it('should respond with a 400 Bad Request when creating an email action with an invalid config', async () => { | ||
await supertest | ||
.post('/api/action') | ||
|
@@ -132,7 +153,4 @@ export default function emailTest({ getService }: KibanaFunctionalTestDefaultPro | |
}); | ||
}); | ||
}); | ||
|
||
// TODO: once we have the HTTP API fire action, test that with a webhook url pointing | ||
// back to the Kibana server | ||
} |