-
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 React Hooks for customization (part 13) (#2554)
* Apply PR comments * Add entry and fix bad merge * Update signature * Add useRenderActivity and useRenderAttachment * Use useCallback to reduce wasted render * Cosmetics * Fix ESLint * Fix ESLint * Export all hooks * Use useEmitTypingIndicator * Fix React warnings * Apply suggestions from code review Co-Authored-By: Corina <[email protected]> * Clean up * Fix test * Fix wasted render * Fix ESLint * Fix ESLint
- Loading branch information
Showing
25 changed files
with
298 additions
and
151 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
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.9 KB
...__/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.
Binary file added
BIN
+40 KB
...__/chrome-docker/use-text-box-js-calling-submit-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.
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 |
---|---|---|
@@ -0,0 +1,92 @@ | ||
import { timeouts } from '../constants.json'; | ||
|
||
import negate from '../setup/conditions/negate'; | ||
import speechRecognitionStartCalled from '../setup/conditions/speechRecognitionStartCalled'; | ||
import speechSynthesisUtterancePended from '../setup/conditions/speechSynthesisUtterancePended'; | ||
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('sendBoxSpeechInterimsVisible should return if dictation is started or not', async () => { | ||
const { driver, pageObjects } = await setupWebDriver({ | ||
props: { | ||
webSpeechPonyfillFactory: () => window.WebSpeechMock | ||
} | ||
}); | ||
|
||
await driver.wait(uiConnected(), timeouts.directLine); | ||
|
||
await expect( | ||
pageObjects.runHook( | ||
'useSendBoxSpeechInterimsVisible', | ||
[], | ||
sendBoxSpeechInterimsVisible => sendBoxSpeechInterimsVisible[0] | ||
) | ||
).resolves.toMatchInlineSnapshot(`false`); | ||
|
||
await pageObjects.clickMicrophoneButton(); | ||
|
||
await driver.wait(speechRecognitionStartCalled(), timeouts.ui); | ||
|
||
await expect( | ||
pageObjects.runHook( | ||
'useSendBoxSpeechInterimsVisible', | ||
[], | ||
sendBoxSpeechInterimsVisible => sendBoxSpeechInterimsVisible[0] | ||
) | ||
).resolves.toMatchInlineSnapshot(`true`); | ||
|
||
await pageObjects.putSpeechRecognitionResult('recognizing', 'Hello'); | ||
|
||
await expect( | ||
pageObjects.runHook( | ||
'useSendBoxSpeechInterimsVisible', | ||
[], | ||
sendBoxSpeechInterimsVisible => sendBoxSpeechInterimsVisible[0] | ||
) | ||
).resolves.toMatchInlineSnapshot(`true`); | ||
}); | ||
|
||
test('sendBoxSpeechInterimsVisible should return false when synthesizing', async () => { | ||
const { driver, pageObjects } = await setupWebDriver({ | ||
props: { | ||
webSpeechPonyfillFactory: () => window.WebSpeechMock | ||
} | ||
}); | ||
|
||
await driver.wait(uiConnected(), timeouts.directLine); | ||
await pageObjects.sendMessageViaMicrophone('Hello, World!'); | ||
await expect(pageObjects.startSpeechSynthesize()); | ||
|
||
await expect( | ||
pageObjects.runHook( | ||
'useSendBoxSpeechInterimsVisible', | ||
[], | ||
sendBoxSpeechInterimsVisible => sendBoxSpeechInterimsVisible[0] | ||
) | ||
).resolves.toMatchInlineSnapshot(`false`); | ||
|
||
await driver.wait(speechSynthesisUtterancePended(), timeouts.ui); | ||
|
||
await pageObjects.clickMicrophoneButton(); | ||
|
||
await driver.wait(negate(speechSynthesisUtterancePended()), timeouts.ui); | ||
|
||
await expect( | ||
pageObjects.runHook( | ||
'useSendBoxSpeechInterimsVisible', | ||
[], | ||
sendBoxSpeechInterimsVisible => sendBoxSpeechInterimsVisible[0] | ||
) | ||
).resolves.toMatchInlineSnapshot(`true`); | ||
}); | ||
|
||
test('setter should be undefined', async () => { | ||
const { pageObjects } = await setupWebDriver(); | ||
const [_, setLanguage] = await pageObjects.runHook('useSendBoxSpeechInterimsVisible'); | ||
|
||
expect(setLanguage).toBeUndefined(); | ||
}); |
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
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.