-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix carousel alignment and test perf improvement (#1641)
* Remove empty line * Fix padding for carousel with avatar * Add carousel tests * Update entry * Add more tests for carousel and stacked layout * Update snapshots and improve image load check perf * Typo * Fix test * Fix image wait * Add #1625
- Loading branch information
Showing
45 changed files
with
534 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
+0 Bytes
(100%)
__tests__/__image_snapshots__/chrome-docker/basic-js-setup-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+77.4 KB
...chrome-docker/carousel-js-carousel-with-avatar-initials-1-attachment-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+162 KB
...ousel-js-carousel-with-avatar-initials-1-attachment-with-wide-screen-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+65.1 KB
...hrome-docker/carousel-js-carousel-with-avatar-initials-2-attachments-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+97.5 KB
...usel-js-carousel-with-avatar-initials-2-attachments-with-wide-screen-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+64.4 KB
.../carousel-js-carousel-with-avatar-initials-4-attachments-and-message-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+27 KB
.../carousel-js-carousel-with-avatar-initials-4-attachments-and-message-2-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+58.8 KB
...rousel-js-carousel-with-avatar-initials-4-attachments-and-no-message-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+46.8 KB
...rousel-js-carousel-with-avatar-initials-4-attachments-and-no-message-2-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+89 KB
...ome-docker/carousel-js-carousel-without-avatar-initials-1-attachment-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+157 KB
...el-js-carousel-without-avatar-initials-1-attachment-with-wide-screen-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+65.6 KB
...me-docker/carousel-js-carousel-without-avatar-initials-2-attachments-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+104 KB
...l-js-carousel-without-avatar-initials-2-attachments-with-wide-screen-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+63.2 KB
...rousel-js-carousel-without-avatar-initials-4-attachments-and-message-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+24.1 KB
...rousel-js-carousel-without-avatar-initials-4-attachments-and-message-2-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+58.4 KB
...sel-js-carousel-without-avatar-initials-4-attachments-and-no-message-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+44.1 KB
...sel-js-carousel-without-avatar-initials-4-attachments-and-no-message-2-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+77.5 KB
..._/chrome-docker/stacked-js-stacked-with-avatar-initials-1-attachment-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+162 KB
...tacked-js-stacked-with-avatar-initials-1-attachment-with-wide-screen-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+83.7 KB
.../chrome-docker/stacked-js-stacked-with-avatar-initials-4-attachments-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+88.9 KB
...hrome-docker/stacked-js-stacked-without-avatar-initials-1-attachment-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+157 KB
...ked-js-stacked-without-avatar-initials-1-attachment-with-wide-screen-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+98 KB
...rome-docker/stacked-js-stacked-without-avatar-initials-4-attachments-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-6 Bytes
(100%)
...how-correctly-formatted-buttons-when-suggested-actions-are-displayed-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+0 Bytes
(100%)
...ommand-should-show-response-from-bot-and-no-text-from-user-on-imback-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-2 Bytes
(100%)
...d-should-show-response-from-bot-and-no-text-from-user-on-messageback-1-snap.png
Oops, something went wrong.
Binary file modified
BIN
-3 Bytes
(100%)
...mand-should-show-response-from-bot-and-no-text-from-user-on-postback-1-snap.png
Oops, something went wrong.
Binary file modified
BIN
-3 Bytes
(100%)
...mand-should-show-response-from-bot-and-text-from-user-on-messageback-1-snap.png
Oops, something went wrong.
Binary file modified
BIN
-5 Bytes
(100%)
...command-should-show-response-from-bot-and-text-from-user-on-postback-1-snap.png
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,280 @@ | ||
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'; | ||
|
||
// selenium-webdriver API doc: | ||
// https://seleniumhq.github.io/selenium/docs/api/javascript/module/selenium-webdriver/index_exports_WebDriver.html | ||
|
||
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); | ||
|
||
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(allImagesLoaded(), timeouts.fetch); | ||
|
||
// Hide cursor before taking screenshot | ||
await pageObjects.hideCursor(); | ||
|
||
expect(await driver.takeScreenshot()).toMatchImageSnapshot(imageSnapshotOptions); | ||
|
||
const rightFlipper = await driver.findElement(By.css('button[aria-label="Right"]')); | ||
|
||
await rightFlipper.click(); | ||
await rightFlipper.click(); | ||
await rightFlipper.click(); | ||
await rightFlipper.click(); | ||
|
||
// Wait for carousel animation to finish | ||
await driver.sleep(1000); | ||
|
||
expect(await driver.takeScreenshot()).toMatchImageSnapshot(imageSnapshotOptions); | ||
}, 60000); | ||
|
||
test('4 attachments and message', 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 carousel', Key.RETURN); | ||
await driver.wait(minNumActivitiesReached(3), timeouts.directLine); | ||
await driver.wait(allImagesLoaded(), timeouts.fetch); | ||
|
||
// Hide cursor before taking screenshot | ||
await pageObjects.hideCursor(); | ||
|
||
expect(await driver.takeScreenshot()).toMatchImageSnapshot(imageSnapshotOptions); | ||
|
||
const rightFlipper = await driver.findElement(By.css('button[aria-label="Right"]')); | ||
|
||
await rightFlipper.click(); | ||
await rightFlipper.click(); | ||
await rightFlipper.click(); | ||
await rightFlipper.click(); | ||
|
||
// Wait for carousel animation to finish | ||
await driver.sleep(1000); | ||
|
||
expect(await driver.takeScreenshot()).toMatchImageSnapshot(imageSnapshotOptions); | ||
}, 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(3), timeouts.directLine); | ||
await driver.wait(allImagesLoaded(), timeouts.fetch); | ||
|
||
// 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); | ||
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(3), timeouts.directLine); | ||
await driver.wait(allImagesLoaded(), timeouts.fetch); | ||
|
||
// 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 carousel', Key.RETURN); | ||
await driver.wait(minNumActivitiesReached(3), timeouts.directLine); | ||
await driver.wait(allImagesLoaded(), timeouts.fetch); | ||
|
||
// 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(3), timeouts.directLine); | ||
await driver.wait(allImagesLoaded(), timeouts.fetch); | ||
|
||
// Hide cursor before taking screenshot | ||
await pageObjects.hideCursor(); | ||
|
||
expect(await driver.takeScreenshot()).toMatchImageSnapshot(imageSnapshotOptions); | ||
}, 60000); | ||
}); | ||
|
||
describe('carousel with avatar initials', () => { | ||
const WEB_CHAT_PROPS = { styleOptions: { botAvatarInitials: 'BF', userAvatarInitials: 'WC' } }; | ||
|
||
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); | ||
|
||
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(allImagesLoaded(), timeouts.fetch); | ||
|
||
// Hide cursor before taking screenshot | ||
await pageObjects.hideCursor(); | ||
|
||
expect(await driver.takeScreenshot()).toMatchImageSnapshot(imageSnapshotOptions); | ||
|
||
const rightFlipper = await driver.findElement(By.css('button[aria-label="Right"]')); | ||
|
||
await rightFlipper.click(); | ||
await rightFlipper.click(); | ||
await rightFlipper.click(); | ||
await rightFlipper.click(); | ||
|
||
// Wait for carousel animation to finish | ||
await driver.sleep(1000); | ||
|
||
expect(await driver.takeScreenshot()).toMatchImageSnapshot(imageSnapshotOptions); | ||
}, 60000); | ||
|
||
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); | ||
|
||
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(allImagesLoaded(), timeouts.fetch); | ||
|
||
// Hide cursor before taking screenshot | ||
await pageObjects.hideCursor(); | ||
|
||
expect(await driver.takeScreenshot()).toMatchImageSnapshot(imageSnapshotOptions); | ||
|
||
const rightFlipper = await driver.findElement(By.css('button[aria-label="Right"]')); | ||
|
||
await rightFlipper.click(); | ||
await rightFlipper.click(); | ||
await rightFlipper.click(); | ||
await rightFlipper.click(); | ||
|
||
// Wait for carousel animation to finish | ||
await driver.sleep(1000); | ||
|
||
expect(await driver.takeScreenshot()).toMatchImageSnapshot(imageSnapshotOptions); | ||
}, 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(3), timeouts.directLine); | ||
await driver.wait(allImagesLoaded(), timeouts.fetch); | ||
|
||
// 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); | ||
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(3), timeouts.directLine); | ||
await driver.wait(allImagesLoaded(), timeouts.fetch); | ||
|
||
// 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 carousel', Key.RETURN); | ||
await driver.wait(minNumActivitiesReached(3), timeouts.directLine); | ||
await driver.wait(allImagesLoaded(), timeouts.fetch); | ||
|
||
// 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(3), timeouts.directLine); | ||
await driver.wait(allImagesLoaded(), timeouts.fetch); | ||
|
||
// Hide cursor before taking screenshot | ||
await pageObjects.hideCursor(); | ||
|
||
expect(await driver.takeScreenshot()).toMatchImageSnapshot(imageSnapshotOptions); | ||
}, 60000); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { Condition } from 'selenium-webdriver'; | ||
|
||
export default function () { | ||
return new Condition('Waiting for Direct Line to connect', async driver => { | ||
return await driver.executeScript(() => { | ||
const { store } = window.WebChatTest; | ||
const { activities } = store.getState(); | ||
|
||
return activities.filter(({ from: { role } }) => role === 'user').every(({ channelData: { state } }) => state === 'sent'); | ||
}); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { By, until } from 'selenium-webdriver'; | ||
|
||
export default function () { | ||
return until.elementLocated(By.css('[role="form"] ul')); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export default async function hideCursor(driver) { | ||
await driver.executeScript(() => document.querySelector(':focus').blur()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import hideCursor from './hideCursor'; | ||
|
||
export default function (driver) { | ||
return { | ||
hideCursor: hideCursor.bind(null, driver) | ||
}; | ||
} |
Oops, something went wrong.