|
| 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="/test-harness.js"></script> |
| 7 | + <script crossorigin="anonymous" src="/test-page-object.js"></script> |
| 8 | + <script crossorigin="anonymous" src="/__dist__/webchat-es5.js"></script> |
| 9 | + </head> |
| 10 | + <body> |
| 11 | + <main id="webchat"></main> |
| 12 | + <script type="importmap"> |
| 13 | + { |
| 14 | + "imports": { |
| 15 | + "@testduet/wait-for": "https://esm.sh/@testduet/wait-for" |
| 16 | + } |
| 17 | + } |
| 18 | + </script> |
| 19 | + <script type="module"> |
| 20 | + import { waitFor } from '@testduet/wait-for'; |
| 21 | + |
| 22 | + run(async function () { |
| 23 | + const { |
| 24 | + WebChat: { renderWebChat, testIds } |
| 25 | + } = window; // Imports in UMD fashion. |
| 26 | + |
| 27 | + const { directLine, store } = testHelpers.createDirectLineEmulator(); |
| 28 | + |
| 29 | + const styleOptions = { |
| 30 | + feedbackActionsPlacement: 'activity-actions' |
| 31 | + }; |
| 32 | + |
| 33 | + renderWebChat({ directLine, store, styleOptions }, document.getElementById('webchat')); |
| 34 | + |
| 35 | + await pageConditions.uiConnected(); |
| 36 | + |
| 37 | + await directLine.emulateIncomingActivity({ |
| 38 | + channelData: { |
| 39 | + feedbackLoop: { |
| 40 | + type: 'default' |
| 41 | + } |
| 42 | + }, |
| 43 | + entities: [ |
| 44 | + { |
| 45 | + '@context': 'https://schema.org', |
| 46 | + '@id': '', |
| 47 | + '@type': 'Message', |
| 48 | + type: 'https://schema.org/Message', |
| 49 | + potentialAction: [ |
| 50 | + { |
| 51 | + '@type': 'LikeAction', |
| 52 | + actionStatus: 'PotentialActionStatus', |
| 53 | + target: { |
| 54 | + '@type': 'EntryPoint', |
| 55 | + urlTemplate: 'ms-directline://postback?interaction=like' |
| 56 | + } |
| 57 | + }, |
| 58 | + { |
| 59 | + '@type': 'DislikeAction', |
| 60 | + actionStatus: 'PotentialActionStatus', |
| 61 | + result: { |
| 62 | + '@type': 'Review', |
| 63 | + reviewBody: "I don't like it.", |
| 64 | + 'reviewBody-input': { |
| 65 | + '@type': 'PropertyValueSpecification', |
| 66 | + valueMinLength: 3, |
| 67 | + valueName: 'reason' |
| 68 | + } |
| 69 | + }, |
| 70 | + target: { |
| 71 | + '@type': 'EntryPoint', |
| 72 | + urlTemplate: 'ms-directline://postback?interaction=dislike{&reason}' |
| 73 | + } |
| 74 | + } |
| 75 | + ] |
| 76 | + } |
| 77 | + ], |
| 78 | + text: `Occaecat cillum amet ipsum amet pariatur proident commodo eiusmod cupidatat voluptate.`, |
| 79 | + type: 'message' |
| 80 | + }); |
| 81 | + |
| 82 | + await pageConditions.numActivitiesShown(1); |
| 83 | + |
| 84 | + // WHEN: The first feedback button is clicked. |
| 85 | + await host.click(document.querySelector(`[data-testid="${testIds.feedbackButton}"]`)); |
| 86 | + |
| 87 | + // THEN: The like button should be pressed. |
| 88 | + expect( |
| 89 | + Array.from(document.querySelectorAll(`[data-testid="${testIds.feedbackButton}"]`)).map( |
| 90 | + element => element.checked |
| 91 | + ) |
| 92 | + ).toEqual([true, false]); |
| 93 | + |
| 94 | + // THEN: Should match the snapshot. |
| 95 | + await host.snapshot('local'); |
| 96 | + }); |
| 97 | + </script> |
| 98 | + </body> |
| 99 | +</html> |
0 commit comments