diff --git a/static/app/debug/notifications/components/notificationBodyRenderer.spec.tsx b/static/app/debug/notifications/components/notificationBodyRenderer.spec.tsx new file mode 100644 index 000000000000..49b7ff2ac79e --- /dev/null +++ b/static/app/debug/notifications/components/notificationBodyRenderer.spec.tsx @@ -0,0 +1,29 @@ +import {render, screen} from 'sentry-test/reactTestingLibrary'; + +import { + NotificationBodyFormattingBlockType, + NotificationBodyRenderer, + NotificationBodyTextBlockType, +} from './notificationBodyRenderer'; + +describe('NotificationBodyRenderer', () => { + it('renders markdown sections as markdown', async () => { + const body = [ + { + type: NotificationBodyFormattingBlockType.MARKDOWN, + blocks: [ + { + type: NotificationBodyTextBlockType.PLAIN_TEXT, + text: '**@Jane Doe** take a look', + }, + ], + }, + ]; + + render(); + + expect(await screen.findByText('@Jane Doe')).toBeInTheDocument(); + expect(screen.getByText('@Jane Doe').tagName).toBe('STRONG'); + expect(screen.queryByText(/\*\*/)).not.toBeInTheDocument(); + }); +}); diff --git a/static/app/debug/notifications/components/notificationBodyRenderer.tsx b/static/app/debug/notifications/components/notificationBodyRenderer.tsx index 848b2fe277e9..e6b29a80e1c6 100644 --- a/static/app/debug/notifications/components/notificationBodyRenderer.tsx +++ b/static/app/debug/notifications/components/notificationBodyRenderer.tsx @@ -1,13 +1,16 @@ import {Fragment} from 'react'; import styled from '@emotion/styled'; +import {MarkedText} from 'sentry/utils/marked/markedText'; + // Match the Python types from notifications/platform/types.py -enum NotificationBodyFormattingBlockType { +export enum NotificationBodyFormattingBlockType { PARAGRAPH = 'paragraph', CODE_BLOCK = 'code_block', + MARKDOWN = 'markdown', } -enum NotificationBodyTextBlockType { +export enum NotificationBodyTextBlockType { PLAIN_TEXT = 'plain_text', BOLD_TEXT = 'bold_text', CODE = 'code', @@ -70,6 +73,15 @@ function renderFormattingBlock( ); } + if (block.type === NotificationBodyFormattingBlockType.MARKDOWN) { + return ( + textBlock.text).join('\n')} + style={{marginBottom: '8px'}} + /> + ); + } return null; }