forked from microsoft/BotFramework-WebChat
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathrenderError.withoutDebug.html
More file actions
96 lines (84 loc) · 3.16 KB
/
renderError.withoutDebug.html
File metadata and controls
96 lines (84 loc) · 3.16 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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<!doctype html>
<html lang="en-US">
<head>
<link href="/assets/index.css" rel="stylesheet" type="text/css" />
<script>
const warn = console.warn.bind(console);
// We need to fake the mock ourselves without using jest-mock.
// jest-mock is ESM and cannot mock before Web Chat.
console.warn = (...args) => {
console.warn.mock.calls.push(args);
warn(...args);
};
console.warn._isMockFunction = true;
console.warn.getMockName = () => 'warn';
console.warn.mock = { calls: [] };
</script>
<script type="importmap">
{
"imports": {
"react": "https://esm.sh/react@18.3.1",
"react-dom": "https://esm.sh/react-dom@18.3.1",
"react-dom/": "https://esm.sh/react-dom@18.3.1/"
}
}
</script>
<script crossorigin="anonymous" src="/test-harness.js"></script>
<script crossorigin="anonymous" src="/test-page-object.js"></script>
<script type="module">
import React from 'react';
window.React = React;
</script>
<script crossorigin="anonymous" defer src="/__dist__/webchat-es5.js"></script>
<script crossorigin="anonymous" defer src="/__dist__/botframework-webchat-debug-theme.development.js"></script>
</head>
<body>
<main id="webchat"></main>
<script type="module">
import React, { createElement } from 'react';
import { createRoot } from 'react-dom/client';
run(async function () {
const {
testHelpers: { createStore },
WebChat: { ReactWebChat }
} = window;
const { directLine, store } = testHelpers.createDirectLineEmulator();
// GIVEN: Web Chat is being rendered without <DebugProvider>.
createRoot(document.getElementById('webchat')).render(createElement(ReactWebChat, { directLine, store }));
await pageConditions.uiConnected();
await directLine.emulateIncomingActivity({
attachments: [
{
contentType: 'application/vnd.microsoft.card.adaptive',
content: {
// WHEN: We want to render a failing Adaptive Cards, adding "*" here to fail the renderer.
type: '*AdaptiveCard*',
$schema: 'http://adaptivecards.io/schemas/adaptive-card.json',
version: '1.5',
body: [
{
text: 'Hello, World!',
type: 'TextBlock'
}
]
}
}
],
type: 'message'
});
// THEN: Should have "render Adaptive Cards" error message.
expect(console.warn).toHaveBeenCalledWith(
expect.stringContaining('Failed to render Adaptive Cards.'),
expect.anything()
);
// THEN: Should not show RCoR error as we have injected catchall.
expect(console.warn).not.toHaveBeenCalledWith(
expect.stringContaining('the request has fall through all middleware, set "fallbackComponent" as a catchall'),
expect.anything()
);
// THEN: Should not show red box.
await host.snapshot('local');
});
</script>
</body>
</html>