forked from microsoft/BotFramework-WebChat
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
useSubmit() should function after reconnect (microsoft#4707)
* useSubmit() should function after reconnect * Add entry
- Loading branch information
Showing
6 changed files
with
101 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
<!DOCTYPE html> | ||
<html lang="en-US"> | ||
<head> | ||
<link href="/assets/index.css" rel="stylesheet" type="text/css" /> | ||
<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> | ||
</head> | ||
<body> | ||
<main id="webchat"></main> | ||
<script> | ||
run(async function () { | ||
const { directLine, store } = testHelpers.createDirectLineEmulator(); | ||
|
||
WebChat.renderWebChat( | ||
{ | ||
directLine, | ||
store | ||
}, | ||
document.getElementById('webchat') | ||
); | ||
|
||
await pageConditions.uiConnected(); | ||
|
||
// WHEN: Reconnecting. | ||
|
||
const { resolve } = directLine.emulateReconnect(); | ||
|
||
// THEN: Connectivity status should show "Network interruption occurred. Reconnecting…" | ||
|
||
await pageConditions.connectivityStatusShown('Network interruption occurred. Reconnecting…'); | ||
|
||
// --- | ||
|
||
// WHEN: Reconnected. | ||
|
||
resolve(); | ||
|
||
// THEN: Connectivity status should be hidden as it is connected. | ||
|
||
await pageConditions.became( | ||
'connectivity status is "connected"', | ||
// Connected means the element is not present. | ||
() => !pageElements.connectivityStatus(), | ||
1000 | ||
); | ||
|
||
// --- | ||
|
||
// WHEN: Send a message. | ||
|
||
const { resolveAll } = await directLine.actPostActivity(() => | ||
pageObjects.sendMessageViaSendBox('echo Hello, World!', { waitForSend: false }) | ||
); | ||
|
||
await resolveAll(); | ||
|
||
// THEN: Should send successfully. | ||
|
||
await pageConditions.allOutgoingActivitiesSent(); | ||
|
||
// THEN: Should show one message. | ||
|
||
await pageConditions.numActivitiesShown(1); | ||
|
||
// --- | ||
|
||
// WHEN: Bot send a message. | ||
|
||
await directLine.emulateIncomingActivity({ text: 'Aloha!', type: 'message' }); | ||
|
||
// THEN: Should show 2 messages. | ||
|
||
await pageConditions.numActivitiesShown(2); | ||
}); | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/** @jest-environment ./packages/test/harness/src/host/jest/WebDriverEnvironment.js */ | ||
|
||
test('after reconnect should send and receive message as usual', () => runHTML('chatAdapter.reconnect.html')); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters