|
| 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/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 | + </head> |
| 12 | + <body> |
| 13 | + <main id="webchat" style="position: relative"></main> |
| 14 | + <script type="text/babel"> |
| 15 | + run(async function () { |
| 16 | + const { |
| 17 | + React, |
| 18 | + ReactDOM: { render }, |
| 19 | + WebChat: { ReactWebChat } |
| 20 | + } = window; // Imports in UMD fashion. |
| 21 | + |
| 22 | + const { directLine, store } = testHelpers.createDirectLineEmulator(); |
| 23 | + |
| 24 | + render(<ReactWebChat directLine={directLine} store={store} />, document.getElementById('webchat')); |
| 25 | + |
| 26 | + await pageConditions.uiConnected(); |
| 27 | + |
| 28 | + expect(window.isSecureContext).toBe(true); |
| 29 | + |
| 30 | + await host.sendDevToolsCommand('Browser.setPermission', { |
| 31 | + permission: { name: 'clipboard-write' }, |
| 32 | + setting: 'granted' |
| 33 | + }); |
| 34 | + |
| 35 | + await expect(navigator.permissions.query({ name: 'clipboard-write' })).resolves.toHaveProperty( |
| 36 | + 'state', |
| 37 | + 'granted' |
| 38 | + ); |
| 39 | + |
| 40 | + await directLine.emulateIncomingActivity({ |
| 41 | + entities: [ |
| 42 | + { |
| 43 | + '@context': 'https://schema.org', |
| 44 | + '@id': '', |
| 45 | + '@type': 'Message', |
| 46 | + keywords: ['AllowCopy'], |
| 47 | + type: 'https://schema.org/Message' |
| 48 | + } |
| 49 | + ], |
| 50 | + text: 'Mollit *aute* **aute** dolor ea ex magna incididunt nostrud sit nisi.', |
| 51 | + type: 'message' |
| 52 | + }); |
| 53 | + |
| 54 | + await pageConditions.numActivitiesShown(1); |
| 55 | + |
| 56 | + // WHEN: Focus on the "Copy" button via keyboard. |
| 57 | + await host.click(document.querySelector(`[data-testid="${WebChat.testIds.copyButton}"]`)); |
| 58 | + |
| 59 | + // THEN: The "Copy" button should say "Copied". |
| 60 | + await host.snapshot(); |
| 61 | + |
| 62 | + // WHEN: After 1 second. |
| 63 | + await testHelpers.sleep(1_000); |
| 64 | + |
| 65 | + // THEN: The "Copy" button should back to normal. |
| 66 | + await host.snapshot(); |
| 67 | + |
| 68 | + // WHEN: Hiding Web Chat and showing it back. |
| 69 | + document.getElementById('webchat').style.display = 'none'; |
| 70 | + document.body.offsetWidth; // Need for browser to refresh the layout. |
| 71 | + document.getElementById('webchat').style.display = ''; |
| 72 | + |
| 73 | + // THEN: The "Copy" button should kept at normal. |
| 74 | + await host.snapshot(); |
| 75 | + }); |
| 76 | + </script> |
| 77 | + </body> |
| 78 | +</html> |
0 commit comments