|
| 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="/test-harness.js"></script> |
| 6 | + <script crossorigin="anonymous" src="/test-page-object.js"></script> |
| 7 | + <script crossorigin="anonymous" src="/__dist__/webchat-es5.js"></script> |
| 8 | + </head> |
| 9 | + <body> |
| 10 | + <main id="webchat"></main> |
| 11 | + <script type="importmap"> |
| 12 | + { |
| 13 | + "imports": { |
| 14 | + "@testduet/wait-for": "https://esm.sh/@testduet/wait-for", |
| 15 | + "@testing-library/dom": "https://esm.sh/@testing-library/dom" |
| 16 | + } |
| 17 | + } |
| 18 | + </script> |
| 19 | + <script type="module"> |
| 20 | + import { waitFor } from '@testduet/wait-for'; |
| 21 | + import { queryAllByTestId } from '@testing-library/dom'; |
| 22 | + |
| 23 | + const { |
| 24 | + testHelpers: { createDirectLineEmulator }, |
| 25 | + WebChat: { createDirectLine, testIds } |
| 26 | + } = window; |
| 27 | + |
| 28 | + run(async function () { |
| 29 | + // We enable reduced motion by default, disable it first. |
| 30 | + await host.sendDevToolsCommand('Emulation.setEmulatedMedia', { |
| 31 | + features: [{ name: 'prefers-reduced-motion', value: '' }] |
| 32 | + }); |
| 33 | + |
| 34 | + const { directLine, store } = createDirectLineEmulator(); |
| 35 | + |
| 36 | + function render(props) { |
| 37 | + WebChat.renderWebChat( |
| 38 | + { |
| 39 | + directLine, |
| 40 | + store, |
| 41 | + ...props |
| 42 | + }, |
| 43 | + document.getElementById('webchat') |
| 44 | + ); |
| 45 | + } |
| 46 | + |
| 47 | + render(); |
| 48 | + |
| 49 | + await pageConditions.uiConnected(); |
| 50 | + |
| 51 | + for (let index = 0; index < 10; index++) { |
| 52 | + await host.upload(pageElements.uploadButton(), 'empty.zip'); |
| 53 | + |
| 54 | + await waitFor(() => |
| 55 | + expect(queryAllByTestId(document, testIds.sendBoxAttachmentBarItem)).toHaveLength(index + 1) |
| 56 | + ); |
| 57 | + } |
| 58 | + |
| 59 | + // THEN: With 1 attachment, they should appear as text-only. |
| 60 | + await host.snapshot('local'); |
| 61 | + |
| 62 | + // WHEN: styleOptions.sendBoxAttachmentBarMaxHeight is set to 200px. |
| 63 | + render({ styleOptions: { sendBoxAttachmentBarMaxHeight: 200 } }); |
| 64 | + |
| 65 | + // THEN: With 1 attachment, they should appear as text-only. |
| 66 | + await host.snapshot('local'); |
| 67 | + }); |
| 68 | + </script> |
| 69 | + </body> |
| 70 | +</html> |
0 commit comments