|
| 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 | + <style type="text/css"> |
| 8 | + /* TODO: [P*] Can we eliminate this style? */ |
| 9 | + .fui-FluentProvider, |
| 10 | + .webchat-fluent { |
| 11 | + height: 100%; |
| 12 | + } |
| 13 | + </style> |
| 14 | + </head> |
| 15 | + <body> |
| 16 | + <main id="webchat"></main> |
| 17 | + <!-- Redirect packages on esm.sh loaded by `@fluentui/react-components` --> |
| 18 | + <script type="importmap"> |
| 19 | + { |
| 20 | + "imports": { |
| 21 | + "@fluentui/react-components": "https://esm.sh/@fluentui/react-components?deps=react@18.3.1,react-dom@18.3.1&exports=FluentProvider,createDarkTheme,webLightTheme", |
| 22 | + "botframework-webchat": "/__dist__/packages/bundle/static/botframework-webchat.js", |
| 23 | + "botframework-webchat/decorator": "/__dist__/packages/bundle/static/botframework-webchat.decorator.js", |
| 24 | + "botframework-webchat/internal": "/__dist__/packages/bundle/static/botframework-webchat.internal.js", |
| 25 | + "botframework-webchat-fluent-theme": "/__dist__/packages/fluent-theme/static/botframework-webchat-fluent-theme.js", |
| 26 | + "jest-mock": "https://esm.sh/jest-mock", |
| 27 | + "react": "/__dist__/packages/bundle/static/react.18.js", |
| 28 | + "react-dom": "/__dist__/packages/bundle/static/react-dom.18.js", |
| 29 | + "react-dom/client": "/__dist__/packages/bundle/static/react-dom.18/client.js", |
| 30 | + "https://esm.sh/react@18.3.1/es2022/react.mjs": "/__dist__/packages/bundle/static/react.18.js", |
| 31 | + "https://esm.sh/react@18.3.1/es2022/react-dom.mjs": "/__dist__/packages/bundle/static/react-dom.18.js", |
| 32 | + "https://esm.sh/react@18.3.1/es2022/react-dom/client.mjs": "/__dist__/packages/bundle/static/react-dom.18/client.js" |
| 33 | + } |
| 34 | + } |
| 35 | + </script> |
| 36 | + <script type="module"> |
| 37 | + import { fn, spyOn } from 'jest-mock'; |
| 38 | + import { FluentProvider, webLightTheme } from '@fluentui/react-components'; |
| 39 | + import { createDirectLine, createStoreWithOptions, hooks, ReactWebChat } from 'botframework-webchat'; |
| 40 | + import { FluentThemeProvider } from 'botframework-webchat-fluent-theme'; |
| 41 | + import { createElement } from 'react'; |
| 42 | + import { createRoot } from 'react-dom/client'; |
| 43 | + |
| 44 | + const consoleError = console.error.bind(console); |
| 45 | + |
| 46 | + spyOn(console, 'error').mockImplementation((...args) => { |
| 47 | + const [message] = args; |
| 48 | + |
| 49 | + if ( |
| 50 | + !( |
| 51 | + typeof message === 'string' && |
| 52 | + (message.includes( |
| 53 | + 'Support for defaultProps will be removed from function components in a future major release. Use JavaScript default parameters instead.' |
| 54 | + ) || |
| 55 | + // TODO: [P0] We should fix the "Cannot update a component while rendering a different component" error. |
| 56 | + (message.includes('Cannot update a component') && |
| 57 | + message.includes('while rendering a different component'))) |
| 58 | + ) |
| 59 | + ) { |
| 60 | + consoleError(...args); |
| 61 | + } |
| 62 | + }); |
| 63 | + |
| 64 | + const { useStyleOptions } = hooks; |
| 65 | + const { |
| 66 | + testHelpers: { createDirectLineEmulator } |
| 67 | + } = window; |
| 68 | + |
| 69 | + // TODO: This is for `createDirectLineEmulator` only, should find ways to eliminate this line. |
| 70 | + window.WebChat = { createStoreWithOptions }; |
| 71 | + |
| 72 | + run(async function () { |
| 73 | + const { directLine, store } = createDirectLineEmulator(); |
| 74 | + |
| 75 | + const fluentTheme = { |
| 76 | + ...webLightTheme, |
| 77 | + // Original is #242424 which is too light for fui-FluentProvider to pass our accessibility checks. |
| 78 | + colorNeutralForeground1: '#1b1b1b' |
| 79 | + }; |
| 80 | + |
| 81 | + createRoot(document.getElementsByTagName('main')[0]).render( |
| 82 | + createElement( |
| 83 | + FluentProvider, |
| 84 | + { className: 'fui-FluentProvider', theme: fluentTheme }, |
| 85 | + createElement( |
| 86 | + FluentThemeProvider, |
| 87 | + { variant: 'fluent' }, |
| 88 | + createElement(ReactWebChat, { directLine, store }) |
| 89 | + ) |
| 90 | + ) |
| 91 | + ); |
| 92 | + |
| 93 | + await pageConditions.uiConnected(); |
| 94 | + |
| 95 | + await directLine.emulateIncomingActivity('Hello, World!'); |
| 96 | + |
| 97 | + await pageConditions.numActivitiesShown(1); |
| 98 | + |
| 99 | + await host.snapshot('local'); |
| 100 | + }); |
| 101 | + </script> |
| 102 | + </body> |
| 103 | +</html> |
0 commit comments