|
| 1 | +<!doctype html> |
| 2 | +<html lang="en-US"> |
| 3 | + <head> |
| 4 | + <link href="/assets/index.css" rel="stylesheet" type="text/css" /> |
| 5 | + </head> |
| 6 | + <body> |
| 7 | + <main id="webchat"></main> |
| 8 | + <script type="importmap"> |
| 9 | + { |
| 10 | + "imports": { |
| 11 | + "@testduet/wait-for": "https://esm.sh/@testduet/wait-for", |
| 12 | + "botframework-webchat": "/__dist__/packages/bundle/static/botframework-webchat.js", |
| 13 | + "botframework-webchat/": "/__dist__/packages/bundle/static/botframework-webchat/", |
| 14 | + "botframework-webchat-fluent-theme": "/__dist__/packages/fluent-theme/static/botframework-webchat-fluent-theme.js", |
| 15 | + "react": "/__dist__/packages/bundle/static/react.js", |
| 16 | + "react-dom": "/__dist__/packages/bundle/static/react-dom.js", |
| 17 | + "react-dom/client": "/__dist__/packages/bundle/static/react-dom/client.js" |
| 18 | + } |
| 19 | + } |
| 20 | + </script> |
| 21 | + <script type="module"> |
| 22 | + import '/test-harness.mjs'; |
| 23 | + import '/test-page-object.mjs'; |
| 24 | + |
| 25 | + import { waitFor } from '@testduet/wait-for'; |
| 26 | + import { createStoreWithOptions, ReactWebChat } from 'botframework-webchat'; |
| 27 | + import { FluentThemeProvider, testIds } from 'botframework-webchat-fluent-theme'; |
| 28 | + import { createElement } from 'react'; |
| 29 | + import { createRoot } from 'react-dom/client'; |
| 30 | + |
| 31 | + // TODO: This is for `createDirectLineEmulator` only, should find ways to eliminate this line. |
| 32 | + window.WebChat = { createStoreWithOptions }; |
| 33 | + |
| 34 | + run(async function () { |
| 35 | + const { directLine, store } = testHelpers.createDirectLineEmulator(); |
| 36 | + |
| 37 | + // GIVEN: Web Chat with the Fluent theme (or its Copilot variant) and `hideSendBox: true`. |
| 38 | + createRoot(document.getElementById('webchat')).render( |
| 39 | + createElement( |
| 40 | + FluentThemeProvider, |
| 41 | + { variant: new URLSearchParams(location.search).get('variant') || 'fluent' }, |
| 42 | + createElement(ReactWebChat, { directLine, store, styleOptions: { hideSendBox: true } }) |
| 43 | + ) |
| 44 | + ); |
| 45 | + |
| 46 | + await pageConditions.uiConnected(); |
| 47 | + |
| 48 | + // WHEN: The bot sends a message with suggested actions, which are shown inside the send box. |
| 49 | + await directLine.emulateIncomingActivity({ |
| 50 | + from: { role: 'bot' }, |
| 51 | + suggestedActions: { |
| 52 | + actions: [ |
| 53 | + { title: 'Yes', type: 'imBack', value: 'Yes' }, |
| 54 | + { title: 'No', type: 'imBack', value: 'No' } |
| 55 | + ] |
| 56 | + }, |
| 57 | + text: 'Do you want to continue?', |
| 58 | + type: 'message' |
| 59 | + }); |
| 60 | + |
| 61 | + await pageConditions.numActivitiesShown(1); |
| 62 | + await waitFor(() => expect(store.getState().suggestedActions).toHaveLength(2)); |
| 63 | + |
| 64 | + // THEN: The send box, its toolbar, and the suggested actions should not be rendered. |
| 65 | + expect(pageElements.byTestId(testIds.sendBoxContainer)).toBeFalsy(); |
| 66 | + expect(pageElements.byTestId(testIds.sendBoxTextBox)).toBeFalsy(); |
| 67 | + expect(pageElements.byTestId(testIds.sendBoxSendButton)).toBeFalsy(); |
| 68 | + expect(pageElements.byTestId(testIds.sendBoxSuggestedAction)).toBeFalsy(); |
| 69 | + |
| 70 | + // THEN: The transcript shows the message, without a send box or suggested actions below it. |
| 71 | + await host.snapshot('local'); |
| 72 | + }); |
| 73 | + </script> |
| 74 | + </body> |
| 75 | +</html> |
0 commit comments