-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Livestreaming typing animation (#5141)
* Rename typing indicator BEM class * Add typingIndicator * Add useAllTyping to replace typing reducer * Fix useAllTyping * Display typing activities * Display typing activities * Multiple activities under one activity key * Clean up * Use activity revisions instead of typing * Add activityOrder test * Fix activity order * Fix tests * Simplify * Clean up * Add simultaneous test * Hide typing indicator for chunked * Fix tests * Clean up * Add tests * Clean up * Add tests * Clean up * Clean up * Clean up * Add out-of-order test * Fix out-of-order * Reduce number of render * Remove use-propagate * Add comments * Fix tests * Fix tests * Migrate test * Fix test * Add initial value * Add channelData.styleOptions.typingIndicatorDuration * Add entries * Fix streamSequence for OOO * Rename streamMode to streamType * Add informative message * Simplify typing structure * Typo * Add `type` property to `useActiveTyping` * Rename "indicator" to "busy" * Move reduceIterable to /hooks * Fix tests * Add useActiveTyping test for livestream * Fix typing structure and add snapshots * isLivestream should return false for informative message * Add snapshot * Clean up * Clean up * Add comment * Add livestream related channelData to "message" activity * Add comment * Clean up isPartOfLivestreamSession * Add notable changes * Explain semver * Rename to isLivestreamChunk * Rename to "receivedAt" from "appearAt" * Add docs * Better grammar * Add undefined * Add more hooks * Typo * Memoize empty array
- Loading branch information
Showing
101 changed files
with
2,730 additions
and
217 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
Binary file added
BIN
+14.9 KB
...-multiple-messages-should-sort-typing-activity-in-its-original-order-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+21.6 KB
...-multiple-messages-should-sort-typing-activity-in-its-original-order-2-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+22.9 KB
...-multiple-messages-should-sort-typing-activity-in-its-original-order-3-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+24.5 KB
...-multiple-messages-should-sort-typing-activity-in-its-original-order-4-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+26.1 KB
...-multiple-messages-should-sort-typing-activity-in-its-original-order-5-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+14.9 KB
.../html/chunk-js-bot-typing-with-chunks-should-display-partial-message-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+16.2 KB
.../html/chunk-js-bot-typing-with-chunks-should-display-partial-message-2-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+17.7 KB
.../html/chunk-js-bot-typing-with-chunks-should-display-partial-message-3-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+19.4 KB
.../html/chunk-js-bot-typing-with-chunks-should-display-partial-message-4-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+15.1 KB
...ve-js-informative-typing-message-should-be-shown-as-typing-indicator-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+14.9 KB
...t-of-order-fashion-should-sort-typing-activity-in-its-original-order-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+17.7 KB
...t-of-order-fashion-should-sort-typing-activity-in-its-original-order-2-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+17.7 KB
...t-of-order-fashion-should-sort-typing-activity-in-its-original-order-3-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+19.4 KB
...t-of-order-fashion-should-sort-typing-activity-in-its-original-order-4-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+14.9 KB
...on-should-sort-typing-activity-based-on-channel-data-sequence-number-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+17.7 KB
...on-should-sort-typing-activity-based-on-channel-data-sequence-number-2-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+17.7 KB
...on-should-sort-typing-activity-based-on-channel-data-sequence-number-3-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+19.4 KB
...on-should-sort-typing-activity-based-on-channel-data-sequence-number-4-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+14.9 KB
...ml/simultaneous-js-bot-typing-multiple-messages-should-work-properly-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+17.1 KB
...ml/simultaneous-js-bot-typing-multiple-messages-should-work-properly-2-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+18.4 KB
...ml/simultaneous-js-bot-typing-multiple-messages-should-work-properly-3-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+20.4 KB
...ml/simultaneous-js-bot-typing-multiple-messages-should-work-properly-4-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+23.6 KB
...ml/simultaneous-js-bot-typing-multiple-messages-should-work-properly-5-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+26.3 KB
...ml/simultaneous-js-bot-typing-multiple-messages-should-work-properly-6-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file was deleted.
Oops, something went wrong.
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,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/[email protected]/babel.min.js"></script> | ||
<script crossorigin="anonymous" src="https://unpkg.com/[email protected]/umd/react.development.js"></script> | ||
<script crossorigin="anonymous" src="https://unpkg.com/[email protected]/umd/react-dom.development.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> | ||
</head> | ||
<body> | ||
<main id="webchat"></main> | ||
<script type="text/babel" data-presets="env,stage-3,react"> | ||
const { | ||
WebChat: { | ||
Components: { BasicWebChat, Composer }, | ||
hooks: { useActiveTyping } | ||
} | ||
} = window; | ||
|
||
run(async function () { | ||
const clock = lolex.createClock(); | ||
|
||
const { directLine, store } = testHelpers.createDirectLineEmulator({ ponyfill: clock }); | ||
|
||
const RunFunction = ({ fn }) => { | ||
fn(); | ||
|
||
return false; | ||
}; | ||
|
||
const renderWithFunction = fn => | ||
new Promise(resolve => | ||
ReactDOM.render( | ||
<Composer directLine={directLine} ponyfill={clock} sendTypingIndicator={true} store={store}> | ||
<BasicWebChat /> | ||
<RunFunction fn={() => resolve(fn && fn())} key={Date.now() + ''} /> | ||
</Composer>, | ||
document.getElementById('webchat') | ||
) | ||
); | ||
|
||
await renderWithFunction(); | ||
|
||
await pageConditions.webChatRendered(); | ||
|
||
clock.tick(600); | ||
|
||
// WHEN: At initial. | ||
await pageConditions.uiConnected(); | ||
|
||
// THEN: `useActiveTyping` should return nothing. | ||
await expect(renderWithFunction(() => useActiveTyping())).resolves.toEqual([{}]); | ||
|
||
// WHEN: Bot livestream. | ||
await directLine.emulateIncomingActivity({ | ||
from: { | ||
id: 'bot', | ||
name: 'Bot', | ||
role: 'bot' | ||
}, | ||
text: 'Et est esse aliqua culpa quis laboris exercitation voluptate dolor.', | ||
type: 'typing' | ||
}); | ||
|
||
// THEN: `useActiveTyping` should return the livestream from the bot. | ||
await expect(renderWithFunction(() => useActiveTyping())).resolves.toEqual([ | ||
{ | ||
bot: { | ||
at: 600, | ||
expireAt: 5600, | ||
name: 'Bot', | ||
role: 'bot', | ||
type: 'livestream' | ||
} | ||
} | ||
]); | ||
}); | ||
</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,5 @@ | ||
/** @jest-environment ./packages/test/harness/src/host/jest/WebDriverEnvironment.js */ | ||
|
||
describe('useActiveTyping', () => { | ||
test('should get bot livestream', () => runHTML('hooks.useActiveTyping.livestream.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
51 changes: 51 additions & 0 deletions
51
__tests__/html/hooks/useTypingIndicatorVisible/getter.botTyping.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,51 @@ | ||
<!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/babel.min.js"></script> | ||
<script crossorigin="anonymous" src="https://unpkg.com/[email protected]/umd/react.production.min.js"></script> | ||
<script crossorigin="anonymous" src="https://unpkg.com/[email protected]/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> | ||
</head> | ||
<body> | ||
<main id="webchat"></main> | ||
<script type="text/babel"> | ||
run(async function () { | ||
const { | ||
ReactDOM: { render }, | ||
WebChat: { | ||
Components: { BasicWebChat, Composer }, | ||
hooks: { useTypingIndicatorVisible } | ||
} | ||
} = window; // Imports in UMD fashion. | ||
|
||
const directLine = WebChat.createDirectLine({ token: await testHelpers.token.fetchDirectLineToken() }); | ||
const store = testHelpers.createStore(); | ||
|
||
let typingIndicatorVisible; | ||
|
||
const RunFunction = () => { | ||
[typingIndicatorVisible] = useTypingIndicatorVisible(); | ||
|
||
return false; | ||
}; | ||
|
||
render( | ||
<Composer directLine={directLine} store={store}> | ||
<BasicWebChat /> | ||
<RunFunction /> | ||
</Composer>, | ||
document.getElementById('webchat') | ||
); | ||
|
||
await pageConditions.uiConnected(); | ||
await pageObjects.sendMessageViaSendBox('typing 1'); | ||
await pageConditions.numActivitiesShown(2); | ||
|
||
expect(typingIndicatorVisible).toBe(true); | ||
}); | ||
</script> | ||
</body> | ||
</html> |
5 changes: 5 additions & 0 deletions
5
__tests__/html/hooks/useTypingIndicatorVisible/getter.botTyping.js
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,5 @@ | ||
/** @jest-environment ./packages/test/harness/src/host/jest/WebDriverEnvironment.js */ | ||
|
||
describe('useTypingIndicatorVisible', () => { | ||
test('getter should return true when typing indicator is shown', () => runHTML('hooks/useTypingIndicatorVisible/getter.botTyping.html')); | ||
}); |
Oops, something went wrong.