From 781109312be8c614ad16bd8f954ccf1b50dfcd62 Mon Sep 17 00:00:00 2001 From: William Wong Date: Fri, 13 Dec 2019 06:47:49 +0800 Subject: [PATCH] Fix null renderMarkdown and add tests (#2724) --- CHANGELOG.md | 1 + ...-js-null-render-markdown-function-1-snap.png | Bin 0 -> 20961 bytes __tests__/hooks/useRenderMarkdownAsHTML.js | 10 ++++++++++ __tests__/markdown.js | 13 +++++++++++++ packages/bundle/src/useComposerProps.js | 3 ++- .../src/hooks/useRenderMarkdownAsHTML.js | 7 +++++-- 6 files changed, 31 insertions(+), 3 deletions(-) create mode 100644 __tests__/__image_snapshots__/chrome-docker/markdown-js-null-render-markdown-function-1-snap.png diff --git a/CHANGELOG.md b/CHANGELOG.md index 3aa4d8e60a..e258bd6a89 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -79,6 +79,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Fixes [#2709](https://github.com/microsoft/BotFramework-WebChat/issues/2709). Reduce wasted render of activities by memoizing partial result of ``, by [@compulim](https://github.com/compulim) in PR [#2710](https://github.com/microsoft/BotFramework-WebChat/pull/2710) - Fixes [#2710](https://github.com/microsoft/BotFramework-WebChat/issues/2710). Suggested actions container should persist for AT, by [@corinagum](https://github.com/corinagum) in PR [#2710](https://github.com/microsoft/BotFramework-WebChat/pull/2710) - Fixes [#2718](https://github.com/microsoft/BotFramework-WebChat/issues/2718). Add `Object.is` polyfill for IE11, by [@compulim](https://github.com/compulim) in PR [#2719](https://github.com/microsoft/BotFramework-WebChat/pull/2719) +- Fixes [#2723](https://github.com/microsoft/BotFramework-WebChat/issues/2723). Fix `renderMarkdown` should not be called if it is `undefined` in minimal bundle, by [@compulim](https://github.com/compulim) in PR [#2724](https://github.com/microsoft/BotFramework-WebChat/pull/2724) ### Changed diff --git a/__tests__/__image_snapshots__/chrome-docker/markdown-js-null-render-markdown-function-1-snap.png b/__tests__/__image_snapshots__/chrome-docker/markdown-js-null-render-markdown-function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s>T%H{z7vz5-!beu{p88^n`|_Uevk1BJfI1_ zTcyS*Fxqw{mH??(WZBcZmi*i7JFTza)*?mQN`VwKpg^)#kv|+a%Z+4ze8#|ezl#!L zf=}*be9zTsSAV14EW=O_*1^`EZBeP4_7{0ELGBG?bP$@_M?-T3Z4fRNjDoifhQv&s zL<|u|40`#}8^6s1`XH31M~5#z=Ih+FaHv329>;QLnLw9}*L9elHz);^Whc zCc&YZ|MKHUHh4KD_|gX}T7hVl)mR;Lhg~4UL^=kZ*i*d9x=B0w59$FmGxG$u(7AKZ z@fRU;7Xy^PNcaN!P<;-S0M_eYq%;Zaiqimd1Wmp$(CM8HezOZ?Yg9cC>;xeH6^xW( zdYTlCE02&&P+(vQ9!Mdf3BO?kiS=txOtGBf(mIwXAf&;!8=PR8(?XiUc)M(jWvkVUpD8LcpH zvhc{slip|VeBoYN)}mETpaH2m_6&KJCCoxFAbJRW&FOo=zKsh2L5^oBWX>`AL24nM z4GJvgqDa-3Spe+MTsV`_WDMT8GrjexW=b41n!0zLSXdltIp|nKcg18T{@Vs?SnU^t zfvj>G?v1F}T$w%X9Hu&@vtqMhEVKEghL zKnGFfpk*Ou9$zB==Yle(!8Z_UBh*g(Mi+&N`+MZ&5}MB8*Q`KgA)=tDssKX3AIG!n zeGI1ZOBon%_qngU34Q(g32rtA$F)}mX(~`z9StcJf%*N- Dwa7fD literal 0 HcmV?d00001 diff --git a/__tests__/hooks/useRenderMarkdownAsHTML.js b/__tests__/hooks/useRenderMarkdownAsHTML.js index da175d0214..fce52dd637 100644 --- a/__tests__/hooks/useRenderMarkdownAsHTML.js +++ b/__tests__/hooks/useRenderMarkdownAsHTML.js @@ -24,3 +24,13 @@ test('renderMarkdown should use custom Markdown transform function from props', pageObjects.runHook('useRenderMarkdownAsHTML', [], fn => fn('Hello, World!')) ).resolves.toMatchInlineSnapshot(`"HELLO, WORLD!"`); }); + +test('renderMarkdown should return falsy if the custom Markdown transform function is null', async () => { + const { pageObjects } = await setupWebDriver({ + props: { + renderMarkdown: null + } + }); + + await expect(pageObjects.runHook('useRenderMarkdownAsHTML', [], fn => !!fn)).resolves.toMatchInlineSnapshot(`false`); +}); diff --git a/__tests__/markdown.js b/__tests__/markdown.js index 4aca9dcef6..f1041fcbc4 100644 --- a/__tests__/markdown.js +++ b/__tests__/markdown.js @@ -22,3 +22,16 @@ test('hero card', async () => { expect(base64PNG).toMatchImageSnapshot(imageSnapshotOptions); }); + +test('null renderMarkdown function', async () => { + const { driver, pageObjects } = await setupWebDriver({ props: { renderMarkdown: null } }); + + await pageObjects.sendMessageViaSendBox('echo **This text should be plain text**', { waitForSend: true }); + + await driver.wait(allImagesLoaded(), timeouts.fetch); + await driver.wait(minNumActivitiesShown(2), timeouts.directLine); + + const base64PNG = await driver.takeScreenshot(); + + expect(base64PNG).toMatchImageSnapshot(imageSnapshotOptions); +}); diff --git a/packages/bundle/src/useComposerProps.js b/packages/bundle/src/useComposerProps.js index e4f9923ac2..c575e958b6 100644 --- a/packages/bundle/src/useComposerProps.js +++ b/packages/bundle/src/useComposerProps.js @@ -22,6 +22,7 @@ export default function useComposerProps({ attachmentMiddleware, renderMarkdown, return { attachmentMiddleware: patchedAttachmentMiddleware, extraStyleSet, - renderMarkdown: renderMarkdown || (text => defaultRenderMarkdown(text, patchedStyleOptions)) + renderMarkdown: + typeof renderMarkdown === 'undefined' ? text => defaultRenderMarkdown(text, patchedStyleOptions) : renderMarkdown }; } diff --git a/packages/component/src/hooks/useRenderMarkdownAsHTML.js b/packages/component/src/hooks/useRenderMarkdownAsHTML.js index 7fb682addc..250270429a 100644 --- a/packages/component/src/hooks/useRenderMarkdownAsHTML.js +++ b/packages/component/src/hooks/useRenderMarkdownAsHTML.js @@ -1,4 +1,4 @@ -import { useCallback } from 'react'; +import { useMemo } from 'react'; import useStyleOptions from '../hooks/useStyleOptions'; import useWebChatUIContext from './internal/useWebChatUIContext'; @@ -7,5 +7,8 @@ export default function useRenderMarkdownAsHTML() { const { renderMarkdown } = useWebChatUIContext(); const [styleOptions] = useStyleOptions(); - return useCallback(markdown => renderMarkdown(markdown, styleOptions), [renderMarkdown, styleOptions]); + return useMemo(() => renderMarkdown && (markdown => renderMarkdown(markdown, styleOptions)), [ + renderMarkdown, + styleOptions + ]); }