-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Expand file tree
/
Copy pathbasic.sendbox.with.mic.html
More file actions
82 lines (70 loc) · 3.51 KB
/
basic.sendbox.with.mic.html
File metadata and controls
82 lines (70 loc) · 3.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<!doctype html>
<html lang="en-US">
<head>
<link href="/assets/index.css" rel="stylesheet" type="text/css" />
<script crossorigin="anonymous" src="https://unpkg.com/@babel/standalone@7.8.7/babel.min.js"></script>
<script crossorigin="anonymous" src="https://unpkg.com/react@16.8.6/umd/react.production.min.js"></script>
<script crossorigin="anonymous" src="https://unpkg.com/react-dom@16.8.6/umd/react-dom.production.min.js"></script>
<script crossorigin="anonymous" src="/test-harness.js"></script>
<script crossorigin="anonymous" src="/test-page-object.js"></script>
<script crossorigin="anonymous" src="/__dist__/webchat-es5.js"></script>
<script crossorigin="anonymous" src="/__dist__/botframework-webchat-fluent-theme.production.min.js"></script>
</head>
<body>
<main id="webchat"></main>
<script type="text/babel">
run(async function () {
const {
React,
ReactDOM: { render },
WebChat: { FluentThemeProvider, ReactWebChat, testIds }
} = window;
// GIVEN: Web Chat with Fluent Theme and microphone button enabled
const { directLine, store } = testHelpers.createDirectLineEmulator();
// Set voice configuration capability to enable microphone button
directLine.setCapability('getVoiceConfiguration', { sampleRate: 24000, chunkIntervalMs: 100 }, { emitEvent: false });
// Enable voice-only mode (hides send button, shows mic + dismiss buttons)
directLine.setCapability('getIsVoiceOnlyMode', true, { emitEvent: false });
render(
<FluentThemeProvider variant="fluent">
<ReactWebChat
directLine={directLine}
store={store}
styleOptions={{
disableFileUpload: true,
hideTelephoneKeypadButton: false,
}}
/>
</FluentThemeProvider>,
document.getElementById('webchat')
);
await pageConditions.uiConnected();
// THEN: Microphone button should be present
const micButton = document.querySelector(`[data-testid="${testIds.sendBoxMicrophoneButton}"]`);
expect(micButton).toBeTruthy();
// THEN: Telephone keypad button should be present
const keypadButton = document.querySelector(`[data-testid="${testIds.sendBoxTelephoneKeypadToolbarButton}"]`);
expect(keypadButton).toBeTruthy();
// THEN: Text counter should NOT be present
const textCounter = document.querySelector('.sendbox__text-counter');
expect(textCounter).toBeFalsy();
// THEN: Send button should NOT be present
const sendButton = document.querySelector(`[data-testid="${testIds.sendBoxSendButton}"]`);
expect(sendButton).toBeFalsy();
// THEN: Should show sendbox with microphone and keypad buttons
await host.snapshot('local');
// WHEN: Voice configuration is removed from directLine
directLine.setCapability('getVoiceConfiguration', undefined);
// Wait for UI to update
await pageConditions.became(
'Microphone button should be hidden after removing voice configuration',
() => !document.querySelector(`[data-testid="${testIds.sendBoxMicrophoneButton}"]`),
1000
);
// THEN: Microphone button should NOT be present anymore
const micButtonAfterRemoval = document.querySelector(`[data-testid="${testIds.sendBoxMicrophoneButton}"]`);
expect(micButtonAfterRemoval).toBeFalsy();
});
</script>
</body>
</html>