forked from microsoft/BotFramework-WebChat
-
Notifications
You must be signed in to change notification settings - Fork 4
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
8 changed files
with
100 additions
and
2 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,47 @@ | ||
import { Key } from 'selenium-webdriver'; | ||
import { timeouts } from './constants.json'; | ||
|
||
import uiConnected from './setup/conditions/uiConnected'; | ||
import suggestedActionsShowed from './setup/conditions/suggestedActionsShowed'; | ||
|
||
// selenium-webdriver API doc: | ||
// https://seleniumhq.github.io/selenium/docs/api/javascript/module/selenium-webdriver/index_exports_WebDriver.html | ||
|
||
jest.setTimeout(timeouts.test); | ||
|
||
// Verification of fix of #1971 | ||
test('should not focus send box after clicking on send button', async () => { | ||
const { driver, pageObjects } = await setupWebDriver(); | ||
|
||
await driver.wait(uiConnected(), timeouts.directLine); | ||
|
||
await pageObjects.setSendBoxText('echo 123'); | ||
await pageObjects.clickSendButton(); | ||
|
||
await expect(pageObjects.hasFocusOnSendBoxTextBox()).resolves.toBeFalsy(); | ||
}); | ||
|
||
// Verification of fix of #1971 | ||
test('should not focus send box after clicking on suggested actions', async () => { | ||
const { driver, pageObjects } = await setupWebDriver(); | ||
|
||
await driver.wait(uiConnected(), timeouts.directLine); | ||
await pageObjects.sendMessageViaSendBox('suggested-actions'); | ||
|
||
await driver.wait(suggestedActionsShowed(), timeouts.directLine); | ||
|
||
await pageObjects.clickSuggestedActionButton(0); | ||
|
||
await expect(pageObjects.hasFocusOnSendBoxTextBox()).resolves.toBeFalsy(); | ||
}); | ||
|
||
// Verification of fix of #1971 | ||
test('should focus send box after pressing ENTER to send message', async () => { | ||
const { driver, pageObjects } = await setupWebDriver(); | ||
|
||
await driver.wait(uiConnected(), timeouts.directLine); | ||
|
||
await pageObjects.setSendBoxText('echo 123', Key.RETURN); | ||
|
||
await expect(pageObjects.hasFocusOnSendBoxTextBox()).resolves.toBeTruthy(); | ||
}); |
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,5 @@ | ||
import getSendButton from './elements/getSendButton'; | ||
|
||
export default async function clickSendButton(driver) { | ||
(await getSendButton(driver)).click(); | ||
} |
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,7 @@ | ||
import getSuggestedActionButtons from './elements/getSuggestedActionButtons'; | ||
|
||
export default async function clickSuggestedActionButton(driver, index) { | ||
const suggestedActions = await getSuggestedActionButtons(driver); | ||
|
||
await suggestedActions[index].click(); | ||
} |
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,5 +1,9 @@ | ||
import { By } from 'selenium-webdriver'; | ||
|
||
const CSS_SELECTOR = '[role="form"] > * > form > input[type="text"]'; | ||
|
||
export default async function getSendBoxTextBox(driver) { | ||
return await driver.findElement(By.css('[role="form"] > * > form > input[type="text"]')); | ||
return await driver.findElement(By.css(CSS_SELECTOR)); | ||
} | ||
|
||
export { CSS_SELECTOR }; |
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,5 @@ | ||
import { By } from 'selenium-webdriver'; | ||
|
||
export default async function getSendButton(driver) { | ||
return await driver.findElement(By.css('[role="form"] button[title="Send"]')); | ||
} |
5 changes: 5 additions & 0 deletions
5
__tests__/setup/pageObjects/elements/getSuggestedActionButtons.js
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,5 @@ | ||
import { By } from 'selenium-webdriver'; | ||
|
||
export default async function getSuggestedActionButtons(driver) { | ||
return await driver.findElements(By.css('[role="form"] > :nth-child(2) ul > li button')); | ||
} |
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 { By } from 'selenium-webdriver'; | ||
import getSendBoxTextBox, { CSS_SELECTOR } from './elements/getSendBoxTextBox'; | ||
|
||
export default async function hasFocusOnSendBoxTextBox(driver) { | ||
// Make sure the send box text box is visible | ||
await getSendBoxTextBox(driver); | ||
|
||
try { | ||
await driver.findElement(By.css(CSS_SELECTOR + ':focus')); | ||
|
||
return true; | ||
} catch (err) { | ||
if (err.name === 'NoSuchElementError') { | ||
return false; | ||
} | ||
|
||
throw err; | ||
} | ||
} |
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