-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Fix initial failed-send live region crash #5848
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
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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
86 changes: 86 additions & 0 deletions
86
__tests__/html2/activityStatus/rehydrateSendFailedRetry.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,86 @@ | ||
| <!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="https://cdn.jsdelivr.net/npm/react@18/umd/react.production.min.js"></script> | ||
| <script | ||
| crossorigin="anonymous" | ||
| src="https://cdn.jsdelivr.net/npm/react-dom@18/umd/react-dom.production.min.js" | ||
| ></script> | ||
| <script crossorigin="anonymous" src="/__dist__/webchat-es5.js"></script> | ||
| </head> | ||
| <body> | ||
| <main id="webchat"></main> | ||
| <script type="module"> | ||
| import { expect } from 'https://esm.sh/expect?standalone'; | ||
| import { waitFor } from 'https://esm.sh/@testduet/wait-for'; | ||
|
|
||
| const { | ||
| React: { createElement }, | ||
| ReactDOM: { createRoot }, | ||
| testHelpers: { createDirectLineEmulator }, | ||
| WebChat: { createDirectLine, createStoreWithOptions, hooks, ReactWebChat } | ||
| } = window; | ||
|
|
||
| // This test only fail in 4.18.0. | ||
| // After we moved to graph backend in 4.19.0, this test no longer fail. | ||
| // This is because the graph backend do not rehydrate activities immediately until after first render. | ||
| // Thus, we are not hitting the JavaScript error related to `(undefined).has()`. | ||
|
|
||
| run( | ||
| async function () { | ||
| const { directLine: directLine1, store: store1 } = createDirectLineEmulator(); | ||
|
|
||
| const root1 = createRoot(document.getElementById('webchat')); | ||
|
|
||
| root1.render(createElement(ReactWebChat, { directLine: directLine1, store: store1 })); | ||
|
|
||
| await pageConditions.uiConnected(); | ||
|
|
||
| const sendMessage = await directLine1.emulateOutgoingActivity('Hello, World!'); | ||
|
|
||
| sendMessage.rejectPostActivity(new Error('artificial error')); | ||
|
|
||
| // Initially, the send-status is "sending", we need to wait until it turns into "send failed". | ||
| await waitFor(() => | ||
| expect(store1.getState().activities[0].channelData['webchat:send-status']).toBe('send failed') | ||
| ); | ||
|
|
||
| await host.snapshot('local'); | ||
|
|
||
| const state = store1.getState(); | ||
|
|
||
| root1.unmount(); | ||
|
|
||
| const root2 = createRoot(document.getElementById('webchat')); | ||
|
|
||
| const { directLine: directLine2, store: store2 } = testHelpers.createDirectLineEmulator({ | ||
| initialState: state | ||
| }); | ||
|
|
||
| root2.render( | ||
| createElement(ReactWebChat, { | ||
| directLine: directLine2, | ||
| store: store2 | ||
| }) | ||
| ); | ||
|
|
||
| await Promise.race([ | ||
| pageConditions.uiConnected(), | ||
| new Promise((_, reject) => | ||
| setTimeout( | ||
| () => reject(new Error('Timed out waiting for chat history to show, possibly JavaScript error')), | ||
| 500 | ||
| ) | ||
| ) | ||
| ]); | ||
|
|
||
| await host.snapshot('local'); | ||
| }, | ||
| { ignoreErrors: true } | ||
| ); | ||
| </script> | ||
| </body> | ||
| </html> |
Binary file added
BIN
+7.87 KB
__tests__/html2/activityStatus/rehydrateSendFailedRetry.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
+7.87 KB
__tests__/html2/activityStatus/rehydrateSendFailedRetry.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.
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
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.