Skip to content

Commit

Permalink
Update snapshots and improve image load check perf
Browse files Browse the repository at this point in the history
  • Loading branch information
compulim committed Jan 27, 2019
1 parent f1f2f59 commit 993f169
Show file tree
Hide file tree
Showing 34 changed files with 49 additions and 75 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.
5 changes: 2 additions & 3 deletions __tests__/basic.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { By, Key } from 'selenium-webdriver';

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

import allImagesLoaded from './setup/conditions/allImagesLoaded.js';
import directLineConnected from './setup/conditions/directLineConnected';
import minNumActivitiesReached from './setup/conditions/minNumActivitiesReached';
import webChatLoaded from './setup/conditions/webChatLoaded';
Expand All @@ -19,9 +20,7 @@ test('setup', async () => {

await input.sendKeys('layout 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);
await driver.wait(allImagesLoaded, timeouts.fetch);

// Hide cursor before taking screenshot
await pageObjects.hideCursor();
Expand Down
73 changes: 25 additions & 48 deletions __tests__/carousel.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
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';
Expand All @@ -18,10 +19,8 @@ describe('carousel without avatar initials', () => {
const input = await driver.findElement(By.css('input[type="text"]'));

await input.sendKeys('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);
await driver.wait(minNumActivitiesReached(3), timeouts.directLine);
await driver.wait(allImagesLoaded(), timeouts.fetch);

// Hide cursor before taking screenshot
await pageObjects.hideCursor();
Expand Down Expand Up @@ -50,10 +49,8 @@ describe('carousel without avatar initials', () => {
const input = await driver.findElement(By.css('input[type="text"]'));

await input.sendKeys('layout 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);
await driver.wait(minNumActivitiesReached(3), timeouts.directLine);
await driver.wait(allImagesLoaded(), timeouts.fetch);

// Hide cursor before taking screenshot
await pageObjects.hideCursor();
Expand Down Expand Up @@ -82,10 +79,8 @@ describe('carousel without avatar initials', () => {
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);
await driver.wait(minNumActivitiesReached(3), timeouts.directLine);
await driver.wait(allImagesLoaded(), timeouts.fetch);

// Hide cursor before taking screenshot
await pageObjects.hideCursor();
Expand All @@ -102,10 +97,8 @@ describe('carousel without avatar initials', () => {
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);
await driver.wait(minNumActivitiesReached(3), timeouts.directLine);
await driver.wait(allImagesLoaded(), timeouts.fetch);

// Hide cursor before taking screenshot
await pageObjects.hideCursor();
Expand All @@ -122,10 +115,8 @@ describe('carousel without avatar initials', () => {
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);
await driver.wait(minNumActivitiesReached(3), timeouts.directLine);
await driver.wait(allImagesLoaded(), timeouts.fetch);

// Hide cursor before taking screenshot
await pageObjects.hideCursor();
Expand All @@ -142,10 +133,8 @@ describe('carousel without avatar initials', () => {
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);
await driver.wait(minNumActivitiesReached(3), timeouts.directLine);
await driver.wait(allImagesLoaded(), timeouts.fetch);

// Hide cursor before taking screenshot
await pageObjects.hideCursor();
Expand All @@ -166,10 +155,8 @@ describe('carousel with avatar initials', () => {
const input = await driver.findElement(By.css('input[type="text"]'));

await input.sendKeys('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);
await driver.wait(minNumActivitiesReached(3), timeouts.directLine);
await driver.wait(allImagesLoaded(), timeouts.fetch);

// Hide cursor before taking screenshot
await pageObjects.hideCursor();
Expand Down Expand Up @@ -198,10 +185,8 @@ describe('carousel with avatar initials', () => {
const input = await driver.findElement(By.css('input[type="text"]'));

await input.sendKeys('layout 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);
await driver.wait(minNumActivitiesReached(3), timeouts.directLine);
await driver.wait(allImagesLoaded(), timeouts.fetch);

// Hide cursor before taking screenshot
await pageObjects.hideCursor();
Expand Down Expand Up @@ -230,10 +215,8 @@ describe('carousel with avatar initials', () => {
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);
await driver.wait(minNumActivitiesReached(3), timeouts.directLine);
await driver.wait(allImagesLoaded(), timeouts.fetch);

// Hide cursor before taking screenshot
await pageObjects.hideCursor();
Expand All @@ -250,10 +233,8 @@ describe('carousel with avatar initials', () => {
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);
await driver.wait(minNumActivitiesReached(3), timeouts.directLine);
await driver.wait(allImagesLoaded(), timeouts.fetch);

// Hide cursor before taking screenshot
await pageObjects.hideCursor();
Expand All @@ -270,10 +251,8 @@ describe('carousel with avatar initials', () => {
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);
await driver.wait(minNumActivitiesReached(3), timeouts.directLine);
await driver.wait(allImagesLoaded(), timeouts.fetch);

// Hide cursor before taking screenshot
await pageObjects.hideCursor();
Expand All @@ -290,10 +269,8 @@ describe('carousel with avatar initials', () => {
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);
await driver.wait(minNumActivitiesReached(3), timeouts.directLine);
await driver.wait(allImagesLoaded(), timeouts.fetch);

// Hide cursor before taking screenshot
await pageObjects.hideCursor();
Expand Down
1 change: 1 addition & 0 deletions __tests__/constants.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
},
"timeouts": {
"directLine": 2500,
"fetch": 2500,
"navigation": 5000
}
}
7 changes: 7 additions & 0 deletions __tests__/setup/conditions/allImagesLoaded.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { Condition } from 'selenium-webdriver';

export default function () {
return new Condition('Waiting for all images to be loaded', async driver =>
await driver.executeScript(() => [].every.call(document.querySelectorAll('img'), ({ complete }) => complete))
);
}
38 changes: 14 additions & 24 deletions __tests__/stacked.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,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';
Expand All @@ -18,10 +20,8 @@ describe('stacked without avatar initials', () => {
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);
await driver.wait(minNumActivitiesReached(3), timeouts.directLine);
await driver.wait(allImagesLoaded(), timeouts.fetch);

// Hide cursor before taking screenshot
await pageObjects.hideCursor();
Expand All @@ -38,10 +38,8 @@ describe('stacked without avatar initials', () => {
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);
await driver.wait(minNumActivitiesReached(3), timeouts.directLine);
await driver.wait(allImagesLoaded(), timeouts.fetch);

// Hide cursor before taking screenshot
await pageObjects.hideCursor();
Expand All @@ -58,10 +56,8 @@ describe('stacked without avatar initials', () => {
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);
await driver.wait(minNumActivitiesReached(3), timeouts.directLine);
await driver.wait(allImagesLoaded(), timeouts.fetch);

// Hide cursor before taking screenshot
await pageObjects.hideCursor();
Expand All @@ -82,10 +78,8 @@ describe('stacked with avatar initials', () => {
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);
await driver.wait(minNumActivitiesReached(3), timeouts.directLine);
await driver.wait(allImagesLoaded(), timeouts.fetch);

// Hide cursor before taking screenshot
await pageObjects.hideCursor();
Expand All @@ -102,10 +96,8 @@ describe('stacked with avatar initials', () => {
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);
await driver.wait(minNumActivitiesReached(3), timeouts.directLine);
await driver.wait(allImagesLoaded(), timeouts.fetch);

// Hide cursor before taking screenshot
await pageObjects.hideCursor();
Expand All @@ -122,10 +114,8 @@ describe('stacked with avatar initials', () => {
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);
await driver.wait(minNumActivitiesReached(3), timeouts.directLine);
await driver.wait(allImagesLoaded(), timeouts.fetch);

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

0 comments on commit 993f169

Please sign in to comment.