|
| 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 | + "react": "/__dist__/packages/bundle/static/react.js", |
| 15 | + "react-dom": "/__dist__/packages/bundle/static/react-dom.js" |
| 16 | + } |
| 17 | + } |
| 18 | + </script> |
| 19 | + <script type="module"> |
| 20 | + import { createDirectLine, createStoreWithOptions, renderWebChat } from 'botframework-webchat'; |
| 21 | + |
| 22 | + run(async function () { |
| 23 | + const { |
| 24 | + testHelpers: { createDirectLineEmulator } |
| 25 | + } = window; |
| 26 | + |
| 27 | + // TODO: This is for `createDirectLineEmulator` only, should find ways to eliminate this line. |
| 28 | + window.WebChat = { createStoreWithOptions }; |
| 29 | + |
| 30 | + const { directLine, store } = createDirectLineEmulator(); |
| 31 | + |
| 32 | + renderWebChat( |
| 33 | + { |
| 34 | + directLine, |
| 35 | + store |
| 36 | + }, |
| 37 | + document.getElementById('webchat') |
| 38 | + ); |
| 39 | + |
| 40 | + await pageConditions.uiConnected(); |
| 41 | + |
| 42 | + await directLine.emulateIncomingActivity({ |
| 43 | + attachments: [ |
| 44 | + { |
| 45 | + content: { |
| 46 | + type: 'AdaptiveCard', |
| 47 | + body: [ |
| 48 | + { |
| 49 | + type: 'TextBlock', |
| 50 | + text: 'You can choose one of the followings.' |
| 51 | + } |
| 52 | + ], |
| 53 | + $schema: 'http://adaptivecards.io/schemas/adaptive-card.json', |
| 54 | + version: '1.2', |
| 55 | + actions: [ |
| 56 | + { |
| 57 | + type: 'Action.Submit', |
| 58 | + title: 'What time is it?' |
| 59 | + }, |
| 60 | + { |
| 61 | + type: 'Action.Submit', |
| 62 | + title: 'What is the weather?' |
| 63 | + } |
| 64 | + ] |
| 65 | + }, |
| 66 | + contentType: 'application/vnd.microsoft.card.adaptive' |
| 67 | + } |
| 68 | + ], |
| 69 | + from: { id: 'bot', role: 'bot' }, |
| 70 | + text: 'What can I do for you?', |
| 71 | + type: 'message' |
| 72 | + }); |
| 73 | + |
| 74 | + await pageConditions.numActivitiesShown(1); |
| 75 | + |
| 76 | + await host.snapshot('local'); |
| 77 | + |
| 78 | + expect(typeof globalThis.React).toBe('undefined'); |
| 79 | + }); |
| 80 | + </script> |
| 81 | + </body> |
| 82 | +</html> |
0 commit comments