-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Fix retry button not working but show "Render error" #5838
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
Open
compulim
wants to merge
5
commits into
microsoft:main
Choose a base branch
from
compulim:fix-send-failed-retry
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 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
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,135 @@ | ||
| <!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> | ||
| function activityStatusInnerTextContained(expectedInnerTextPattern, index = 0) { | ||
| return pageConditions.became( | ||
| `Activity status should contains "${expectedInnerTextPattern}"`, | ||
| () => pageElements.activityStatuses()[index].innerText.includes(expectedInnerTextPattern), | ||
| 1000 | ||
| ); | ||
| } | ||
|
|
||
| function activityChannelDataStateBecame(expectedState, index = 0) { | ||
| if (typeof expectedState === 'undefined') { | ||
| return pageConditions.became( | ||
| `Activity "channelData.state" should be undefined`, | ||
| () => !('state' in pageObjects.getActivities()[index].channelData), | ||
| 1000 | ||
| ); | ||
| } | ||
|
|
||
| return pageConditions.became( | ||
| `Activity "channelData.state" should be "${expectedState}"`, | ||
| () => pageObjects.getActivities()[index].channelData?.state === expectedState, | ||
| 1000 | ||
| ); | ||
| } | ||
|
|
||
| function activityChannelDataWebChatSendStatusBecame(expectedSendStatus, index = 0) { | ||
| return pageConditions.became( | ||
| `Activity "channelData['webchat:send-status']" should be "${expectedSendStatus}"`, | ||
| () => pageObjects.getActivities()[index].channelData?.['webchat:send-status'] === expectedSendStatus, | ||
| 1000 | ||
| ); | ||
| } | ||
|
|
||
| run( | ||
| async function () { | ||
| const clock = lolex.createClock(); | ||
|
|
||
| const { directLine, store } = testHelpers.createDirectLineEmulator({ ponyfill: clock }); | ||
|
|
||
| WebChat.renderWebChat( | ||
| { | ||
| directLine, | ||
| ponyfill: clock, | ||
| store, | ||
| styleOptions: { spinnerAnimationBackgroundImage: 'url(/assets/staticspinner.png)' } | ||
| }, | ||
| document.getElementById('webchat') | ||
| ); | ||
|
|
||
| await pageConditions.webChatRendered(); | ||
|
|
||
| clock.tick(400); | ||
|
|
||
| // SETUP: Send a message and resolve the call to `postActivity()`. | ||
| await pageConditions.uiConnected(); | ||
|
|
||
| const sendMessage = await directLine.actPostActivity( | ||
| () => pageObjects.sendMessageViaSendBox('Hello, World!', { waitForSend: false }), | ||
| { id: 'a00001' } | ||
| ); | ||
|
|
||
| // THEN: `channelData.state` should be "sending". | ||
| await activityChannelDataStateBecame('sending'); | ||
|
|
||
| // THEN: `channelData['webchat:send-status']` should be "sending". | ||
| await activityChannelDataWebChatSendStatusBecame('sending'); | ||
|
|
||
| // THEN: The message should have status of "Sending". | ||
| await activityStatusInnerTextContained('Sending'); | ||
|
|
||
| // THEN: It should match snapshot. | ||
| await host.snapshot('local'); | ||
|
|
||
| // WHEN: After 20 seconds. | ||
| clock.tick(20000); | ||
|
|
||
| // THEN: `channelData.state` should be "send failed". | ||
| await activityChannelDataStateBecame('send failed'); | ||
|
|
||
| // THEN: `channelData['webchat:send-status']` should be "sending". | ||
| await activityChannelDataWebChatSendStatusBecame('sending'); | ||
|
|
||
| // THEN: The message should have status of "Send failed. Retry." | ||
| // This is because the message passed 20s as defined in `styleOptions.sendTimeout`. | ||
| await activityStatusInnerTextContained('Send failed. Retry.'); | ||
|
|
||
| // THEN: It should match snapshot. | ||
| await host.snapshot('local'); | ||
|
|
||
| // WHEN: The retry button is clicked. | ||
| const sendMessageRetry = await directLine.actPostActivity(() => | ||
| host.click(pageElements.activityStatuses()[0].querySelector('button')) | ||
| ); | ||
|
|
||
| // THEN: It should show 2 outgoing messages. | ||
| await pageConditions.numActivitiesShown(2); | ||
|
|
||
| // THEN: It should match snapshot. | ||
| await host.snapshot('local'); | ||
|
|
||
| // WHEN: The first outgoing message is sent. | ||
| await sendMessage.resolveAll(); | ||
|
|
||
| // THEN: The activity status of the first message should be "Just now." | ||
| await activityStatusInnerTextContained('Just now', 0); | ||
| await activityStatusInnerTextContained('Sending', 1); | ||
|
|
||
| // THEN: It should match snapshot. | ||
| await host.snapshot('local'); | ||
|
|
||
| // WHEN: The second outgoing message is sent. | ||
| await sendMessageRetry.resolveAll(); | ||
|
|
||
| // THEN: The activity status of the second message should be "Just now." | ||
| await activityStatusInnerTextContained('Just now', 0); | ||
| await activityStatusInnerTextContained('Just now', 1); | ||
|
|
||
| // THEN: It should match snapshot. | ||
| await host.snapshot('local'); | ||
| }, | ||
| { ignoreErrors: true } | ||
| ); | ||
| </script> | ||
| </body> | ||
| </html> | ||
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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.