Skip to content

Commit

Permalink
Use page object to send message
Browse files Browse the repository at this point in the history
  • Loading branch information
compulim committed Apr 26, 2019
1 parent a74680d commit cdd11f1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
7 changes: 2 additions & 5 deletions __tests__/offlineUI.js
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ describe('offline UI', async () => {
});

test('should show "Render error" connectivity status when a JavaScript error is present in the code.', async () => {
const { driver } = await setupWebDriver({
const { driver, pageObjects } = await setupWebDriver({
storeMiddleware: ({ dispatch }) => next => action => {
if (action.type === 'DIRECT_LINE/INCOMING_ACTIVITY' && action.payload.activity && action.payload.activity.text === 'error') {
dispatch({
Expand All @@ -343,10 +343,7 @@ describe('offline UI', async () => {
});

await driver.wait(uiConnected(), timeouts.directLine);

const input = await driver.findElement(By.css('input[type="text"]'));

await input.sendKeys('error', Key.RETURN);
await pageObjects.sendMessageViaSendBox('error', { waitForSend: false });
await driver.wait(minNumActivitiesShown(2), timeouts.directLine);

const base64PNG = await driver.takeScreenshot();
Expand Down
5 changes: 3 additions & 2 deletions __tests__/setup/pageObjects/sendMessageViaSendBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ import { By, Key } from 'selenium-webdriver';
import { timeouts } from '../../constants.json';
import allOutgoingActivitiesSent from '../conditions/allOutgoingActivitiesSent';

export default async function (driver, text) {
export default async function (driver, text, { waitForSend = true }) {
const input = await driver.findElement(By.css('input[type="text"]'));

await input.sendKeys(text, Key.RETURN);
await driver.wait(allOutgoingActivitiesSent(), timeouts.directLine);

waitForSend && await driver.wait(allOutgoingActivitiesSent(), timeouts.directLine);
}

0 comments on commit cdd11f1

Please sign in to comment.