Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
compulim committed Jul 2, 2019
1 parent 528e6ac commit f385858
Show file tree
Hide file tree
Showing 33 changed files with 205 additions and 148 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
79 changes: 0 additions & 79 deletions __tests__/bubble.js

This file was deleted.

131 changes: 131 additions & 0 deletions __tests__/bubbleBorder.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
import { imageSnapshotOptions, timeouts } from './constants.json';

import allImagesLoaded from './setup/conditions/allImagesLoaded';
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);

async function sendMessageAndMatchSnapshot(driver, pageObjects, message) {
await driver.wait(uiConnected(), timeouts.directLine);
await pageObjects.sendMessageViaSendBox(message);

await driver.wait(minNumActivitiesShown(3), timeouts.directLine);

const base64PNG = await driver.takeScreenshot();

expect(base64PNG).toMatchImageSnapshot(imageSnapshotOptions);
}

describe('bubble border', () => {
test('with color, radius, style, and width set', async () => {
const { driver, pageObjects } = await setupWebDriver({
props: {
styleOptions: {
bubbleBorderColor: 'Red',
bubbleBorderRadius: 10,
bubbleBorderStyle: 'dashed',
bubbleBorderWidth: 2,

bubbleFromUserBorderColor: 'Green',
bubbleFromUserBorderRadius: 20,
bubbleFromUserBorderStyle: 'dotted',
bubbleFromUserBorderWidth: 3
}
},
zoom: 3
});

await sendMessageAndMatchSnapshot(driver, pageObjects, 'echo Hello, World!');
});

describe('with deprecated border style', () => {
test('with color, radius, style, and width set', async () => {
const { driver, pageObjects } = await setupWebDriver({
props: {
styleOptions: {
bubbleBorder: 'dashed 2px Red',
bubbleBorderRadius: 10,

bubbleFromUserBorder: 'dotted 3px Green',
bubbleFromUserBorderRadius: 20
}
},
zoom: 3
});

await sendMessageAndMatchSnapshot(driver, pageObjects, 'echo Hello, World!');
});

test('of "dashed 2px Red" and "dotted 2px Green"', async () => {
const { driver, pageObjects } = await setupWebDriver({
props: {
styleOptions: {
bubbleBorder: 'dashed 2px Red',
bubbleFromUserBorder: 'dotted 2px Green'
}
}
});

await driver.wait(uiConnected(), timeouts.directLine);
await pageObjects.sendMessageViaSendBox('Hello, World!');
await driver.wait(minNumActivitiesShown(2), timeouts.directLine);

expect(await driver.takeScreenshot()).toMatchImageSnapshot(imageSnapshotOptions);
});

test('of "dashed" and "dotted"', async () => {
const { driver, pageObjects } = await setupWebDriver({
props: {
styleOptions: {
bubbleBorder: 'dashed',
bubbleFromUserBorder: 'dotted'
}
}
});

await driver.wait(uiConnected(), timeouts.directLine);
await pageObjects.sendMessageViaSendBox('Hello, World!');
await driver.wait(minNumActivitiesShown(2), timeouts.directLine);

expect(await driver.takeScreenshot()).toMatchImageSnapshot(imageSnapshotOptions);
});

test('of "2px"', async () => {
const { driver, pageObjects } = await setupWebDriver({
props: {
styleOptions: {
bubbleBorder: '2px',
bubbleFromUserBorder: '2px'
}
}
});

await driver.wait(uiConnected(), timeouts.directLine);
await pageObjects.sendMessageViaSendBox('Hello, World!');
await driver.wait(minNumActivitiesShown(2), timeouts.directLine);

expect(await driver.takeScreenshot()).toMatchImageSnapshot(imageSnapshotOptions);
});

test('of "Red" and "Green"', async () => {
const { driver, pageObjects } = await setupWebDriver({
props: {
styleOptions: {
bubbleBorder: 'Red',
bubbleFromUserBorder: 'Green'
}
}
});

await driver.wait(uiConnected(), timeouts.directLine);
await pageObjects.sendMessageViaSendBox('Hello, World!');
await driver.wait(minNumActivitiesShown(2), timeouts.directLine);

expect(await driver.takeScreenshot()).toMatchImageSnapshot(imageSnapshotOptions);
});
});
});
47 changes: 13 additions & 34 deletions __tests__/carousel.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,9 @@ import uiConnected from './setup/conditions/uiConnected';

jest.setTimeout(timeouts.test);

let props;

beforeEach(() => {
props = {
// We are using red/green border to emphasis the size of the border while testing
styleOptions: {
bubbleBorderColor: 'red',
bubbleFromUserBorderColor: 'green'
}
};
});

describe('carousel without avatar initials', () => {
test('4 attachments and no message', async () => {
const { driver, pageObjects } = await setupWebDriver({ props });
const { driver, pageObjects } = await setupWebDriver();

await driver.wait(uiConnected(), timeouts.directLine);
await pageObjects.sendMessageViaSendBox('carousel', { waitForSend: true });
Expand All @@ -49,7 +37,7 @@ describe('carousel without avatar initials', () => {
});

test('4 attachments and message', async () => {
const { driver, pageObjects } = await setupWebDriver({ props });
const { driver, pageObjects } = await setupWebDriver();

await driver.wait(uiConnected(), timeouts.directLine);
await pageObjects.sendMessageViaSendBox('layout carousel', { waitForSend: true });
Expand All @@ -73,7 +61,7 @@ describe('carousel without avatar initials', () => {
});

test('2 attachments', async () => {
const { driver, pageObjects } = await setupWebDriver({ props });
const { driver, pageObjects } = await setupWebDriver();

await driver.wait(uiConnected(), timeouts.directLine);
await pageObjects.sendMessageViaSendBox('layout double', { waitForSend: true });
Expand All @@ -85,7 +73,7 @@ describe('carousel without avatar initials', () => {
});

test('2 attachments with wide screen', async () => {
const { driver, pageObjects } = await setupWebDriver({ props, width: 640 });
const { driver, pageObjects } = await setupWebDriver({ width: 640 });

await driver.wait(uiConnected(), timeouts.directLine);
await pageObjects.sendMessageViaSendBox('layout double', { waitForSend: true });
Expand All @@ -97,7 +85,7 @@ describe('carousel without avatar initials', () => {
});

test('1 attachment', async () => {
const { driver, pageObjects } = await setupWebDriver({ props });
const { driver, pageObjects } = await setupWebDriver();

await driver.wait(uiConnected(), timeouts.directLine);
await pageObjects.sendMessageViaSendBox('layout single carousel', { waitForSend: true });
Expand All @@ -109,7 +97,7 @@ describe('carousel without avatar initials', () => {
});

test('1 attachment with wide screen', async () => {
const { driver, pageObjects } = await setupWebDriver({ props, width: 640 });
const { driver, pageObjects } = await setupWebDriver({ width: 640 });

await driver.wait(uiConnected(), timeouts.directLine);
await pageObjects.sendMessageViaSendBox('layout single carousel', { waitForSend: true });
Expand All @@ -122,19 +110,10 @@ describe('carousel without avatar initials', () => {
});

describe('carousel with avatar initials', () => {
beforeEach(() => {
props = {
...props,
styleOptions: {
...props.styleOptions,
botAvatarInitials: 'BF',
userAvatarInitials: 'WC'
}
};
});
const WEB_CHAT_PROPS = { styleOptions: { botAvatarInitials: 'BF', userAvatarInitials: 'WC' } };

test('4 attachments and no message', async () => {
const { driver, pageObjects } = await setupWebDriver({ props });
const { driver, pageObjects } = await setupWebDriver({ props: WEB_CHAT_PROPS });

await driver.wait(uiConnected(), timeouts.directLine);
await pageObjects.sendMessageViaSendBox('carousel', { waitForSend: true });
Expand All @@ -158,7 +137,7 @@ describe('carousel with avatar initials', () => {
});

test('4 attachments and message', async () => {
const { driver, pageObjects } = await setupWebDriver({ props });
const { driver, pageObjects } = await setupWebDriver({ props: WEB_CHAT_PROPS });

await driver.wait(uiConnected(), timeouts.directLine);
await pageObjects.sendMessageViaSendBox('layout carousel', { waitForSend: true });
Expand All @@ -182,7 +161,7 @@ describe('carousel with avatar initials', () => {
});

test('2 attachments', async () => {
const { driver, pageObjects } = await setupWebDriver({ props });
const { driver, pageObjects } = await setupWebDriver({ props: WEB_CHAT_PROPS });

await driver.wait(uiConnected(), timeouts.directLine);
await pageObjects.sendMessageViaSendBox('layout double', { waitForSend: true });
Expand All @@ -194,7 +173,7 @@ describe('carousel with avatar initials', () => {
});

test('2 attachments with wide screen', async () => {
const { driver, pageObjects } = await setupWebDriver({ props, width: 640 });
const { driver, pageObjects } = await setupWebDriver({ props: WEB_CHAT_PROPS, width: 640 });

await driver.wait(uiConnected(), timeouts.directLine);
await pageObjects.sendMessageViaSendBox('layout double', { waitForSend: true });
Expand All @@ -206,7 +185,7 @@ describe('carousel with avatar initials', () => {
});

test('1 attachment', async () => {
const { driver, pageObjects } = await setupWebDriver({ props });
const { driver, pageObjects } = await setupWebDriver({ props: WEB_CHAT_PROPS });

await driver.wait(uiConnected(), timeouts.directLine);
await pageObjects.sendMessageViaSendBox('layout single carousel', { waitForSend: true });
Expand All @@ -218,7 +197,7 @@ describe('carousel with avatar initials', () => {
});

test('1 attachment with wide screen', async () => {
const { driver, pageObjects } = await setupWebDriver({ props, width: 640 });
const { driver, pageObjects } = await setupWebDriver({ props: WEB_CHAT_PROPS, width: 640 });

await driver.wait(uiConnected(), timeouts.directLine);
await pageObjects.sendMessageViaSendBox('layout single carousel', { waitForSend: true });
Expand Down
2 changes: 1 addition & 1 deletion __tests__/setup/pageObjects/sendMessageViaSendBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { By, Key } from 'selenium-webdriver';
import { timeouts } from '../../constants.json';
import allOutgoingActivitiesSent from '../conditions/allOutgoingActivitiesSent';

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

await input.sendKeys(text, Key.RETURN);
Expand Down
Loading

0 comments on commit f385858

Please sign in to comment.