-
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 tests * Add tests * Add focus tests * Add tests * Improve reliability * Fix * Add link * Add comment * Apply PR changes * Rename and move files * Rename
- Loading branch information
Showing
38 changed files
with
608 additions
and
154 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
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,48 @@ | ||
import { Key } from 'selenium-webdriver'; | ||
|
||
import { timeouts } from './constants.json'; | ||
import sendBoxTextBoxFocused from './setup/conditions/sendBoxTextBoxFocused'; | ||
import suggestedActionsShown from './setup/conditions/suggestedActionsShown'; | ||
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); | ||
|
||
// Verification of fix of #1971, https://github.com/microsoft/BotFramework-WebChat/issues/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.typeOnSendBox('echo 123'); | ||
await pageObjects.clickSendButton(); | ||
|
||
await expect(sendBoxTextBoxFocused().fn(driver)).resolves.toBeFalsy(); | ||
}); | ||
|
||
// Verification of fix of #1971, https://github.com/microsoft/BotFramework-WebChat/issues/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(suggestedActionsShown(), timeouts.directLine); | ||
|
||
await pageObjects.clickSuggestedActionButton(0); | ||
|
||
await expect(sendBoxTextBoxFocused().fn(driver)).resolves.toBeFalsy(); | ||
}); | ||
|
||
// Verification of fix of #1971, https://github.com/microsoft/BotFramework-WebChat/issues/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.typeOnSendBox('echo 123', Key.RETURN); | ||
|
||
await expect(sendBoxTextBoxFocused().fn(driver)).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
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,5 @@ | ||
import { Condition } from 'selenium-webdriver'; | ||
|
||
export default function negateCondition(condition) { | ||
return new Condition(`Negate of ${condition.name}`, async (...args) => !(await condition.fn(...args))); | ||
} |
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,22 @@ | ||
import { By, Condition } from 'selenium-webdriver'; | ||
|
||
import getSendBoxTextBox, { CSS_SELECTOR } from '../elements/getSendBoxTextBox'; | ||
|
||
export default function sendBoxTextBoxFocused() { | ||
return new Condition('Send box text box to be focused', async 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { Condition } from 'selenium-webdriver'; | ||
|
||
// Checks if Web Chat has called "speechRecognition.start()" and pending for a series of speech events. | ||
|
||
export default function speechRecognitionStartCalled() { | ||
return new Condition('SpeechRecognition.start to be called', driver => | ||
driver.executeScript(() => window.WebSpeechMock.speechRecognitionStartCalled()) | ||
); | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 { Condition } from 'selenium-webdriver'; | ||
|
||
export default function speechSynthesisUtterancePended() { | ||
return new Condition('Speech synthesis utterance to be pended to synthesize', driver => | ||
driver.executeScript(() => window.WebSpeechMock.speechSynthesisUtterancePended()) | ||
); | ||
} |
2 changes: 1 addition & 1 deletion
2
...etup/conditions/suggestedActionsShowed.js → ...setup/conditions/suggestedActionsShown.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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import { By, until } from 'selenium-webdriver'; | ||
|
||
export default function suggestedActionsShowed() { | ||
export default function suggestedActionsShown() { | ||
return until.elementLocated(By.css('[role="form"] ul')); | ||
} |
File renamed without changes.
File renamed without changes.
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,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(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"]')); | ||
} |
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')); | ||
} |
File renamed without changes.
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 getMicrophoneButton from '../elements/getMicrophoneButton'; | ||
|
||
export default async function clickMicrophoneButton(driver) { | ||
const microphoneButton = await getMicrophoneButton(driver); | ||
|
||
await microphoneButton.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,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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { By } from 'selenium-webdriver'; | ||
|
||
export default async function getNumActivitiesShown(driver) { | ||
return (await driver.findElements(By.css(`[role="listitem"]`))).length; | ||
} |
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 getSendBoxTextBox from '../elements/getSendBoxTextBox'; | ||
|
||
export default async function getSendBoxText(driver) { | ||
const textBox = await getSendBoxTextBox(driver); | ||
|
||
return await textBox.getAttribute('value'); | ||
} |
This file was deleted.
Oops, something went wrong.
3 changes: 0 additions & 3 deletions
3
__tests__/setup/pageObjects/hasPendingSpeechSynthesisUtterance.js
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.