|
| 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="/test-harness.js"></script> |
| 6 | + <script crossorigin="anonymous" src="/test-page-object.js"></script> |
| 7 | + </head> |
| 8 | + <body> |
| 9 | + <main id="webchat"></main> |
| 10 | + <script type="importmap"> |
| 11 | + { |
| 12 | + "imports": { |
| 13 | + "botframework-webchat": "/__dist__/packages/bundle/static/botframework-webchat.js", |
| 14 | + "botframework-webchat/hook": "/__dist__/packages/bundle/static/botframework-webchat/hook.js", |
| 15 | + "botframework-webchat/middleware": "/__dist__/packages/bundle/static/botframework-webchat/middleware.js", |
| 16 | + "react": "https://esm.sh/react@18", |
| 17 | + "react-dom": "https://esm.sh/react-dom@18", |
| 18 | + "react-dom/": "https://esm.sh/react-dom@18/" |
| 19 | + } |
| 20 | + } |
| 21 | + </script> |
| 22 | + <script src="https://esm.sh/tsx" type="module"></script> |
| 23 | + <script type="text/babel"> |
| 24 | + import { createDirectLine, createStoreWithOptions, hooks, ReactWebChat } from 'botframework-webchat'; |
| 25 | + import { createElement } from 'react'; |
| 26 | + import { createRoot } from 'react-dom/client'; |
| 27 | + |
| 28 | + const { |
| 29 | + testHelpers: { createDirectLineEmulator } |
| 30 | + } = window; |
| 31 | + |
| 32 | + // TODO: This is for `createDirectLineEmulator` only, should find ways to eliminate this line. |
| 33 | + window.WebChat = { createStoreWithOptions }; |
| 34 | + |
| 35 | + run(async function () { |
| 36 | + const { directLine, store } = createDirectLineEmulator(); |
| 37 | + |
| 38 | + createRoot(document.getElementsByTagName('main')[0]).render( |
| 39 | + <ReactWebChat directLine={directLine} store={store} /> |
| 40 | + ); |
| 41 | + |
| 42 | + await pageConditions.uiConnected(); |
| 43 | + |
| 44 | + await directLine.emulateIncomingActivity('Hello, World!'); |
| 45 | + |
| 46 | + await pageConditions.numActivitiesShown(1); |
| 47 | + |
| 48 | + await host.snapshot('local'); |
| 49 | + }); |
| 50 | + </script> |
| 51 | + </body> |
| 52 | +</html> |
0 commit comments