|
12 | 12 | <main id="webchat"></main> |
13 | 13 | <script> |
14 | 14 | run(async function () { |
| 15 | + const useDeprecatedHook = new URL(location).searchParams.has('deprecated'); |
15 | 16 | const directLine = WebChat.createDirectLine({ token: await testHelpers.token.fetchDirectLineToken() }); |
16 | 17 | const store = testHelpers.createStore(); |
17 | 18 |
|
|
23 | 24 | await pageConditions.uiConnected(); |
24 | 25 |
|
25 | 26 | // WHEN: `useSendBoxAttachments` hook is called to get the attachments. |
26 | | - const initialSendBoxAttachments = await pageObjects.runHook( |
27 | | - ({ useSendBoxAttachments }) => useSendBoxAttachments()[0] |
| 27 | + const initialSendBoxAttachments = await pageObjects.runHook(hooks => |
| 28 | + useDeprecatedHook |
| 29 | + ? hooks.useSendBoxAttachments()[0] |
| 30 | + : hooks.useSendBoxAttachmentsHooks().useSendBoxAttachments()[0] |
28 | 31 | ); |
29 | 32 |
|
30 | 33 | // THEN: It should return empty array. |
|
59 | 62 | }); |
60 | 63 |
|
61 | 64 | // WHEN: `useSendBoxAttachments` hook is called to set an attachment. |
62 | | - await pageObjects.runHook(({ useSendBoxAttachments }) => { |
| 65 | + await pageObjects.runHook(hooks => { |
63 | 66 | const attachmentsRef = React.useRef([{ blob, thumbnailURL }]); |
64 | | - useSendBoxAttachments()[1](attachmentsRef.current); |
| 67 | + |
| 68 | + if (useDeprecatedHook) { |
| 69 | + hooks.useSendBoxAttachments()[1](attachmentsRef.current); |
| 70 | + } else { |
| 71 | + hooks.useSendBoxAttachmentsHooks().useSendBoxAttachments()[1](attachmentsRef.current); |
| 72 | + } |
65 | 73 | }); |
66 | 74 |
|
67 | 75 | // THEN: It should show checkmark on the button and file preview. |
68 | | - await host.snapshot(); |
| 76 | + await host.snapshot('local'); |
69 | 77 |
|
70 | 78 | // WHEN: `useSendBoxAttachments` hook is called to get the attachments. |
71 | | - const sendBoxAttachments = await pageObjects.runHook(({ useSendBoxAttachments }) => useSendBoxAttachments()[0]); |
| 79 | + const sendBoxAttachments = await pageObjects.runHook(hooks => |
| 80 | + useDeprecatedHook |
| 81 | + ? hooks.useSendBoxAttachments()[0] |
| 82 | + : hooks.useSendBoxAttachmentsHooks().useSendBoxAttachments()[0] |
| 83 | + ); |
72 | 84 |
|
73 | 85 | // THEN: It should return 1 attachment. |
74 | 86 | expect(sendBoxAttachments).toHaveLength(1); |
|
80 | 92 | // THEN: It should send the attachment (each "run hook" is an activity). |
81 | 93 | await pageConditions.allOutgoingActivitiesSent(); |
82 | 94 | await pageConditions.numActivitiesShown(5); |
83 | | - await host.snapshot(); |
| 95 | + await host.snapshot('local'); |
84 | 96 |
|
85 | 97 | // WHEN: `useSendBoxAttachments` hook is called to get the attachments. |
86 | | - const finalSendBoxAttachments = await pageObjects.runHook( |
87 | | - ({ useSendBoxAttachments }) => useSendBoxAttachments()[0] |
| 98 | + const finalSendBoxAttachments = await pageObjects.runHook(hooks => |
| 99 | + useDeprecatedHook |
| 100 | + ? hooks.useSendBoxAttachments()[0] |
| 101 | + : hooks.useSendBoxAttachmentsHooks().useSendBoxAttachments()[0] |
88 | 102 | ); |
89 | 103 |
|
90 | 104 | // THEN: It should return 0 attachments. |
|
0 commit comments