Skip to content

Commit 11c6526

Browse files
committed
Fix maxMessageLength flaky
1 parent a554931 commit 11c6526

2 files changed

Lines changed: 55 additions & 20 deletions

File tree

-110 Bytes
Loading

__tests__/html/fluentTheme/maxMessageLength.html

Lines changed: 55 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,57 @@
22
<html lang="en-US">
33
<head>
44
<link href="/assets/index.css" rel="stylesheet" type="text/css" />
5-
<script crossorigin="anonymous" src="https://unpkg.com/@babel/standalone@7.8.7/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-
<script crossorigin="anonymous" src="/__dist__/botframework-webchat-fluent-theme.production.min.js"></script>
125
</head>
136
<body>
147
<main id="webchat"></main>
8+
<script type="importmap">
9+
{
10+
"imports": {
11+
"#test-harness": "/test-harness.mjs",
12+
"#test-page-object": "/test-page-object.mjs",
13+
"@fluentui/react-components": "https://esm.sh/@fluentui/react-components?deps=react@18,react-dom@18&exports=FluentProvider,createDarkTheme,webLightTheme",
14+
"@testduet/wait-for": "https://esm.sh/@testduet/wait-for",
15+
"botframework-webchat": "/__dist__/packages/bundle/static/botframework-webchat.js",
16+
"botframework-webchat/component": "/__dist__/packages/bundle/static/botframework-webchat/component.js",
17+
"botframework-webchat/decorator": "/__dist__/packages/bundle/static/botframework-webchat/decorator.js",
18+
"botframework-webchat/hook": "/__dist__/packages/bundle/static/botframework-webchat/hook.js",
19+
"botframework-webchat/internal": "/__dist__/packages/bundle/static/botframework-webchat/internal.js",
20+
"botframework-webchat-fluent-theme": "/__dist__/packages/fluent-theme/static/botframework-webchat-fluent-theme.js",
21+
"react": "https://esm.sh/react@18",
22+
"react-dom": "https://esm.sh/react-dom@18",
23+
"react-dom/": "https://esm.sh/react-dom@18/"
24+
}
25+
}
26+
</script>
27+
<script src="https://esm.sh/tsx" type="module"></script>
1528
<script type="text/babel">
16-
run(async function () {
17-
const {
18-
React,
19-
ReactDOM: { render },
20-
WebChat: { FluentThemeProvider, ReactWebChat }
21-
} = window; // Imports in UMD fashion.
29+
import '#test-harness';
30+
import '#test-page-object';
31+
32+
import { FluentProvider, webLightTheme } from '@fluentui/react-components';
33+
import { waitFor } from '@testduet/wait-for';
34+
import { createDirectLine, createStoreWithOptions, hooks, ReactWebChat } from 'botframework-webchat';
35+
import { FluentThemeProvider, testIds } from 'botframework-webchat-fluent-theme';
36+
import { createRoot } from 'react-dom/client';
37+
38+
console.log(testIds);
39+
40+
const {
41+
testHelpers: { createDirectLineEmulator }
42+
} = window;
43+
44+
// TODO: This is for `createDirectLineEmulator` only, should find ways to eliminate this line.
45+
window.WebChat = { createStoreWithOptions };
2246

47+
run(async function () {
2348
const { directLine, store } = testHelpers.createDirectLineEmulator();
2449

2550
const App = () => <ReactWebChat directLine={directLine} store={store} />;
2651

27-
render(
52+
createRoot(document.getElementsByTagName('main')[0]).render(
2853
<FluentThemeProvider>
2954
<App />
30-
</FluentThemeProvider>,
31-
document.getElementById('webchat')
55+
</FluentThemeProvider>
3256
);
3357

3458
await pageConditions.uiConnected();
@@ -39,11 +63,22 @@
3963

4064
await pageConditions.numActivitiesShown(1);
4165

42-
document.querySelector(`[data-testid="${WebChat.testIds.sendBoxTextBox}"]`).focus();
43-
await host.sendKeys('Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris '.repeat(12));
44-
66+
document.querySelector(`[data-testid="${testIds.sendBoxTextBox}"]`).focus();
67+
await host.sendKeys(
68+
'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris '.repeat(
69+
12
70+
)
71+
);
72+
4573
await host.sendKeys('\n');
46-
host.click(document.querySelector(`[data-testid="${WebChat.testIds.sendBoxSendButton}"]`));
74+
75+
const sendBoxSendButton = document.querySelector(`[data-testid="${testIds.sendBoxSendButton}"]`);
76+
77+
// WHEN: Click on the send button.
78+
host.click(sendBoxSendButton);
79+
80+
// THEN: Should focus on the send button, so the text box scroll bar should disappear.
81+
await waitFor(() => expect(document.activeElement).toBe(sendBoxSendButton));
4782

4883
// THEN: Should not send the activity.
4984
await host.snapshot();

0 commit comments

Comments
 (0)