-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Fix sorting activities when they are grouped in either part grouping or livestreaming #5635
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Changes from all commits
Commits
Show all changes
82 commits
Select commit
Hold shift + click to select a range
8b0c9f4
Add sorting upsert algorithm
compulim 314441f
With webchat:internal:position
compulim 19fcfed
Update comment
compulim 4195a6b
Redux store backcompat
compulim 72197a2
Add given-when-then
compulim e605f9c
Allow HowTo without position
compulim a1a504a
Upsert livestream activity based on sequence number
compulim aec404e
Should not move livestream if timestamp is undefined
compulim 75d8287
Fix tests
compulim fc072e6
Clean up Object.freeze()
compulim c88d8ee
Fix path
compulim ef734e8
Allow reuse position
compulim b6ea346
FIx update activity channel data
compulim 67cbec5
No reorder when concluding livestream does not have timestamp
compulim 821e623
Upsert as-is if no HowTo.position
compulim c18febb
Always reuse position including livestreaming
compulim 720afbf
Fix @id
compulim d2e9dc7
Fix typing indicator test with duplicate activity ID
compulim 826890c
Fix typing indicator scrolling test with duplicate activity ID
compulim 8df5f83
Fix typing indicator test with duplicate livestream activity ID
compulim 283303d
Fix collapsible test have bad livestreaming metadata
compulim 0987656
Remove CoT
compulim 8790431
Skip activity for finalized livestream
compulim fb343fe
Update position for plain activity
compulim f5ee565
Remove timestamp: undefined
compulim 3d591c3
Update timestamp algorithm
compulim 7854dc6
Sort by logical timestamp, followed by local timestamp
compulim 84449fd
Fix test: livestream finalize should move it to bottom
compulim 184441c
Honor timestamp on finalizing livestream activity
compulim 7d96a42
Fix dupe ID
compulim 92ce42b
Add a clock tick before sending another message
compulim d72be2a
Patch all activities with internal channel data and fix typing entrie…
compulim bf7b117
Clean up
compulim de2a60f
Update snapshots
compulim c3c166b
Fix test: finalizing livestream will update timestamp
compulim e8f863b
Add tick between outgoing activities
compulim 36f6016
Fix unit test
compulim 2312c42
Fix typings
compulim 0290e6e
Rename perma ID to local ID
compulim 2b3ddb3
Add comment
compulim a5053a0
Fix test: part grouping will always have updated timestamp
compulim 72f1db4
Rename permaId to localId
compulim dfe3033
Fix test: part grouping should use max timestamp
compulim 079a67d
Initial delete activity
compulim e295020
Rename activityInternalId to activityLocalId
compulim 033bd37
Add clean up after delete
compulim 9d4b846
Delete livestream activities
compulim 32c0395
Delete activities in part grouping with livestream
compulim b3af866
Reorganize tests
compulim 825dd23
Wire up delete activity
compulim 0505a64
Add clientActivityIdToLocalId index
compulim 222af7b
Update doc
compulim c08681c
Fix ESLint
compulim edb9e01
Add *.spec.* and *.test.*
compulim 290787c
Revert
compulim c84d2b2
Clean up comment
compulim ac2abfc
Use standard way to parse @id
compulim 7a5ed2a
Remove early return
compulim 9d94d3d
Add multiple part grouping test
compulim 36971af
Remove unnecessary findBeforeAfter
compulim 331b829
Typo
compulim 172dcaa
Update doc
compulim 12d42af
Fix part grouping ID
compulim f69df40
Update test: position to undefined should be unmoved
compulim 9308ec3
Refactor property types
compulim c448b87
Use property functions
compulim 287afdf
Fix part ID
compulim fee17b6
Local ID is blank node identifier
compulim f907902
Use node identifier schema for local ID
compulim 3fdd28c
Fix import path
compulim e9416a7
Fix local ID
compulim 003a9b9
Clean up
compulim 95dcdc5
Add typing to Map
compulim ec9888a
Clean up
compulim 24f81e6
Clean up with generateLocalIdInActivity
compulim 5c4cd4a
Remove unused BlankNodeIdentifier
compulim 068f16b
Clean up
compulim 1ea2b1c
Use queryLocalIdFromActivity for generateLocalIdInActivity
compulim 74cc311
Patch activity on POST_ACTIVITY_PENDING
compulim c12afba
Update PR number
compulim b58b263
Incorporate PR changes
compulim 37ce80f
Add related read
compulim File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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
108 changes: 108 additions & 0 deletions
108
__tests__/html2/activityOrdering/livestreamWithMovingTimestamp.html
This file contains hidden or 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,108 @@ | ||
| <!doctype html> | ||
| <html lang="en-US"> | ||
| <head> | ||
| <link href="/assets/index.css" rel="stylesheet" type="text/css" /> | ||
| </head> | ||
| <body> | ||
| <main id="webchat"></main> | ||
| <script type="importmap"> | ||
| { | ||
| "imports": { | ||
| "botframework-webchat": "/__dist__/packages/bundle/static/botframework-webchat.js", | ||
| "react": "/__dist__/packages/bundle/static/react.js", | ||
| "react-dom": "/__dist__/packages/bundle/static/react-dom.js" | ||
| } | ||
| } | ||
| </script> | ||
| <script type="module"> | ||
| import '/test-harness.mjs'; | ||
| import '/test-page-object.mjs'; | ||
|
|
||
| import { createDirectLine, createStoreWithOptions, renderWebChat } from 'botframework-webchat'; | ||
| import { version } from 'react'; | ||
|
|
||
| run(async function () { | ||
| const { | ||
| testHelpers: { createDirectLineEmulator } | ||
| } = window; | ||
|
|
||
| // TODO: This is for `createDirectLineEmulator` only, should find ways to eliminate this line. | ||
| window.WebChat = { createStoreWithOptions }; | ||
|
|
||
| const { directLine, store } = createDirectLineEmulator(); | ||
|
|
||
| renderWebChat({ directLine, store }, document.getElementById('webchat')); | ||
|
|
||
| await pageConditions.uiConnected(); | ||
|
|
||
| await directLine.emulateIncomingActivity({ | ||
| from: { role: 'bot' }, | ||
| id: 'a-00001', | ||
| text: 'Hello, World!', | ||
| timestamp: new Date(86_400_000).toISOString() | ||
| }); | ||
|
|
||
| await directLine.emulateIncomingActivity({ | ||
| channelData: { | ||
| streamSequence: 1, | ||
| streamType: 'streaming' | ||
| }, | ||
| from: { role: 'bot' }, | ||
| id: 'a-00002', | ||
| text: '`t=undefined`\n\nA quick', | ||
| timestamp: undefined, | ||
| type: 'typing' | ||
| }); | ||
|
|
||
| expect(pageElements.activityContents().map(({ textContent }) => textContent)).toEqual([ | ||
| 'Hello, World!', | ||
| 't=undefined\nA quick' | ||
| ]); | ||
|
|
||
| // THEN: Screenshot should show no timestamp below the second message. | ||
| await host.snapshot('local'); | ||
|
|
||
| await directLine.emulateIncomingActivity({ | ||
| channelData: { | ||
| streamId: 'a-00002', | ||
| streamSequence: 2, | ||
| streamType: 'streaming' | ||
| }, | ||
| from: { role: 'bot' }, | ||
| id: 'a-00003', | ||
| text: '`t=0`\n\nA quick brown fox', | ||
| timestamp: new Date(0).toISOString(), | ||
| type: 'typing' | ||
| }); | ||
|
|
||
| expect(pageElements.activityContents().map(({ textContent }) => textContent)).toEqual([ | ||
| 'Hello, World!', | ||
| 't=0\nA quick brown fox' | ||
| ]); | ||
|
|
||
| // THEN: Should show the livestream message on second position as it should not be moved. | ||
| await host.snapshot('local'); | ||
|
|
||
| await directLine.emulateIncomingActivity({ | ||
| channelData: { | ||
| streamId: 'a-00002', | ||
| streamType: 'final' | ||
| }, | ||
| from: { role: 'bot' }, | ||
| id: 'a-00004', | ||
| text: '`t=0`\n\nA quick brown fox jumped over the lazy dogs.', | ||
| timestamp: new Date(0).toISOString(), | ||
| type: 'message' | ||
| }); | ||
|
|
||
| // THEN: Should have the livestream message as the first one. | ||
| expect(pageElements.activityContents().map(({ textContent }) => textContent)).toEqual([ | ||
| 't=0\nA quick brown fox jumped over the lazy dogs.', | ||
| 'Hello, World!' | ||
| ]); | ||
|
|
||
| await host.snapshot('local'); | ||
| }); | ||
| </script> | ||
| </body> | ||
| </html> |
Binary file added
BIN
+9.71 KB
__tests__/html2/activityOrdering/livestreamWithMovingTimestamp.html.snap-1.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
+10.2 KB
__tests__/html2/activityOrdering/livestreamWithMovingTimestamp.html.snap-2.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
+12.5 KB
__tests__/html2/activityOrdering/livestreamWithMovingTimestamp.html.snap-3.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 contains hidden or 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 modified
BIN
+145 Bytes
(100%)
__tests__/html2/activityOrdering/partGroupingAtTheEndOfChatHistory.html.snap-3.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 modified
BIN
-3 Bytes
(100%)
__tests__/html2/activityOrdering/partGroupingAtTheEndOfChatHistory.html.snap-4.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 modified
BIN
-3 Bytes
(100%)
__tests__/html2/activityOrdering/partGroupingAtTheEndOfChatHistory.html.snap-5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
156 changes: 156 additions & 0 deletions
156
__tests__/html2/activityOrdering/partGroupingShouldUseMaxTimestamp.html
This file contains hidden or 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,156 @@ | ||
| <!doctype html> | ||
| <html lang="en-US"> | ||
| <head> | ||
| <link href="/assets/index.css" rel="stylesheet" type="text/css" /> | ||
| </head> | ||
| <body> | ||
| <main id="webchat"></main> | ||
| <script type="importmap"> | ||
| { | ||
| "imports": { | ||
| "botframework-webchat": "/__dist__/packages/bundle/static/botframework-webchat.js", | ||
| "jest-mock": "https://esm.sh/jest-mock", | ||
| "react": "/__dist__/packages/bundle/static/react.js", | ||
| "react-dom": "/__dist__/packages/bundle/static/react-dom.js" | ||
| } | ||
| } | ||
| </script> | ||
| <script type="module"> | ||
| import '/test-harness.mjs'; | ||
| import '/test-page-object.mjs'; | ||
| import { fn, spyOn } from 'jest-mock'; | ||
|
|
||
| import { createDirectLine, createStoreWithOptions, renderWebChat } from 'botframework-webchat'; | ||
| import { version } from 'react'; | ||
|
|
||
| const IGNORING_KEYWORDS = [ | ||
| 'Cannot update a component', | ||
| 'Support for defaultProps', | ||
| 'ReactDOM.render is no longer supported', | ||
| 'To locate the bad setState()', | ||
| 'has been deprecated, use `import {' | ||
| ]; | ||
|
|
||
| const error = console.error.bind(console); | ||
|
|
||
| spyOn(console, 'error').mockImplementation((...args) => { | ||
| const [message] = args; | ||
|
|
||
| if (typeof message === 'string' && IGNORING_KEYWORDS.some(keywords => message.includes(keywords))) { | ||
| return; | ||
| } | ||
|
|
||
| error(...args); | ||
| }); | ||
|
|
||
| run(async function () { | ||
| const { | ||
| testHelpers: { createDirectLineEmulator } | ||
| } = window; | ||
|
|
||
| // TODO: This is for `createDirectLineEmulator` only, should find ways to eliminate this line. | ||
| window.WebChat = { createStoreWithOptions }; | ||
|
|
||
| const { directLine, store } = createDirectLineEmulator(); | ||
|
|
||
| renderWebChat({ directLine, store }, document.getElementById('webchat')); | ||
|
|
||
| await pageConditions.uiConnected(); | ||
|
|
||
| await directLine.emulateIncomingActivity({ | ||
| channelData: { | ||
| streamSequence: 1, | ||
| streamType: 'streaming' | ||
| }, | ||
| entities: [ | ||
| { | ||
| '@context': 'https://schema.org', | ||
| '@id': '', | ||
| '@type': 'Message', | ||
| type: 'https://schema.org/Message', | ||
| isPartOf: { '@id': '_:c-00001', '@type': 'HowTo' } | ||
| } | ||
| ], | ||
| from: { role: 'bot' }, | ||
| id: 'a-00001', | ||
| text: 'Task 1 at t=0', | ||
| timestamp: new Date(0).toISOString(), | ||
| type: 'typing' | ||
| }); | ||
|
|
||
| expect(pageElements.activityContents().map(({ textContent }) => textContent)).toEqual(['Task 1 at t=0']); | ||
|
|
||
| await host.snapshot('local'); | ||
|
|
||
| await directLine.emulateIncomingActivity({ | ||
| channelData: { | ||
| streamId: 'a-00001', | ||
| streamSequence: 2, | ||
| streamType: 'streaming' | ||
| }, | ||
| entities: [ | ||
| { | ||
| '@context': 'https://schema.org', | ||
| '@id': '', | ||
| '@type': 'Message', | ||
| type: 'https://schema.org/Message', | ||
| isPartOf: { '@id': '_:c-00001', '@type': 'HowTo' } | ||
| } | ||
| ], | ||
| from: { role: 'bot' }, | ||
| id: 'a-00002', | ||
| text: 'Task 1 at t=10', | ||
| timestamp: new Date(10).toISOString(), | ||
| type: 'typing' | ||
| }); | ||
|
|
||
| expect(pageElements.activityContents().map(({ textContent }) => textContent)).toEqual(['Task 1 at t=10']); | ||
|
|
||
| await host.snapshot('local'); | ||
|
|
||
| await directLine.emulateIncomingActivity({ | ||
| entities: [ | ||
| { | ||
| '@context': 'https://schema.org', | ||
| '@id': '', | ||
| '@type': 'Message', | ||
| type: 'https://schema.org/Message', | ||
| isPartOf: { '@id': '_:c-00001', '@type': 'HowTo' } | ||
| } | ||
| ], | ||
| from: { role: 'bot' }, | ||
| id: 'a-00003', | ||
| text: 'Task 2 at t=20', | ||
| timestamp: new Date(20).toISOString(), | ||
| type: 'message' | ||
| }); | ||
|
|
||
| expect(pageElements.activityContents().map(({ textContent }) => textContent)).toEqual([ | ||
| 'Task 1 at t=10', | ||
| 'Task 2 at t=20' | ||
| ]); | ||
|
|
||
| await host.snapshot('local'); | ||
|
|
||
| await directLine.emulateIncomingActivity({ | ||
| from: { role: 'bot' }, | ||
| id: 'a-00004', | ||
| text: 'Hello, World at t=15', | ||
| timestamp: new Date(15).toISOString() | ||
| }); | ||
|
|
||
| // Part grouping timestamp is t=20 (max of all parts.) | ||
| // "Hello, World" is t=15. | ||
| // Thus, "Hello, World" appear before part grouping. | ||
|
|
||
| expect(pageElements.activityContents().map(({ textContent }) => textContent)).toEqual([ | ||
| 'Hello, World at t=15', | ||
| 'Task 1 at t=10', | ||
| 'Task 2 at t=20' | ||
| ]); | ||
|
|
||
| await host.snapshot('local'); | ||
| }); | ||
| </script> | ||
| </body> | ||
| </html> |
Binary file added
BIN
+10.1 KB
__tests__/html2/activityOrdering/partGroupingShouldUseMaxTimestamp.html.snap-1.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
+10.1 KB
__tests__/html2/activityOrdering/partGroupingShouldUseMaxTimestamp.html.snap-2.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
+11.6 KB
__tests__/html2/activityOrdering/partGroupingShouldUseMaxTimestamp.html.snap-3.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
+13.5 KB
__tests__/html2/activityOrdering/partGroupingShouldUseMaxTimestamp.html.snap-4.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 modified
BIN
-18 Bytes
(100%)
__tests__/html2/livestream/activityOrder.entity.html.snap-5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.