|
| 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="https://unpkg.com/react@16.8.6/umd/react.production.min.js"></script> |
| 6 | + <script crossorigin="anonymous" src="https://unpkg.com/react-dom@16.8.6/umd/react-dom.production.min.js"></script> |
| 7 | + <script crossorigin="anonymous" src="/test-harness.js"></script> |
| 8 | + <script crossorigin="anonymous" src="/test-page-object.js"></script> |
| 9 | + <script crossorigin="anonymous" src="/__dist__/webchat-es5.js"></script> |
| 10 | + </head> |
| 11 | + <body> |
| 12 | + <main id="webchat"></main> |
| 13 | + <script type="importmap"> |
| 14 | + { |
| 15 | + "imports": { |
| 16 | + "@testduet/wait-for": "https://esm.sh/@testduet/wait-for" |
| 17 | + } |
| 18 | + } |
| 19 | + </script> |
| 20 | + <script type="module"> |
| 21 | + import { waitFor } from '@testduet/wait-for'; |
| 22 | + |
| 23 | + run(async function () { |
| 24 | + const { |
| 25 | + React: { createElement }, |
| 26 | + ReactDOM: { render }, |
| 27 | + WebChat: { ReactWebChat } |
| 28 | + } = window; // Imports in UMD fashion. |
| 29 | + |
| 30 | + const ponyfill = lolex.createClock(); |
| 31 | + const { directLine, store } = testHelpers.createDirectLineEmulator({ ponyfill }); |
| 32 | + |
| 33 | + const App = () => |
| 34 | + createElement(ReactWebChat, { |
| 35 | + directLine, |
| 36 | + ponyfill, |
| 37 | + store, |
| 38 | + styleOptions: { |
| 39 | + typingAnimationBackgroundImage: `url('data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEAYABgAAD/2wBDAAYEBQYFBAYGBQYHBwYIChAKCgkJChQODwwQFxQYGBcUFhYaHSUfGhsjHBYWICwgIyYnKSopGR8tMC0oMCUoKSj/2wBDAQcHBwoIChMKChMoGhYaKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCj/wAARCAAUACgDASIAAhEBAxEB/8QAGgABAQACAwAAAAAAAAAAAAAAAAYCBwMFCP/EACsQAAECBQIEBQUAAAAAAAAAAAECAwAEBQYRBxITIjFBMlFhccFScoGh8f/EABQBAQAAAAAAAAAAAAAAAAAAAAD/xAAUEQEAAAAAAAAAAAAAAAAAAAAA/9oADAMBAAIRAxEAPwD0lctx023JVD9UeKOIcNoSNylkdcCMbauSmXHLOPUx8r4ZAcQtO1SM9Mj5iO1gtWo1syc7S2zMKYSptbIPNgnII8/5HBpRZ9RpaKjNVVCpUzLPAQ1nmA7qPl6fmAondRrcaqhkVTiiQrYXgglsH7vnpHc3DcNNoEimaqT4Q2s4bCRuUs+gEaLd05uNFVMmiS3o3YEwFDhlP1Z7e3WLzUuzahUKHRk0zM07TmeApvOFLGEjcM9+Xp6wFnbN0Uu5GnF0x4qW1je2tO1Sc9Djy9oRD6QWlU6PPzVSqjRlgtksttKPMcqBKiO3h/cIDacIQgEIQgEIQgP/2Q==')` |
| 40 | + } |
| 41 | + }); |
| 42 | + |
| 43 | + render(createElement(App), document.getElementById('webchat')); |
| 44 | + |
| 45 | + await pageConditions.webChatRendered(); |
| 46 | + |
| 47 | + // Wait for "Connecting..." message to dismiss |
| 48 | + ponyfill.tick(600); |
| 49 | + |
| 50 | + await pageConditions.uiConnected(); |
| 51 | + |
| 52 | + // --- |
| 53 | + |
| 54 | + // WHEN: A contentless message is received. |
| 55 | + await directLine.emulateIncomingActivity({ |
| 56 | + channelData: { streamSequence: 1, streamType: 'streaming' }, |
| 57 | + from: { id: 'u-00001', name: 'Bot', role: 'bot' }, |
| 58 | + id: 't-00001', |
| 59 | + type: 'typing' |
| 60 | + }); |
| 61 | + |
| 62 | + // THEN: Should render the typing indicator. |
| 63 | + await waitFor(() => expect(pageElements.typingIndicator).toBeTruthy()); |
| 64 | + await host.snapshot('local'); |
| 65 | + |
| 66 | + // --- |
| 67 | + |
| 68 | + // WHEN: After 60 seconds. |
| 69 | + ponyfill.tick(60_000); |
| 70 | + |
| 71 | + // THEN: Should continue to render the typing indicator. |
| 72 | + await waitFor(() => expect(pageElements.typingIndicator).toBeTruthy()); |
| 73 | + await host.snapshot('local'); |
| 74 | + }); |
| 75 | + </script> |
| 76 | + </body> |
| 77 | +</html> |
0 commit comments