Skip to content

Commit

Permalink
Fix test with recent changes
Browse files Browse the repository at this point in the history
  • Loading branch information
compulim committed Jan 28, 2019
1 parent dead46a commit 1d16bf8
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 77 deletions.
66 changes: 27 additions & 39 deletions __tests__/carousel.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { By, Key } from 'selenium-webdriver';

import { imageSnapshotOptions, timeouts } from './constants.json';

import allImagesLoaded from './setup/conditions/allImagesLoaded';
import directLineConnected from './setup/conditions/directLineConnected';
import minNumActivitiesReached from './setup/conditions/minNumActivitiesReached';
import webChatLoaded from './setup/conditions/webChatLoaded';
import botConnected from './setup/conditions/botConnected';
import minNumActivitiesShown from './setup/conditions/minNumActivitiesShown';

// selenium-webdriver API doc:
// https://seleniumhq.github.io/selenium/docs/api/javascript/module/selenium-webdriver/index_exports_WebDriver.html
Expand All @@ -13,13 +13,12 @@ describe('carousel without avatar initials', () => {
test('4 attachments and no message', async () => {
const { driver, pageObjects } = await setupWebDriver();

await driver.wait(webChatLoaded(), timeouts.navigation);
await driver.wait(directLineConnected(), timeouts.directLine);
await driver.wait(botConnected(), timeouts.directLine);

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

await input.sendKeys('carousel', Key.RETURN);
await driver.wait(minNumActivitiesReached(3), timeouts.directLine);
await driver.wait(minNumActivitiesShown(3), timeouts.directLine);
await driver.wait(allImagesLoaded(), timeouts.fetch);

// Hide cursor before taking screenshot
Expand All @@ -43,13 +42,12 @@ describe('carousel without avatar initials', () => {
test('4 attachments and message', async () => {
const { driver, pageObjects } = await setupWebDriver();

await driver.wait(webChatLoaded(), timeouts.navigation);
await driver.wait(directLineConnected(), timeouts.directLine);
await driver.wait(botConnected(), timeouts.directLine);

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

await input.sendKeys('layout carousel', Key.RETURN);
await driver.wait(minNumActivitiesReached(3), timeouts.directLine);
await driver.wait(minNumActivitiesShown(3), timeouts.directLine);
await driver.wait(allImagesLoaded(), timeouts.fetch);

// Hide cursor before taking screenshot
Expand All @@ -73,13 +71,12 @@ describe('carousel without avatar initials', () => {
test('2 attachments', async () => {
const { driver, pageObjects } = await setupWebDriver();

await driver.wait(webChatLoaded(), timeouts.navigation);
await driver.wait(directLineConnected(), timeouts.directLine);
await driver.wait(botConnected(), timeouts.directLine);

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

await input.sendKeys('layout double', Key.RETURN);
await driver.wait(minNumActivitiesReached(3), timeouts.directLine);
await driver.wait(minNumActivitiesShown(3), timeouts.directLine);
await driver.wait(allImagesLoaded(), timeouts.fetch);

// Hide cursor before taking screenshot
Expand All @@ -91,13 +88,12 @@ describe('carousel without avatar initials', () => {
test('2 attachments with wide screen', async () => {
const { driver, pageObjects } = await setupWebDriver({ width: 640 });

await driver.wait(webChatLoaded(), timeouts.navigation);
await driver.wait(directLineConnected(), timeouts.directLine);
await driver.wait(botConnected(), timeouts.directLine);

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

await input.sendKeys('layout double', Key.RETURN);
await driver.wait(minNumActivitiesReached(3), timeouts.directLine);
await driver.wait(minNumActivitiesShown(3), timeouts.directLine);
await driver.wait(allImagesLoaded(), timeouts.fetch);

// Hide cursor before taking screenshot
Expand All @@ -109,13 +105,12 @@ describe('carousel without avatar initials', () => {
test('1 attachment', async () => {
const { driver, pageObjects } = await setupWebDriver();

await driver.wait(webChatLoaded(), timeouts.navigation);
await driver.wait(directLineConnected(), timeouts.directLine);
await driver.wait(botConnected(), timeouts.directLine);

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

await input.sendKeys('layout single carousel', Key.RETURN);
await driver.wait(minNumActivitiesReached(3), timeouts.directLine);
await driver.wait(minNumActivitiesShown(3), timeouts.directLine);
await driver.wait(allImagesLoaded(), timeouts.fetch);

// Hide cursor before taking screenshot
Expand All @@ -127,13 +122,12 @@ describe('carousel without avatar initials', () => {
test('1 attachment with wide screen', async () => {
const { driver, pageObjects } = await setupWebDriver({ width: 640 });

await driver.wait(webChatLoaded(), timeouts.navigation);
await driver.wait(directLineConnected(), timeouts.directLine);
await driver.wait(botConnected(), timeouts.directLine);

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

await input.sendKeys('layout single carousel', Key.RETURN);
await driver.wait(minNumActivitiesReached(3), timeouts.directLine);
await driver.wait(minNumActivitiesShown(3), timeouts.directLine);
await driver.wait(allImagesLoaded(), timeouts.fetch);

// Hide cursor before taking screenshot
Expand All @@ -149,13 +143,12 @@ describe('carousel with avatar initials', () => {
test('4 attachments and no message', async () => {
const { driver, pageObjects } = await setupWebDriver({ props: WEB_CHAT_PROPS });

await driver.wait(webChatLoaded(), timeouts.navigation);
await driver.wait(directLineConnected(), timeouts.directLine);
await driver.wait(botConnected(), timeouts.directLine);

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

await input.sendKeys('carousel', Key.RETURN);
await driver.wait(minNumActivitiesReached(3), timeouts.directLine);
await driver.wait(minNumActivitiesShown(3), timeouts.directLine);
await driver.wait(allImagesLoaded(), timeouts.fetch);

// Hide cursor before taking screenshot
Expand All @@ -179,13 +172,12 @@ describe('carousel with avatar initials', () => {
test('4 attachments and message', async () => {
const { driver, pageObjects } = await setupWebDriver({ props: WEB_CHAT_PROPS });

await driver.wait(webChatLoaded(), timeouts.navigation);
await driver.wait(directLineConnected(), timeouts.directLine);
await driver.wait(botConnected(), timeouts.directLine);

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

await input.sendKeys('layout carousel', Key.RETURN);
await driver.wait(minNumActivitiesReached(3), timeouts.directLine);
await driver.wait(minNumActivitiesShown(3), timeouts.directLine);
await driver.wait(allImagesLoaded(), timeouts.fetch);

// Hide cursor before taking screenshot
Expand All @@ -209,13 +201,12 @@ describe('carousel with avatar initials', () => {
test('2 attachments', async () => {
const { driver, pageObjects } = await setupWebDriver({ props: WEB_CHAT_PROPS });

await driver.wait(webChatLoaded(), timeouts.navigation);
await driver.wait(directLineConnected(), timeouts.directLine);
await driver.wait(botConnected(), timeouts.directLine);

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

await input.sendKeys('layout double', Key.RETURN);
await driver.wait(minNumActivitiesReached(3), timeouts.directLine);
await driver.wait(minNumActivitiesShown(3), timeouts.directLine);
await driver.wait(allImagesLoaded(), timeouts.fetch);

// Hide cursor before taking screenshot
Expand All @@ -227,13 +218,12 @@ describe('carousel with avatar initials', () => {
test('2 attachments with wide screen', async () => {
const { driver, pageObjects } = await setupWebDriver({ props: WEB_CHAT_PROPS, width: 640 });

await driver.wait(webChatLoaded(), timeouts.navigation);
await driver.wait(directLineConnected(), timeouts.directLine);
await driver.wait(botConnected(), timeouts.directLine);

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

await input.sendKeys('layout double', Key.RETURN);
await driver.wait(minNumActivitiesReached(3), timeouts.directLine);
await driver.wait(minNumActivitiesShown(3), timeouts.directLine);
await driver.wait(allImagesLoaded(), timeouts.fetch);

// Hide cursor before taking screenshot
Expand All @@ -245,13 +235,12 @@ describe('carousel with avatar initials', () => {
test('1 attachment', async () => {
const { driver, pageObjects } = await setupWebDriver({ props: WEB_CHAT_PROPS });

await driver.wait(webChatLoaded(), timeouts.navigation);
await driver.wait(directLineConnected(), timeouts.directLine);
await driver.wait(botConnected(), timeouts.directLine);

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

await input.sendKeys('layout single carousel', Key.RETURN);
await driver.wait(minNumActivitiesReached(3), timeouts.directLine);
await driver.wait(minNumActivitiesShown(3), timeouts.directLine);
await driver.wait(allImagesLoaded(), timeouts.fetch);

// Hide cursor before taking screenshot
Expand All @@ -263,13 +252,12 @@ describe('carousel with avatar initials', () => {
test('1 attachment with wide screen', async () => {
const { driver, pageObjects } = await setupWebDriver({ props: WEB_CHAT_PROPS, width: 640 });

await driver.wait(webChatLoaded(), timeouts.navigation);
await driver.wait(directLineConnected(), timeouts.directLine);
await driver.wait(botConnected(), timeouts.directLine);

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

await input.sendKeys('layout single carousel', Key.RETURN);
await driver.wait(minNumActivitiesReached(3), timeouts.directLine);
await driver.wait(minNumActivitiesShown(3), timeouts.directLine);
await driver.wait(allImagesLoaded(), timeouts.fetch);

// Hide cursor before taking screenshot
Expand Down
2 changes: 1 addition & 1 deletion __tests__/constants.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
}
},
"timeouts": {
"directLine": 2500,
"directLine": 5000,
"fetch": 2500,
"navigation": 5000
}
Expand Down
6 changes: 4 additions & 2 deletions __tests__/setup/setupTestFramework.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { Builder } from 'selenium-webdriver';
import { configureToMatchImageSnapshot } from 'jest-image-snapshot';
import { createServer } from 'http';
import { join } from 'path';
import { promisify } from 'util';
import { configureToMatchImageSnapshot } from 'jest-image-snapshot';
import getPort from 'get-port';
import handler from 'serve-handler';

import { timeouts } from '../constants.json';

import createPageObjects from './pageObjects/index';
import setupTestEnvironment from './setupTestEnvironment';
import webChatLoaded from './conditions/webChatLoaded';
Expand Down Expand Up @@ -43,7 +45,7 @@ global.setupWebDriver = async (options = {}) => {
main({ props });
}, global.__coverage__, options.props);

await driver.wait(webChatLoaded(), 5000);
await driver.wait(webChatLoaded(), timeouts.navigation);

return { driver, pageObjects: createPageObjects(driver) };
})();
Expand Down
35 changes: 14 additions & 21 deletions __tests__/stacked.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ import { By, Key } from 'selenium-webdriver';
import { imageSnapshotOptions, timeouts } from './constants.json';

import allImagesLoaded from './setup/conditions/allImagesLoaded';
import directLineConnected from './setup/conditions/directLineConnected';
import minNumActivitiesReached from './setup/conditions/minNumActivitiesReached';
import webChatLoaded from './setup/conditions/webChatLoaded';
import botConnected from './setup/conditions/botConnected';
import minNumActivitiesShown from './setup/conditions/minNumActivitiesShown';

// selenium-webdriver API doc:
// https://seleniumhq.github.io/selenium/docs/api/javascript/module/selenium-webdriver/index_exports_WebDriver.html
Expand All @@ -14,13 +13,12 @@ describe('stacked without avatar initials', () => {
test('4 attachments', async () => {
const { driver, pageObjects } = await setupWebDriver();

await driver.wait(webChatLoaded(), timeouts.navigation);
await driver.wait(directLineConnected(), timeouts.directLine);
await driver.wait(botConnected(), timeouts.directLine);

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

await input.sendKeys('layout stacked', Key.RETURN);
await driver.wait(minNumActivitiesReached(3), timeouts.directLine);
await driver.wait(minNumActivitiesShown(3), timeouts.directLine);
await driver.wait(allImagesLoaded(), timeouts.fetch);

// Hide cursor before taking screenshot
Expand All @@ -32,13 +30,12 @@ describe('stacked without avatar initials', () => {
test('1 attachment', async () => {
const { driver, pageObjects } = await setupWebDriver();

await driver.wait(webChatLoaded(), timeouts.navigation);
await driver.wait(directLineConnected(), timeouts.directLine);
await driver.wait(botConnected(), timeouts.directLine);

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

await input.sendKeys('layout single', Key.RETURN);
await driver.wait(minNumActivitiesReached(3), timeouts.directLine);
await driver.wait(minNumActivitiesShown(3), timeouts.directLine);
await driver.wait(allImagesLoaded(), timeouts.fetch);

// Hide cursor before taking screenshot
Expand All @@ -50,13 +47,12 @@ describe('stacked without avatar initials', () => {
test('1 attachment with wide screen', async () => {
const { driver, pageObjects } = await setupWebDriver({ width: 640 });

await driver.wait(webChatLoaded(), timeouts.navigation);
await driver.wait(directLineConnected(), timeouts.directLine);
await driver.wait(botConnected(), timeouts.directLine);

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

await input.sendKeys('layout single', Key.RETURN);
await driver.wait(minNumActivitiesReached(3), timeouts.directLine);
await driver.wait(minNumActivitiesShown(3), timeouts.directLine);
await driver.wait(allImagesLoaded(), timeouts.fetch);

// Hide cursor before taking screenshot
Expand All @@ -72,13 +68,12 @@ describe('stacked with avatar initials', () => {
test('4 attachments', async () => {
const { driver, pageObjects } = await setupWebDriver({ props: WEB_CHAT_PROPS });

await driver.wait(webChatLoaded(), timeouts.navigation);
await driver.wait(directLineConnected(), timeouts.directLine);
await driver.wait(botConnected(), timeouts.directLine);

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

await input.sendKeys('layout stacked', Key.RETURN);
await driver.wait(minNumActivitiesReached(3), timeouts.directLine);
await driver.wait(minNumActivitiesShown(3), timeouts.directLine);
await driver.wait(allImagesLoaded(), timeouts.fetch);

// Hide cursor before taking screenshot
Expand All @@ -90,13 +85,12 @@ describe('stacked with avatar initials', () => {
test('1 attachment', async () => {
const { driver, pageObjects } = await setupWebDriver({ props: WEB_CHAT_PROPS });

await driver.wait(webChatLoaded(), timeouts.navigation);
await driver.wait(directLineConnected(), timeouts.directLine);
await driver.wait(botConnected(), timeouts.directLine);

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

await input.sendKeys('layout single', Key.RETURN);
await driver.wait(minNumActivitiesReached(3), timeouts.directLine);
await driver.wait(minNumActivitiesShown(3), timeouts.directLine);
await driver.wait(allImagesLoaded(), timeouts.fetch);

// Hide cursor before taking screenshot
Expand All @@ -108,13 +102,12 @@ describe('stacked with avatar initials', () => {
test('1 attachment with wide screen', async () => {
const { driver, pageObjects } = await setupWebDriver({ props: WEB_CHAT_PROPS, width: 640 });

await driver.wait(webChatLoaded(), timeouts.navigation);
await driver.wait(directLineConnected(), timeouts.directLine);
await driver.wait(botConnected(), timeouts.directLine);

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

await input.sendKeys('layout single', Key.RETURN);
await driver.wait(minNumActivitiesReached(3), timeouts.directLine);
await driver.wait(minNumActivitiesShown(3), timeouts.directLine);
await driver.wait(allImagesLoaded(), timeouts.fetch);

// Hide cursor before taking screenshot
Expand Down
Loading

0 comments on commit 1d16bf8

Please sign in to comment.