|
| 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/@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 | + </head> |
| 13 | + |
| 14 | + <body> |
| 15 | + <main id="webchat"></main> |
| 16 | + <script type="text/babel"> |
| 17 | + run(async function () { |
| 18 | + const { |
| 19 | + React, |
| 20 | + ReactDOM: { render }, |
| 21 | + WebChat: { FluentThemeProvider, ReactWebChat } |
| 22 | + } = window; // Imports in UMD fashion. |
| 23 | + |
| 24 | + const { directLine, store } = testHelpers.createDirectLineEmulator(); |
| 25 | + |
| 26 | + const App = () => <ReactWebChat directLine={directLine} store={store} />; |
| 27 | + |
| 28 | + render( |
| 29 | + <FluentThemeProvider> |
| 30 | + <App /> |
| 31 | + </FluentThemeProvider>, |
| 32 | + document.getElementById('webchat') |
| 33 | + ); |
| 34 | + |
| 35 | + await pageConditions.uiConnected(); |
| 36 | + |
| 37 | + await (await directLine.emulateOutgoingActivity("What's the weather like today?")).resolveAll(); |
| 38 | + |
| 39 | + await directLine.emulateIncomingActivity({ |
| 40 | + type: 'message', |
| 41 | + text: 'The weather is sunny and warm.', |
| 42 | + from: { |
| 43 | + role: 'bot' |
| 44 | + }, |
| 45 | + locale: 'en-US', |
| 46 | + entities: [], |
| 47 | + channelData: { |
| 48 | + feedbackLoop: { |
| 49 | + type: 'default', |
| 50 | + disclaimer: |
| 51 | + 'We may contact you at klewis@contoso.microsoft.com about your feedback. Learn more about how this data is used and your rights. By pressing Submit, your feedback will be used to improve our products and services. Privacy statement.' |
| 52 | + } |
| 53 | + } |
| 54 | + }); |
| 55 | + |
| 56 | + await pageConditions.numActivitiesShown(2); |
| 57 | + |
| 58 | + await (await directLine.emulateOutgoingActivity('How is the weather in Seattle today?')).resolveAll(); |
| 59 | + |
| 60 | + await directLine.emulateIncomingActivity({ |
| 61 | + id: 'a-00001', |
| 62 | + type: 'message', |
| 63 | + text: "I'm not sure how to help with that.", |
| 64 | + from: { |
| 65 | + role: 'bot' |
| 66 | + }, |
| 67 | + locale: 'en-US', |
| 68 | + entities: [], |
| 69 | + channelData: { |
| 70 | + feedbackLoop: { |
| 71 | + type: 'default', |
| 72 | + disclaimer: |
| 73 | + 'We may contact you at klewis@contoso.microsoft.com about your feedback. Learn more about how this data is used and your rights. By pressing Submit, your feedback will be used to improve our products and services. Privacy statement.' |
| 74 | + } |
| 75 | + } |
| 76 | + }); |
| 77 | + |
| 78 | + await pageConditions.numActivitiesShown(4); |
| 79 | + |
| 80 | + pageElements.byTestId('send box text area').focus(); |
| 81 | + await host.sendShiftTab(2); |
| 82 | + |
| 83 | + await host.sendKeys('ENTER'); |
| 84 | + await host.sendKeys('ENTER'); |
| 85 | + |
| 86 | + await pageConditions.became( |
| 87 | + 'feedback form is open', |
| 88 | + () => document.activeElement === pageElements.byTestId('feedback sendbox'), |
| 89 | + 20000 |
| 90 | + ); |
| 91 | + |
| 92 | + await host.snapshot('local'); |
| 93 | + |
| 94 | + await host.sendKeys('Test feedback'); |
| 95 | + const { activity } = await directLine.actPostActivity(async () => { |
| 96 | + await host.sendTab(1); |
| 97 | + await host.sendKeys('ENTER'); |
| 98 | + }); |
| 99 | + |
| 100 | + expect(activity).toEqual( |
| 101 | + expect.objectContaining({ |
| 102 | + type: 'invoke', |
| 103 | + name: 'message/submitAction', |
| 104 | + replyToId: 'a-00001', |
| 105 | + value: { |
| 106 | + actionName: 'feedback', |
| 107 | + actionValue: { |
| 108 | + reaction: 'like', |
| 109 | + feedback: { |
| 110 | + feedbackText: expect.any(String) |
| 111 | + } |
| 112 | + } |
| 113 | + } |
| 114 | + }) |
| 115 | + ); |
| 116 | + }); |
| 117 | + </script> |
| 118 | + </body> |
| 119 | +</html> |
0 commit comments