-
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
16 changed files
with
337 additions
and
42 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
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,60 @@ | ||
import { timeouts } from '../constants.json'; | ||
|
||
import speechRecognitionStartCalled from '../setup/conditions/speechRecognitionStartCalled'; | ||
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('sendBoxDictationStarted 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('useSendBoxDictationStarted', [], sendBoxDictationStarted => sendBoxDictationStarted[0]) | ||
).resolves.toMatchInlineSnapshot(`false`); | ||
|
||
await pageObjects.clickMicrophoneButton(); | ||
|
||
await driver.wait(speechRecognitionStartCalled(), timeouts.ui); | ||
|
||
await expect( | ||
pageObjects.runHook('useSendBoxDictationStarted', [], sendBoxDictationStarted => sendBoxDictationStarted[0]) | ||
).resolves.toMatchInlineSnapshot(`true`); | ||
|
||
await pageObjects.putSpeechRecognitionResult('recognizing', 'Hello'); | ||
|
||
await expect( | ||
pageObjects.runHook('useSendBoxDictationStarted', [], sendBoxDictationStarted => sendBoxDictationStarted[0]) | ||
).resolves.toMatchInlineSnapshot(`true`); | ||
}); | ||
|
||
test('sendBoxDictationStarted 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 pageObjects.clickMicrophoneButton(); | ||
|
||
await expect( | ||
pageObjects.runHook('useSendBoxDictationStarted', [], sendBoxDictationStarted => sendBoxDictationStarted[0]) | ||
).resolves.toMatchInlineSnapshot(`false`); | ||
|
||
await pageObjects.endSpeechSynthesize(); | ||
|
||
await expect( | ||
pageObjects.runHook('useSendBoxDictationStarted', [], sendBoxDictationStarted => sendBoxDictationStarted[0]) | ||
).resolves.toMatchInlineSnapshot(`true`); | ||
}); |
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,38 @@ | ||
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); | ||
|
||
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
Oops, something went wrong.