-
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
64 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { By, Key } from 'selenium-webdriver'; | ||
|
||
import directLineConnected from './setup/conditions/directLineConnected'; | ||
import minNumActivitiesReached from './setup/conditions/minNumActivitiesReached'; | ||
import webChatLoaded from './setup/conditions/webChatLoaded'; | ||
|
||
// selenium-webdriver API doc: | ||
// https://seleniumhq.github.io/selenium/docs/api/javascript/module/selenium-webdriver/index_exports_WebDriver.html | ||
|
||
test('Send typing indicator', async () => { | ||
const { driver } = await setupWebDriver({ props: { sendTypingIndicator: true } }); | ||
|
||
await driver.wait(webChatLoaded(), 2000); | ||
await driver.wait(directLineConnected(), 2000); | ||
|
||
const input = await driver.findElement(By.tagName('input[type="text"]')); | ||
|
||
await input.sendKeys('echo-typing', Key.RETURN); | ||
await driver.wait(minNumActivitiesReached(3), 2000); | ||
await input.sendKeys('ABC'); | ||
|
||
// Typing indicator takes longer to come back | ||
await driver.wait(minNumActivitiesReached(4), 5000); | ||
}, 60000); | ||
|
||
// TODO: [P3] Take this deprecation code out when releasing on or after January 13 2020 | ||
test('Send typing indicator using deprecated props', async () => { | ||
const { driver } = await setupWebDriver({ props: { sendTyping: true } }); | ||
|
||
await driver.wait(webChatLoaded(), 2000); | ||
await driver.wait(directLineConnected(), 2000); | ||
|
||
const input = await driver.findElement(By.tagName('input[type="text"]')); | ||
|
||
await input.sendKeys('echo-typing', Key.RETURN); | ||
await driver.wait(minNumActivitiesReached(3), 2000); | ||
await input.sendKeys('ABC'); | ||
|
||
// Typing indicator takes longer to come back | ||
await driver.wait(minNumActivitiesReached(4), 5000); | ||
}, 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 |
---|---|---|
@@ -1,7 +1,10 @@ | ||
import { Condition } from 'selenium-webdriver'; | ||
|
||
export default function () { | ||
return new Condition('Waiting for Direct Line to connect', async driver => { | ||
return await driver.executeScript(() => ~window.WebChatTest.actions.findIndex(({ type }) => type === 'DIRECT_LINE/CONNECT_FULFILLED')); | ||
}); | ||
return new Condition('Waiting for Direct Line to connect with a welcome message', async driver => | ||
await driver.executeScript(() => | ||
!!~window.WebChatTest.actions.findIndex(({ type }) => type === 'DIRECT_LINE/CONNECT_FULFILLED') | ||
&& !!document.querySelector(`[role="listitem"]:nth-child(1)`) | ||
) | ||
); | ||
} |
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,10 @@ | ||
import { Condition } from 'selenium-webdriver'; | ||
|
||
export default function () { | ||
return new Condition('Waiting for incoming typing activity', async driver => { | ||
await driver.executeScript(() => | ||
// TODO: [P2] We should use activities selector from core | ||
!!~window.WebChatTest.store.getState().activities.findIndex(({ type }) => type === 'typing') | ||
) | ||
); | ||
} |
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