-
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.
Add Reconnect UI to ConnectivityStatus when connection has been inter…
…rupted (#1895) * Move HowToQuestions.md to root .github * Minor copy update to English strings * Add Reconnecting component to ConectivityStatus * Add tests and screencaptures * Rewrite ConnectivityStatus * Refactor * More refactoring * Refactor 3 * Add transparency to offlineUI tests * More ConnectivityStatus refactor * Fix 1831: ability to change Spinner and Typing indicator via defaultStyles * Fix offlineUI tests with static spinner * Fix test with static spinner
- Loading branch information
Corina
authored
Apr 20, 2019
1 parent
4172154
commit 09536a5
Showing
21 changed files
with
338 additions
and
209 deletions.
There are no files selected for viewing
File renamed without changes.
Binary file added
BIN
+9.92 KB
...rruption-occurred-reconnecting-status-when-connection-is-interrupted-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 modified
BIN
-6 Bytes
(100%)
...he-connecting-connectivity-status-when-connecting-for-the-first-time-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.
File renamed without changes
Binary file added
BIN
+8.81 KB
...how-taking-longer-than-usual-to-connect-ui-when-reconnection-is-slow-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.
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 |
---|---|---|
@@ -1,6 +1,7 @@ | ||
import { By, Condition, Key } from 'selenium-webdriver'; | ||
|
||
import { imageSnapshotOptions, timeouts } from './constants.json'; | ||
import staticSpinner from './setup/assets/staticSpinner'; | ||
import uiConnected from './setup/conditions/uiConnected'; | ||
|
||
// selenium-webdriver API doc: | ||
|
@@ -18,9 +19,17 @@ const allOutgoingMessagesFailed = new Condition('All outgoing messages to fail s | |
}); | ||
|
||
describe('offline UI', async () => { | ||
test('should show "slow to connect" UI when connection is slow', async () => { | ||
test('should show "taking longer than usual to connect" UI when connection is slow', async () => { | ||
|
||
const WEB_CHAT_PROPS = { styleOptions: { spinnerAnimationBackgroundImage: staticSpinner } }; | ||
|
||
const { driver } = await setupWebDriver({ | ||
props: { WEB_CHAT_PROPS }, | ||
createDirectLine: options => { | ||
// This part of code is running in the JavaScript VM in Chromium. | ||
// This variable must be declared within scope | ||
const ONLINE = 2; | ||
|
||
const workingDirectLine = window.WebChat.createDirectLine(options); | ||
|
||
return { | ||
|
@@ -32,7 +41,7 @@ describe('offline UI', async () => { | |
complete: () => observer.complete(), | ||
error: err => observer.error(err), | ||
next: connectionStatus => { | ||
connectionStatus !== 2 && observer.next(connectionStatus); | ||
connectionStatus !== ONLINE && observer.next(connectionStatus); | ||
} | ||
}); | ||
|
||
|
@@ -177,24 +186,79 @@ describe('offline UI', async () => { | |
}); | ||
|
||
test('should display the "Connecting..." connectivity status when connecting for the first time', async() => { | ||
const WEB_CHAT_PROPS = { spinnerAnimationBackgroundImage: staticSpinner }; | ||
|
||
const { driver } = await setupWebDriver({ | ||
props: WEB_CHAT_PROPS, | ||
createDirectline: options => { | ||
// This part of code is running in the JavaScript VM in Chromium. | ||
// This Direct Line Connection Status variable must be declared within scope | ||
const UNINITIALIZED = 0; | ||
|
||
const workingDirectLine = window.WebChat.createDirectLine(options); | ||
|
||
return { | ||
activity$: workingDirectLine.activity$, | ||
postActivity: workingDirectLine.postActivity.bind(workingDirectLine), | ||
|
||
connectionStatus$: new Observable(observer => { | ||
const subscription = workingDirectLine.connectionStatus$.subscribe( { | ||
const subscription = workingDirectLine.connectionStatus$.subscribe({ | ||
complete: () => observer.complete(), | ||
error: err => observer.error(err), | ||
next: connectionStatus => { | ||
connectionStatus === UNINITIALIZED && observer.next(connectionStatus); | ||
} | ||
}); | ||
|
||
return () => subscription.unsubscribe(); | ||
}) | ||
}; | ||
}, | ||
pingBotOnLoad: false, | ||
setup: () => new Promise(resolve => { | ||
const scriptElement = document.createElement('script'); | ||
|
||
scriptElement.onload = resolve; | ||
scriptElement.setAttribute('src', 'https://unpkg.com/[email protected]/client/core.min.js'); | ||
|
||
document.head.appendChild(scriptElement); | ||
|
||
}) | ||
}); | ||
|
||
const base64PNG = await driver.takeScreenshot(); | ||
expect(base64PNG).toMatchImageSnapshot(imageSnapshotOptions); | ||
}); | ||
|
||
test('should display "Network interruption occurred. Reconnecting…" status when connection is interrupted', async () => { | ||
const WEB_CHAT_PROPS = { styleOptions: { spinnerAnimationBackgroundImage: staticSpinner } }; | ||
|
||
const { driver } = await setupWebDriver({ | ||
props: { WEB_CHAT_PROPS }, | ||
createDirectLine: options => { | ||
// This part of code is running in the JavaScript VM in Chromium. | ||
// These Direct Line Connection Status variables must be declared within scope | ||
const CONNECTING = 1; | ||
|
||
const ONLINE = 2; | ||
|
||
const reconnectingDirectLine = window.WebChat.createDirectLine(options); | ||
|
||
return { | ||
activity$: reconnectingDirectLine.activity$, | ||
postActivity: reconnectingDirectLine.postActivity.bind(reconnectingDirectLine), | ||
|
||
connectionStatus$: new Observable(observer => { | ||
const subscription = reconnectingDirectLine.connectionStatus$.subscribe({ | ||
complete: () => observer.complete(), | ||
error: err => observer.error(err), | ||
next: connectionStatus => { | ||
connectionStatus == 1 && observer.next(connectionStatus); | ||
observer.next(connectionStatus); | ||
connectionStatus === ONLINE && observer.next(CONNECTING); | ||
} | ||
}); | ||
|
||
return subscription.unsubscribe(); | ||
return () => subscription.unsubscribe(); | ||
}) | ||
}; | ||
}, | ||
|
@@ -206,12 +270,58 @@ describe('offline UI', async () => { | |
scriptElement.setAttribute('src', 'https://unpkg.com/[email protected]/client/core.min.js'); | ||
|
||
document.head.appendChild(scriptElement); | ||
}) | ||
}); | ||
|
||
await driver.sleep(600); | ||
const base64PNG = await driver.takeScreenshot(); | ||
expect(base64PNG).toMatchImageSnapshot(imageSnapshotOptions); | ||
}); | ||
|
||
test('should show "Taking longer than usual to connect" UI when reconnection is slow', async () => { | ||
const { driver } = await setupWebDriver({ | ||
createDirectLine: options => { | ||
// This part of code is running in the JavaScript VM in Chromium. | ||
// These Direct Line Connection Status variables must be declared within scope | ||
const CONNECTING = 1; | ||
|
||
const ONLINE = 2; | ||
|
||
const reconnectingDirectLine = window.WebChat.createDirectLine(options); | ||
|
||
return { | ||
activity$: reconnectingDirectLine.activity$, | ||
postActivity: reconnectingDirectLine.postActivity.bind(reconnectingDirectLine), | ||
|
||
connectionStatus$: new Observable(observer => { | ||
const subscription = reconnectingDirectLine.connectionStatus$.subscribe({ | ||
complete: () => observer.complete(), | ||
error: err => observer.error(err), | ||
next: connectionStatus => { | ||
observer.next(connectionStatus); | ||
connectionStatus === ONLINE && observer.next(CONNECTING); | ||
} | ||
}); | ||
|
||
return () => subscription.unsubscribe(); | ||
}) | ||
}; | ||
}, | ||
pingBotOnLoad: false, | ||
setup: () => new Promise(resolve => { | ||
const scriptElement = document.createElement('script'); | ||
|
||
scriptElement.onload = resolve; | ||
scriptElement.setAttribute('src', 'https://unpkg.com/[email protected]/client/core.min.js'); | ||
|
||
document.head.appendChild(scriptElement); | ||
}) | ||
}); | ||
|
||
await driver.sleep(17000); | ||
|
||
const base64PNG = await driver.takeScreenshot(); | ||
|
||
// Snapshots are intentionally not compared because the spinner will cause the snapshot to fail regularly | ||
expect(base64PNG).toMatchImageSnapshot(imageSnapshotOptions); | ||
}); | ||
}); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
19 changes: 8 additions & 11 deletions
19
packages/component/src/Attachment/Assets/SpinnerAnimation.js
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.