|
2 | 2 | <html lang="en-US"> |
3 | 3 | <head> |
4 | 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.production.min.js"></script> |
7 | | - <script crossorigin="anonymous" src="https://unpkg.com/react-dom@16.8.6/umd/react-dom.production.min.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 | | - <script crossorigin="anonymous" src="/__dist__/botframework-webchat-fluent-theme.production.min.js"></script> |
12 | 5 | </head> |
13 | 6 | <body> |
14 | 7 | <main id="webchat"></main> |
| 8 | + <script type="importmap"> |
| 9 | + { |
| 10 | + "imports": { |
| 11 | + "#test-harness": "/test-harness.mjs", |
| 12 | + "#test-page-object": "/test-page-object.mjs", |
| 13 | + "@fluentui/react-components": "https://esm.sh/@fluentui/react-components?deps=react@18,react-dom@18&exports=FluentProvider,createDarkTheme,webLightTheme", |
| 14 | + "@testduet/wait-for": "https://esm.sh/@testduet/wait-for", |
| 15 | + "botframework-webchat": "/__dist__/packages/bundle/static/botframework-webchat.js", |
| 16 | + "botframework-webchat/component": "/__dist__/packages/bundle/static/botframework-webchat/component.js", |
| 17 | + "botframework-webchat/decorator": "/__dist__/packages/bundle/static/botframework-webchat/decorator.js", |
| 18 | + "botframework-webchat/hook": "/__dist__/packages/bundle/static/botframework-webchat/hook.js", |
| 19 | + "botframework-webchat/internal": "/__dist__/packages/bundle/static/botframework-webchat/internal.js", |
| 20 | + "botframework-webchat-fluent-theme": "/__dist__/packages/fluent-theme/static/botframework-webchat-fluent-theme.js", |
| 21 | + "react": "https://esm.sh/react@18", |
| 22 | + "react-dom": "https://esm.sh/react-dom@18", |
| 23 | + "react-dom/": "https://esm.sh/react-dom@18/" |
| 24 | + } |
| 25 | + } |
| 26 | + </script> |
| 27 | + <script src="https://esm.sh/tsx" type="module"></script> |
15 | 28 | <script type="text/babel"> |
16 | | - run(async function () { |
17 | | - const { |
18 | | - React, |
19 | | - ReactDOM: { render }, |
20 | | - WebChat: { FluentThemeProvider, ReactWebChat } |
21 | | - } = window; // Imports in UMD fashion. |
| 29 | + import '#test-harness'; |
| 30 | + import '#test-page-object'; |
| 31 | + |
| 32 | + import { FluentProvider, webLightTheme } from '@fluentui/react-components'; |
| 33 | + import { waitFor } from '@testduet/wait-for'; |
| 34 | + import { createDirectLine, createStoreWithOptions, hooks, ReactWebChat } from 'botframework-webchat'; |
| 35 | + import { FluentThemeProvider, testIds } from 'botframework-webchat-fluent-theme'; |
| 36 | + import { createRoot } from 'react-dom/client'; |
| 37 | + |
| 38 | + console.log(testIds); |
| 39 | + |
| 40 | + const { |
| 41 | + testHelpers: { createDirectLineEmulator } |
| 42 | + } = window; |
| 43 | + |
| 44 | + // TODO: This is for `createDirectLineEmulator` only, should find ways to eliminate this line. |
| 45 | + window.WebChat = { createStoreWithOptions }; |
22 | 46 |
|
| 47 | + run(async function () { |
23 | 48 | const { directLine, store } = testHelpers.createDirectLineEmulator(); |
24 | 49 |
|
25 | 50 | const App = () => <ReactWebChat directLine={directLine} store={store} />; |
26 | 51 |
|
27 | | - render( |
| 52 | + createRoot(document.getElementsByTagName('main')[0]).render( |
28 | 53 | <FluentThemeProvider> |
29 | 54 | <App /> |
30 | | - </FluentThemeProvider>, |
31 | | - document.getElementById('webchat') |
| 55 | + </FluentThemeProvider> |
32 | 56 | ); |
33 | 57 |
|
34 | 58 | await pageConditions.uiConnected(); |
|
39 | 63 |
|
40 | 64 | await pageConditions.numActivitiesShown(1); |
41 | 65 |
|
42 | | - document.querySelector(`[data-testid="${WebChat.testIds.sendBoxTextBox}"]`).focus(); |
43 | | - await host.sendKeys('Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris '.repeat(12)); |
44 | | - |
| 66 | + document.querySelector(`[data-testid="${testIds.sendBoxTextBox}"]`).focus(); |
| 67 | + await host.sendKeys( |
| 68 | + 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris '.repeat( |
| 69 | + 12 |
| 70 | + ) |
| 71 | + ); |
| 72 | + |
45 | 73 | await host.sendKeys('\n'); |
46 | | - host.click(document.querySelector(`[data-testid="${WebChat.testIds.sendBoxSendButton}"]`)); |
| 74 | + |
| 75 | + const sendBoxSendButton = document.querySelector(`[data-testid="${testIds.sendBoxSendButton}"]`); |
| 76 | + |
| 77 | + // WHEN: Click on the send button. |
| 78 | + host.click(sendBoxSendButton); |
| 79 | + |
| 80 | + // THEN: Should focus on the send button, so the text box scroll bar should disappear. |
| 81 | + await waitFor(() => expect(document.activeElement).toBe(sendBoxSendButton)); |
47 | 82 |
|
48 | 83 | // THEN: Should not send the activity. |
49 | 84 | await host.snapshot(); |
|
0 commit comments