|
| 1 | +<!doctype html> |
| 2 | +<html lang="en-US"> |
| 3 | + <head> |
| 4 | + <link href="/assets/index.css" rel="stylesheet" type="text/css" /> |
| 5 | + <script crossorigin="anonymous" src="https://unpkg.com/@babel/standalone@7.8.7/babel.min.js"></script> |
| 6 | + <script crossorigin="anonymous" src="https://unpkg.com/react@16.8.6/umd/react.development.js"></script> |
| 7 | + <script crossorigin="anonymous" src="https://unpkg.com/react-dom@16.8.6/umd/react-dom.development.js"></script> |
| 8 | + <script crossorigin="anonymous" src="/test-harness.js"></script> |
| 9 | + <script crossorigin="anonymous" src="/test-page-object.js"></script> |
| 10 | + <script crossorigin="anonymous" src="/__dist__/webchat-es5.js"></script> |
| 11 | + </head> |
| 12 | + <body> |
| 13 | + <main id="webchat"></main> |
| 14 | + <script type="text/babel" data-presets="env,stage-3,react"> |
| 15 | + const { |
| 16 | + testHelpers: { createDirectLineEmulator }, |
| 17 | + WebChat: { |
| 18 | + Components: { BasicWebChat, Composer }, |
| 19 | + hooks: { useSendBoxHooks }, |
| 20 | + testIds |
| 21 | + } |
| 22 | + } = window; |
| 23 | + |
| 24 | + run(async function () { |
| 25 | + const { directLine, store } = createDirectLineEmulator(); |
| 26 | + |
| 27 | + const RunFunction = ({ fn }) => { |
| 28 | + fn(); |
| 29 | + |
| 30 | + return false; |
| 31 | + }; |
| 32 | + |
| 33 | + const renderWithFunction = fn => |
| 34 | + new Promise(resolve => |
| 35 | + ReactDOM.render( |
| 36 | + <Composer directLine={directLine} sendTypingIndicator={true} store={store}> |
| 37 | + <BasicWebChat /> |
| 38 | + <RunFunction fn={() => resolve(fn && fn())} key={Date.now() + ''} /> |
| 39 | + </Composer>, |
| 40 | + document.getElementById('webchat') |
| 41 | + ) |
| 42 | + ); |
| 43 | + |
| 44 | + await renderWithFunction(); |
| 45 | + |
| 46 | + await pageConditions.webChatRendered(); |
| 47 | + |
| 48 | + // WHEN: At initial. |
| 49 | + await pageConditions.uiConnected(); |
| 50 | + |
| 51 | + // WHEN: `useActiveTyping` to set the text box value. |
| 52 | + await renderWithFunction(() => useSendBoxHooks().useSendBoxValue()[1]('Hello, World!')); |
| 53 | + |
| 54 | + // THEN: Send box should be "Hello, World!" |
| 55 | + expect(pageElements.byTestId(testIds.sendBoxTextBox)).toHaveProperty('value', 'Hello, World!'); |
| 56 | + }); |
| 57 | + </script> |
| 58 | + </body> |
| 59 | +</html> |
0 commit comments