-
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.
New message indicator only show up for new messages (#2915)
* Show new message only when items arrive * Flush * Add tests * Update entry * Fix ESLint * Fix tests * Fix tests * Fix tests * Apply PR suggestions * Fix ESLint
- Loading branch information
Showing
21 changed files
with
187 additions
and
12 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
Binary file modified
BIN
-2.16 KB
(93%)
...aste-in-the-send-box-when-focus-is-on-a-text-box-of-an-adaptive-card-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
-2.16 KB
(93%)
...type-in-the-send-box-when-focus-is-on-a-text-box-of-an-adaptive-card-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 removed
BIN
-48 KB
...licking-new-messages-button-should-scroll-to-end-and-stick-to-bottom-1-snap.png
Binary file not shown.
Binary file removed
BIN
-37.1 KB
...licking-new-messages-button-should-scroll-to-end-and-stick-to-bottom-2-snap.png
Binary file not shown.
File renamed without changes
Binary file added
BIN
+48.1 KB
...oll-to-bottom-js-show-new-messages-button-only-when-new-message-come-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
+50.4 KB
...oll-to-bottom-js-show-new-messages-button-only-when-new-message-come-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
+40 KB
...oll-to-bottom-js-show-new-messages-button-only-when-new-message-come-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
+48.1 KB
...oll-to-bottom-js-show-new-messages-button-only-when-new-message-come-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
+36.2 KB
...oll-to-bottom-js-show-new-messages-button-only-when-new-message-come-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 modified
BIN
+53 Bytes
(100%)
...e-docker/style-options-js-style-options-hide-scroll-to-bottom-button-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
+52 Bytes
(100%)
...e-docker/style-options-js-style-options-hide-scroll-to-bottom-button-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 modified
BIN
+2.37 KB
(100%)
...cker/use-scroll-to-end-js-calling-scroll-to-end-should-scroll-to-end-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
+2.85 KB
(110%)
...cker/use-scroll-to-end-js-calling-scroll-to-end-should-scroll-to-end-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 modified
BIN
-2.45 KB
(95%)
...__/chrome-docker/use-text-box-js-calling-submit-should-scroll-to-end-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 |
---|---|---|
|
@@ -11,7 +11,29 @@ import uiConnected from '../setup/conditions/uiConnected'; | |
jest.setTimeout(timeouts.test); | ||
|
||
test('calling scrollToEnd should scroll to end', async () => { | ||
const { driver, pageObjects } = await setupWebDriver(); | ||
const { driver, pageObjects } = await setupWebDriver({ | ||
createDirectLine: options => { | ||
const workingDirectLine = window.WebChat.createDirectLine(options); | ||
|
||
return { | ||
activity$: new Observable(activityObserver => { | ||
window.WebChatTest.activityObserver = activityObserver; | ||
|
||
const subscription = workingDirectLine.activity$.subscribe({ | ||
complete: () => activityObserver.complete(), | ||
error: value => activityObserver.error(value), | ||
next: value => activityObserver.next(value) | ||
}); | ||
|
||
return () => subscription.unsubscribe(); | ||
}), | ||
connectionStatus$: workingDirectLine.connectionStatus$, | ||
postActivity: workingDirectLine.postActivity.bind(workingDirectLine), | ||
token: workingDirectLine.token | ||
}; | ||
}, | ||
setup: () => window.WebChatTest.loadScript('https://unpkg.com/[email protected]/client/core.min.js') | ||
}); | ||
|
||
await driver.wait(uiConnected(), timeouts.directLine); | ||
|
||
|
@@ -21,6 +43,17 @@ test('calling scrollToEnd should scroll to end', async () => { | |
|
||
await pageObjects.scrollToTop(); | ||
|
||
await driver.executeScript(() => { | ||
window.WebChatTest.activityObserver.next({ | ||
from: { | ||
id: 'bot', | ||
role: 'bot' | ||
}, | ||
text: 'Hello, World!', | ||
type: 'message' | ||
}); | ||
}); | ||
|
||
await driver.wait(scrollToBottomButtonVisible(), timeouts.ui); | ||
|
||
expect(await driver.takeScreenshot()).toMatchImageSnapshot(imageSnapshotOptions); | ||
|
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 |
---|---|---|
|
@@ -3,6 +3,7 @@ import { By } from 'selenium-webdriver'; | |
import { imageSnapshotOptions, timeouts } from './constants.json'; | ||
|
||
import minNumActivitiesShown from './setup/conditions/minNumActivitiesShown'; | ||
import negationOf from './setup/conditions/negationOf'; | ||
import scrollToBottomButtonVisible from './setup/conditions/scrollToBottomButtonVisible'; | ||
import scrollToBottomCompleted from './setup/conditions/scrollToBottomCompleted'; | ||
import suggestedActionsShown from './setup/conditions/suggestedActionsShown'; | ||
|
@@ -36,7 +37,7 @@ test('should stick to bottom if submitting an Adaptive Card while suggested acti | |
expect(base64PNG).toMatchImageSnapshot(imageSnapshotOptions); | ||
}); | ||
|
||
test('clicking "New messages" button should scroll to end and stick to bottom', async () => { | ||
test('should scroll to bottom on send', async () => { | ||
const { driver, pageObjects } = await setupWebDriver(); | ||
|
||
await driver.wait(uiConnected(), timeouts.directLine); | ||
|
@@ -47,17 +48,98 @@ test('clicking "New messages" button should scroll to end and stick to bottom', | |
|
||
await pageObjects.scrollToTop(); | ||
|
||
await driver.wait(negationOf(scrollToBottomButtonVisible()), timeouts.ui); | ||
|
||
// Should scroll to bottom on send | ||
|
||
await pageObjects.sendMessageViaSendBox('Hello, World!'); | ||
await driver.wait(scrollToBottomCompleted(), timeouts.scrollToBottom); | ||
|
||
await driver.wait(minNumActivitiesShown(4), timeouts.directLine); | ||
|
||
expect(await driver.takeScreenshot()).toMatchImageSnapshot(imageSnapshotOptions); | ||
}); | ||
|
||
test('show "New messages" button only when new message come', async () => { | ||
const { driver, pageObjects } = await setupWebDriver({ | ||
createDirectLine: options => { | ||
const workingDirectLine = window.WebChat.createDirectLine(options); | ||
|
||
return { | ||
activity$: new Observable(activityObserver => { | ||
window.WebChatTest.activityObserver = activityObserver; | ||
|
||
const subscription = workingDirectLine.activity$.subscribe({ | ||
complete: () => activityObserver.complete(), | ||
error: value => activityObserver.error(value), | ||
next: value => activityObserver.next(value) | ||
}); | ||
|
||
return () => subscription.unsubscribe(); | ||
}), | ||
connectionStatus$: workingDirectLine.connectionStatus$, | ||
postActivity: workingDirectLine.postActivity.bind(workingDirectLine), | ||
token: workingDirectLine.token | ||
}; | ||
}, | ||
setup: () => window.WebChatTest.loadScript('https://unpkg.com/[email protected]/client/core.min.js') | ||
}); | ||
|
||
await driver.wait(uiConnected(), timeouts.directLine); | ||
|
||
await pageObjects.sendMessageViaSendBox('help'); | ||
await driver.wait(minNumActivitiesShown(2), timeouts.directLine); | ||
await driver.wait(scrollToBottomCompleted(), timeouts.scrollToBottom); | ||
|
||
// Should not show "New message" button because no new message coming in | ||
|
||
await pageObjects.scrollToTop(); | ||
|
||
await driver.wait(negationOf(scrollToBottomButtonVisible()), timeouts.ui); | ||
|
||
expect(await driver.takeScreenshot()).toMatchImageSnapshot(imageSnapshotOptions); | ||
|
||
// Should show "New message" button when new message came in | ||
|
||
await driver.executeScript(() => { | ||
window.WebChatTest.activityObserver.next({ | ||
from: { | ||
id: 'bot', | ||
role: 'bot' | ||
}, | ||
text: 'Hello, World!', | ||
type: 'message' | ||
}); | ||
}); | ||
|
||
await driver.wait(scrollToBottomButtonVisible(), timeouts.ui); | ||
|
||
expect(await driver.takeScreenshot()).toMatchImageSnapshot(imageSnapshotOptions); | ||
|
||
await pageObjects.clickScrollToBottomButton(); | ||
await driver.wait(scrollToBottomCompleted(), timeouts.scrollToBottom); | ||
await driver.wait(negationOf(scrollToBottomButtonVisible()), timeouts.ui); | ||
|
||
// Should stick to bottom | ||
|
||
await driver.executeScript(() => { | ||
window.WebChatTest.activityObserver.next({ | ||
from: { | ||
id: 'bot', | ||
role: 'bot' | ||
}, | ||
text: 'Aloha!', | ||
type: 'message' | ||
}); | ||
}); | ||
|
||
await driver.wait(minNumActivitiesShown(4), timeouts.directLine); | ||
|
||
expect(await driver.takeScreenshot()).toMatchImageSnapshot(imageSnapshotOptions); | ||
|
||
await pageObjects.sendMessageViaSendBox('Hello, World!'); | ||
await driver.wait(scrollToBottomCompleted(), timeouts.scrollToBottom); | ||
await pageObjects.scrollToTop(); | ||
|
||
await driver.wait(negationOf(scrollToBottomButtonVisible()), timeouts.ui); | ||
|
||
expect(await driver.takeScreenshot()).toMatchImageSnapshot(imageSnapshotOptions); | ||
}); |
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 |
---|---|---|
|
@@ -41,7 +41,29 @@ describe('style options', () => { | |
}); | ||
|
||
test('hide scroll to bottom button', async () => { | ||
const { driver, pageObjects } = await setupWebDriver(); | ||
const { driver, pageObjects } = await setupWebDriver({ | ||
createDirectLine: options => { | ||
const workingDirectLine = window.WebChat.createDirectLine(options); | ||
|
||
return { | ||
activity$: new Observable(activityObserver => { | ||
window.WebChatTest.activityObserver = activityObserver; | ||
|
||
const subscription = workingDirectLine.activity$.subscribe({ | ||
complete: () => activityObserver.complete(), | ||
error: value => activityObserver.error(value), | ||
next: value => activityObserver.next(value) | ||
}); | ||
|
||
return () => subscription.unsubscribe(); | ||
}), | ||
connectionStatus$: workingDirectLine.connectionStatus$, | ||
postActivity: workingDirectLine.postActivity.bind(workingDirectLine), | ||
token: workingDirectLine.token | ||
}; | ||
}, | ||
setup: () => window.WebChatTest.loadScript('https://unpkg.com/[email protected]/client/core.min.js') | ||
}); | ||
|
||
await driver.wait(uiConnected(), timeouts.directLine); | ||
await pageObjects.sendMessageViaSendBox('markdown', { waitForSend: true }); | ||
|
@@ -50,6 +72,17 @@ describe('style options', () => { | |
|
||
await pageObjects.scrollToTop(); | ||
|
||
await driver.executeScript(() => { | ||
window.WebChatTest.activityObserver.next({ | ||
from: { | ||
id: 'bot', | ||
role: 'bot' | ||
}, | ||
text: 'Hello, World!', | ||
type: 'message' | ||
}); | ||
}); | ||
|
||
await driver.wait(scrollToBottomButtonVisible(), timeouts.ui); | ||
expect(await driver.takeScreenshot()).toMatchImageSnapshot(imageSnapshotOptions); | ||
|
||
|
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