-
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.
Add React Hooks for customization (part 11) (#2552)
* Add send box related hooks * Fix merge
- Loading branch information
Showing
19 changed files
with
274 additions
and
44 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 added
BIN
+51.8 KB
...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 added
BIN
+37.1 KB
...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 added
BIN
+15.8 KB
...d-box-js-calling-submit-send-box-should-send-the-message-in-send-box-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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { timeouts } from '../constants.json'; | ||
|
||
import sendBoxTextBoxFocused from '../setup/conditions/sendBoxTextBoxFocused'; | ||
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('calling emitTypingIndicator should send a typing activity', async () => { | ||
const { driver, pageObjects } = await setupWebDriver(); | ||
|
||
await driver.wait(uiConnected(), timeouts.directLine); | ||
|
||
await pageObjects.runHook('useFocusSendBox', [], fn => fn()); | ||
|
||
await driver.wait(sendBoxTextBoxFocused(), timeouts.ui); | ||
}); |
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,34 @@ | ||
import { imageSnapshotOptions, timeouts } from '../constants.json'; | ||
|
||
import minNumActivitiesShown from '../setup/conditions/minNumActivitiesShown'; | ||
import scrollToBottomButtonVisible from '../setup/conditions/scrollToBottomButtonVisible'; | ||
import scrollToBottomCompleted from '../setup/conditions/scrollToBottomCompleted'; | ||
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('calling scrollToEnd should scroll to end', async () => { | ||
const { driver, pageObjects } = await setupWebDriver(); | ||
|
||
await driver.wait(uiConnected(), timeouts.directLine); | ||
|
||
await pageObjects.sendMessageViaSendBox('help'); | ||
await driver.wait(minNumActivitiesShown(2), timeouts.directLine); | ||
await driver.wait(scrollToBottomCompleted(), timeouts.scrollToBottom); | ||
|
||
await driver.executeScript(() => { | ||
document.querySelector('[role="log"] > *').scrollTop = 0; | ||
}); | ||
|
||
await driver.wait(scrollToBottomButtonVisible(), timeouts.ui); | ||
|
||
expect(await driver.takeScreenshot()).toMatchImageSnapshot(imageSnapshotOptions); | ||
|
||
await pageObjects.runHook('useScrollToEnd', [], scrollToEnd => scrollToEnd()); | ||
await driver.wait(scrollToBottomCompleted(), timeouts.scrollToBottom); | ||
|
||
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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { timeouts } from '../constants.json'; | ||
|
||
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('getter should get the send box text', async () => { | ||
const { driver, pageObjects } = await setupWebDriver(); | ||
|
||
await driver.wait(uiConnected(), timeouts.directLine); | ||
|
||
await pageObjects.typeOnSendBox('Hello, World!'); | ||
await expect(pageObjects.runHook('useSendBoxValue', [], result => result[0])).resolves.toBe('Hello, World!'); | ||
}); | ||
|
||
test('setter should set the send box text', async () => { | ||
const { driver, pageObjects } = await setupWebDriver(); | ||
|
||
await driver.wait(uiConnected(), timeouts.directLine); | ||
|
||
await pageObjects.runHook('useSendBoxValue', [], result => result[1]('Hello, World!')); | ||
await expect(pageObjects.getSendBoxText()).resolves.toBe('Hello, World!'); | ||
}); |
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,24 @@ | ||
import { imageSnapshotOptions, timeouts } from '../constants.json'; | ||
|
||
import minNumActivitiesShown from '../setup/conditions/minNumActivitiesShown'; | ||
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('calling submitSendBox should send the message in send box', async () => { | ||
const { driver, pageObjects } = await setupWebDriver(); | ||
|
||
await driver.wait(uiConnected(), timeouts.directLine); | ||
|
||
await pageObjects.typeOnSendBox('Hello, World!'); | ||
await pageObjects.runHook('useSubmitSendBox', [], submitSendBox => submitSendBox()); | ||
|
||
await driver.wait(minNumActivitiesShown(2), timeouts.directLine); | ||
|
||
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,29 @@ | ||
import { imageSnapshotOptions, timeouts } from '../constants.json'; | ||
|
||
import minNumActivitiesShown from '../setup/conditions/minNumActivitiesShown'; | ||
import scrollToBottomCompleted from '../setup/conditions/scrollToBottomCompleted'; | ||
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); | ||
|
||
// TODO: [P1] Test is temporarily disable until fully implemented | ||
test('calling submit should scroll to end', async () => { | ||
// const { driver, pageObjects } = await setupWebDriver(); | ||
// await driver.wait(uiConnected(), timeouts.directLine); | ||
// await pageObjects.typeOnSendBox('help'); | ||
// await expect(pageObjects.runHook('useTextBoxValue', [], textBoxValue => textBoxValue[0])).resolves.toBe('help'); | ||
// await pageObjects.clickSendButton(); | ||
// await driver.wait(minNumActivitiesShown(2), timeouts.directLine); | ||
// await driver.wait(scrollToBottomCompleted(), timeouts.scrollToBottom); | ||
// await driver.executeScript(() => { | ||
// document.querySelector('[role="log"] > *').scrollTop = 0; | ||
// }); | ||
// expect(await driver.takeScreenshot()).toMatchImageSnapshot(imageSnapshotOptions); | ||
// await pageObjects.runHook('useTextBoxValue', [], textBoxValue => textBoxValue[1]('Hello, World!')); | ||
// await pageObjects.runHook('useTextBoxSubmit', [], textBoxSubmit => textBoxSubmit()); | ||
// await driver.wait(scrollToBottomCompleted(), timeouts.scrollToBottom); | ||
// 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
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
Oops, something went wrong.