-
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 6) (#2547)
* Add multiple post activity related hooks * Fix suggested action * Fix tests * Fix ESLint * Fix ESLint
- Loading branch information
Showing
33 changed files
with
473 additions
and
90 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
+18.2 KB
...js-calling-perform-card-action-should-send-card-action-to-middleware-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
+15.8 KB
...r/use-post-activity-js-calling-post-activity-should-send-an-activity-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
+18.6 KB
.../chrome-docker/use-send-files-js-calling-send-file-should-send-files-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
+14.3 KB
...ack-js-calling-send-message-back-should-send-a-message-back-activity-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
+15.8 KB
...-send-message-js-calling-send-message-should-send-a-message-activity-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
+10.3 KB
...post-back-js-calling-send-post-back-should-send-a-post-back-activity-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,23 @@ | ||
import { timeouts } from '../constants.json'; | ||
|
||
import minNumActivitiesShown from '../setup/conditions/minNumActivitiesShown'; | ||
import typingActivityReceived from '../setup/conditions/typingActivityReceived'; | ||
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.sendMessageViaSendBox('echo-typing', { waitForSend: true }); | ||
|
||
await driver.wait(minNumActivitiesShown(2), timeouts.directLine); | ||
|
||
await pageObjects.runHook('useEmitTypingIndicator', [], fn => fn()); | ||
|
||
await driver.wait(typingActivityReceived(), timeouts.directLine); | ||
}); |
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 { imageSnapshotOptions, 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('calling performCardAction should send card action to middleware', async () => { | ||
const { driver, pageObjects } = await setupWebDriver({ | ||
props: { | ||
cardActionMiddleware: ({ dispatch }) => next => ({ cardAction }) => { | ||
if (cardAction.type === 'openUrl') { | ||
dispatch({ | ||
type: 'WEB_CHAT/SEND_MESSAGE', | ||
payload: { | ||
text: `Navigating to ${cardAction.value}` | ||
} | ||
}); | ||
} else { | ||
return next(cardAction); | ||
} | ||
} | ||
} | ||
}); | ||
|
||
await driver.wait(uiConnected(), timeouts.directLine); | ||
await pageObjects.runHook('usePerformCardAction', [], performCardAction => | ||
performCardAction({ type: 'openUrl', value: 'about:blank' }) | ||
); | ||
|
||
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 { 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 postActivity should send an activity', async () => { | ||
const { driver, pageObjects } = await setupWebDriver(); | ||
|
||
await driver.wait(uiConnected(), timeouts.directLine); | ||
|
||
await pageObjects.runHook('usePostActivity', [], fn => | ||
fn({ | ||
text: 'Hello, World!', | ||
type: 'message' | ||
}) | ||
); | ||
|
||
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,31 @@ | ||
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 sendFile should send files', async () => { | ||
const { driver, pageObjects } = await setupWebDriver(); | ||
|
||
await driver.wait(uiConnected(), timeouts.directLine); | ||
|
||
await pageObjects.runHook('useSendFiles', [], sendFiles => { | ||
const blob1 = new Blob([new ArrayBuffer(1024)]); | ||
const blob2 = new Blob([new ArrayBuffer(1024)]); | ||
|
||
blob1.name = 'index.png'; | ||
blob2.name = 'index2.png'; | ||
|
||
sendFiles([blob1, blob2]); | ||
}); | ||
|
||
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,23 @@ | ||
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 sendMessage should send a message activity', async () => { | ||
const { driver, pageObjects } = await setupWebDriver(); | ||
|
||
await driver.wait(uiConnected(), timeouts.directLine); | ||
|
||
await pageObjects.runHook('useSendMessage', [], sendMessage => sendMessage('Hello, World!')); | ||
|
||
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,25 @@ | ||
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 sendMessageBack should send a message back activity', async () => { | ||
const { driver, pageObjects } = await setupWebDriver(); | ||
|
||
await driver.wait(uiConnected(), timeouts.directLine); | ||
|
||
await pageObjects.runHook('useSendMessageBack', [], sendMessageBack => | ||
sendMessageBack({ hello: 'World!' }, 'Aloha!', 'Display text') | ||
); | ||
|
||
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,23 @@ | ||
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 sendPostBack should send a post back activity', async () => { | ||
const { driver, pageObjects } = await setupWebDriver(); | ||
|
||
await driver.wait(uiConnected(), timeouts.directLine); | ||
|
||
await pageObjects.runHook('useSendPostBack', [], sendPostBack => sendPostBack({ hello: 'World!' })); | ||
|
||
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
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.