-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
66 additions
and
1 deletion.
There are no files selected for viewing
Binary file added
BIN
+33.9 KB
...ottom-if-submitting-an-adaptive-card-while-suggested-actions-is-open-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 |
---|---|---|
|
@@ -9,6 +9,7 @@ | |
"fetch": 2500, | ||
"navigation": 10000, | ||
"postActivity": 30000, | ||
"scrollToBottom": 1000, | ||
"test": 60000 | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { By } from 'selenium-webdriver'; | ||
|
||
import { imageSnapshotOptions, timeouts } from './constants.json'; | ||
|
||
import minNumActivitiesShown from './setup/conditions/minNumActivitiesShown'; | ||
import scrollToBottomCompleted from './setup/conditions/scrollToBottomCompleted'; | ||
import suggestedActionsShowed from './setup/conditions/suggestedActionsShowed'; | ||
import uiConnected from './setup/conditions/uiConnected'; | ||
|
||
// selenium-webdriver API doc: | ||
// https://seleniumhq.github.io/selenium/docs/api/javascript/module/selenium-webdriver/index_exports_WebDriver.html | ||
|
||
jest.setTimeout(timeouts.test); | ||
|
||
test('should stick to bottom if submitting an Adaptive Card while suggested actions is open', async () => { | ||
const { driver, pageObjects } = await setupWebDriver(); | ||
|
||
await driver.wait(uiConnected(), timeouts.directLine); | ||
|
||
await pageObjects.sendMessageViaSendBox('card inputs', { waitForSend: true }); | ||
await driver.wait(minNumActivitiesShown(2), timeouts.directLine); | ||
|
||
await pageObjects.sendMessageViaSendBox('suggested-actions', { waitForSend: true }); | ||
await driver.wait(suggestedActionsShowed(), timeouts.directLine); | ||
await driver.wait(scrollToBottomCompleted(), timeouts.scrollToBottom); | ||
|
||
const submitButton = await driver.findElement(By.css('button.ac-pushButton:nth-of-type(2)')); | ||
|
||
await submitButton.click(); | ||
await driver.wait(minNumActivitiesShown(5), timeouts.directLine); | ||
await driver.wait(scrollToBottomCompleted(), timeouts.scrollToBottom); | ||
|
||
const base64PNG = await driver.takeScreenshot(); | ||
|
||
expect(base64PNG).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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { Condition } from 'selenium-webdriver'; | ||
|
||
import { timeouts } from '../../constants.json'; | ||
|
||
export default function scrollToBottomCompleted() { | ||
return new Condition('for UI to scroll to bottom', async driver => { | ||
const done = await driver.executeAsyncScript((timeoutInMS, callback) => { | ||
const scrollable = document.querySelector('[role="log"] > *'); | ||
|
||
// If we do not receive any "scroll" event at all, probably we are at the bottom. | ||
const defaultTimeout = setTimeout(() => callback(true), timeoutInMS); | ||
let timeout; | ||
const handleScroll = () => { | ||
clearTimeout(defaultTimeout); | ||
clearTimeout(timeout); | ||
|
||
timeout = setTimeout(() => { | ||
scrollable.removeEventListener('scroll', handleScroll); | ||
callback(true); | ||
}, 200); | ||
}; | ||
|
||
scrollable.addEventListener('scroll', handleScroll); | ||
}, timeouts.scrollToBottom); | ||
|
||
return done; | ||
}); | ||
} |
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