Skip to content

Commit

Permalink
Add more tests for carousel and stacked layout
Browse files Browse the repository at this point in the history
  • Loading branch information
compulim committed Jan 25, 2019
1 parent 1c05c19 commit 2e92474
Show file tree
Hide file tree
Showing 16 changed files with 255 additions and 0 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.
120 changes: 120 additions & 0 deletions __tests__/carousel.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,26 @@ describe('carousel without avatar initials', () => {
}, 60000);

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

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

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

await input.sendKeys('layout double', Key.RETURN);
await driver.wait(minNumActivitiesReached(2), timeouts.directLine);

// TODO: [P2] Remove this sleep which wait for the image to be loaded
await driver.sleep(1000);

// Hide cursor before taking screenshot
await pageObjects.hideCursor();

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

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

await driver.wait(webChatLoaded(), timeouts.navigation);
Expand All @@ -92,6 +112,46 @@ describe('carousel without avatar initials', () => {

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

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

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

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

await input.sendKeys('layout single carousel', Key.RETURN);
await driver.wait(minNumActivitiesReached(2), timeouts.directLine);

// TODO: [P2] Remove this sleep which wait for the image to be loaded
await driver.sleep(1000);

// Hide cursor before taking screenshot
await pageObjects.hideCursor();

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

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);

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

await input.sendKeys('layout single carousel', Key.RETURN);
await driver.wait(minNumActivitiesReached(2), timeouts.directLine);

// TODO: [P2] Remove this sleep which wait for the image to be loaded
await driver.sleep(1000);

// Hide cursor before taking screenshot
await pageObjects.hideCursor();

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

describe('carousel with avatar initials', () => {
Expand Down Expand Up @@ -162,6 +222,26 @@ describe('carousel with avatar initials', () => {
}, 60000);

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);

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

await input.sendKeys('layout double', Key.RETURN);
await driver.wait(minNumActivitiesReached(2), timeouts.directLine);

// TODO: [P2] Remove this sleep which wait for the image to be loaded
await driver.sleep(1000);

// Hide cursor before taking screenshot
await pageObjects.hideCursor();

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

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

await driver.wait(webChatLoaded(), timeouts.navigation);
Expand All @@ -180,4 +260,44 @@ describe('carousel with avatar initials', () => {

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

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);

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

await input.sendKeys('layout single carousel', Key.RETURN);
await driver.wait(minNumActivitiesReached(2), timeouts.directLine);

// TODO: [P2] Remove this sleep which wait for the image to be loaded
await driver.sleep(1000);

// Hide cursor before taking screenshot
await pageObjects.hideCursor();

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

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);

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

await input.sendKeys('layout single carousel', Key.RETURN);
await driver.wait(minNumActivitiesReached(2), timeouts.directLine);

// TODO: [P2] Remove this sleep which wait for the image to be loaded
await driver.sleep(1000);

// Hide cursor before taking screenshot
await pageObjects.hideCursor();

expect(await driver.takeScreenshot()).toMatchImageSnapshot(imageSnapshotOptions);
}, 60000);
});
135 changes: 135 additions & 0 deletions __tests__/stacked.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
import { By, Key } from 'selenium-webdriver';

import { imageSnapshotOptions, timeouts } from './constants.json';
import directLineConnected from './setup/conditions/directLineConnected';
import minNumActivitiesReached from './setup/conditions/minNumActivitiesReached';
import webChatLoaded from './setup/conditions/webChatLoaded';

// selenium-webdriver API doc:
// https://seleniumhq.github.io/selenium/docs/api/javascript/module/selenium-webdriver/index_exports_WebDriver.html

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);

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

await input.sendKeys('layout stacked', Key.RETURN);
await driver.wait(minNumActivitiesReached(2), timeouts.directLine);

// TODO: [P2] Remove this sleep which wait for the image to be loaded
await driver.sleep(1000);

// Hide cursor before taking screenshot
await pageObjects.hideCursor();

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

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

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

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

await input.sendKeys('layout single', Key.RETURN);
await driver.wait(minNumActivitiesReached(2), timeouts.directLine);

// TODO: [P2] Remove this sleep which wait for the image to be loaded
await driver.sleep(1000);

// Hide cursor before taking screenshot
await pageObjects.hideCursor();

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

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);

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

await input.sendKeys('layout single', Key.RETURN);
await driver.wait(minNumActivitiesReached(2), timeouts.directLine);

// TODO: [P2] Remove this sleep which wait for the image to be loaded
await driver.sleep(1000);

// Hide cursor before taking screenshot
await pageObjects.hideCursor();

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

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

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);

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

await input.sendKeys('layout stacked', Key.RETURN);
await driver.wait(minNumActivitiesReached(2), timeouts.directLine);

// TODO: [P2] Remove this sleep which wait for the image to be loaded
await driver.sleep(1000);

// Hide cursor before taking screenshot
await pageObjects.hideCursor();

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

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);

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

await input.sendKeys('layout single', Key.RETURN);
await driver.wait(minNumActivitiesReached(2), timeouts.directLine);

// TODO: [P2] Remove this sleep which wait for the image to be loaded
await driver.sleep(1000);

// Hide cursor before taking screenshot
await pageObjects.hideCursor();

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

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);

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

await input.sendKeys('layout single', Key.RETURN);
await driver.wait(minNumActivitiesReached(2), timeouts.directLine);

// TODO: [P2] Remove this sleep which wait for the image to be loaded
await driver.sleep(1000);

// Hide cursor before taking screenshot
await pageObjects.hideCursor();

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

0 comments on commit 2e92474

Please sign in to comment.