-
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 receipt card and disabled Adaptive Cards (#2417)
* Fix receipt card and disabled Adaptive Cards * Fix ESLint * Update PR entry * Add submission test
- Loading branch information
Showing
29 changed files
with
337 additions
and
104 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 added
BIN
+21.8 KB
..._/__image_snapshots__/chrome-docker/adaptive-cards-js-breakfast-card-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
+20.7 KB
...rome-docker/adaptive-cards-js-breakfast-card-with-custom-host-config-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
+33.2 KB
...mage_snapshots__/chrome-docker/adaptive-cards-js-disable-card-inputs-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
+33.2 KB
...mage_snapshots__/chrome-docker/adaptive-cards-js-disable-card-inputs-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
+34.5 KB
...mage_snapshots__/chrome-docker/adaptive-cards-js-disable-card-inputs-3-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
+20.8 KB
__tests__/__image_snapshots__/chrome-docker/rich-cards-js-audio-card-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
+21.8 KB
...sts__/__image_snapshots__/chrome-docker/rich-cards-js-breakfast-card-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
+80.6 KB
__tests__/__image_snapshots__/chrome-docker/rich-cards-js-hero-card-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
+11.5 KB
__tests__/__image_snapshots__/chrome-docker/rich-cards-js-oauth-card-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
+51.1 KB
__tests__/__image_snapshots__/chrome-docker/rich-cards-js-receipt-card-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
+11.9 KB
__tests__/__image_snapshots__/chrome-docker/rich-cards-js-sign-in-card-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
+18.6 KB
...sts__/__image_snapshots__/chrome-docker/rich-cards-js-thumbnail-card-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
+51.8 KB
...licking-new-messages-button-should-scroll-to-end-and-stick-to-bottom-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
+37.3 KB
...licking-new-messages-button-should-scroll-to-end-and-stick-to-bottom-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
+40.3 KB
...licking-new-messages-button-should-scroll-to-end-and-stick-to-bottom-3-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,79 @@ | ||
import { imageSnapshotOptions, timeouts } from './constants.json'; | ||
|
||
import allImagesLoaded from './setup/conditions/allImagesLoaded'; | ||
import minNumActivitiesShown from './setup/conditions/minNumActivitiesShown'; | ||
import scrollToBottomCompleted from './setup/conditions/scrollToBottomCompleted'; | ||
import uiConnected from './setup/conditions/uiConnected'; | ||
|
||
import createAdaptiveCardsHostConfig from '../packages/bundle/src/adaptiveCards/Styles/adaptiveCardHostConfig'; | ||
import defaultStyleOptions from '../packages/component/src/Styles/defaultStyleOptions'; | ||
|
||
// selenium-webdriver API doc: | ||
// https://seleniumhq.github.io/selenium/docs/api/javascript/module/selenium-webdriver/index_exports_WebDriver.html | ||
|
||
jest.setTimeout(timeouts.test); | ||
|
||
test('breakfast card', async () => { | ||
const { driver, pageObjects } = await setupWebDriver(); | ||
|
||
await driver.wait(uiConnected(), timeouts.directLine); | ||
await pageObjects.sendMessageViaSendBox('card breakfast', { waitForSend: true }); | ||
|
||
await driver.wait(minNumActivitiesShown(2), timeouts.directLine); | ||
await driver.wait(allImagesLoaded(), 2000); | ||
|
||
const base64PNG = await driver.takeScreenshot(); | ||
|
||
expect(base64PNG).toMatchImageSnapshot(imageSnapshotOptions); | ||
}); | ||
|
||
test('breakfast card with custom host config', async () => { | ||
const adaptiveCardHostConfig = createAdaptiveCardsHostConfig({ ...defaultStyleOptions, bubbleTextColor: '#FF0000' }); | ||
|
||
const { driver, pageObjects } = await setupWebDriver({ | ||
props: { | ||
adaptiveCardHostConfig | ||
} | ||
}); | ||
|
||
await driver.wait(uiConnected(), timeouts.directLine); | ||
await pageObjects.sendMessageViaSendBox('card breakfast', { waitForSend: true }); | ||
|
||
await driver.wait(minNumActivitiesShown(2), timeouts.directLine); | ||
await driver.wait(allImagesLoaded(), 2000); | ||
|
||
const base64PNG = await driver.takeScreenshot(); | ||
|
||
expect(base64PNG).toMatchImageSnapshot(imageSnapshotOptions); | ||
}); | ||
|
||
test('disable card inputs', async () => { | ||
const { driver, pageObjects } = await setupWebDriver(); | ||
|
||
await driver.wait(uiConnected(), timeouts.directLine); | ||
await pageObjects.sendMessageViaSendBox('card inputs', { waitForSend: true }); | ||
|
||
await driver.wait(minNumActivitiesShown(2), timeouts.directLine); | ||
await driver.wait(allImagesLoaded(), 2000); | ||
await driver.wait(scrollToBottomCompleted(), timeouts.scrollToBottom); | ||
|
||
await driver.executeScript(() => { | ||
document.querySelector('.ac-input input[type="checkbox"]').checked = true; | ||
}); | ||
|
||
expect(await driver.takeScreenshot()).toMatchImageSnapshot(imageSnapshotOptions); | ||
|
||
await pageObjects.updateProps({ disabled: true }); | ||
|
||
expect(await driver.takeScreenshot()).toMatchImageSnapshot(imageSnapshotOptions); | ||
|
||
await pageObjects.updateProps({ disabled: false }); | ||
await driver.executeScript(() => { | ||
document.querySelector('.ac-actionSet button:nth-of-type(2)').click(); | ||
}); | ||
|
||
await driver.wait(minNumActivitiesShown(3), timeouts.directLine); | ||
await driver.wait(scrollToBottomCompleted(), timeouts.scrollToBottom); | ||
|
||
expect(await driver.takeScreenshot()).toMatchImageSnapshot(imageSnapshotOptions); | ||
}); |
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,96 @@ | ||
import { imageSnapshotOptions, timeouts } from './constants.json'; | ||
|
||
import allImagesLoaded from './setup/conditions/allImagesLoaded'; | ||
import minNumActivitiesShown from './setup/conditions/minNumActivitiesShown'; | ||
import scrollToBottomCompleted from './setup/conditions/scrollToBottomCompleted'; | ||
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); | ||
|
||
test('audio card', async () => { | ||
const { driver, pageObjects } = await setupWebDriver(); | ||
|
||
await driver.wait(uiConnected(), timeouts.directLine); | ||
await pageObjects.sendMessageViaSendBox('audiocard', { waitForSend: true }); | ||
|
||
await driver.wait(minNumActivitiesShown(2), timeouts.directLine); | ||
await driver.wait(allImagesLoaded(), 2000); | ||
|
||
const base64PNG = await driver.takeScreenshot(); | ||
|
||
expect(base64PNG).toMatchImageSnapshot(imageSnapshotOptions); | ||
}); | ||
|
||
test('hero card', async () => { | ||
const { driver, pageObjects } = await setupWebDriver(); | ||
|
||
await driver.wait(uiConnected(), timeouts.directLine); | ||
await pageObjects.sendMessageViaSendBox('herocard', { waitForSend: true }); | ||
|
||
await driver.wait(minNumActivitiesShown(2), timeouts.directLine); | ||
await driver.wait(allImagesLoaded(), 2000); | ||
await driver.wait(scrollToBottomCompleted(), timeouts.scrollToBottom); | ||
|
||
const base64PNG = await driver.takeScreenshot(); | ||
|
||
expect(base64PNG).toMatchImageSnapshot(imageSnapshotOptions); | ||
}); | ||
|
||
test('oauth card', async () => { | ||
const { driver, pageObjects } = await setupWebDriver({ useProductionBot: true }); | ||
|
||
await driver.wait(uiConnected(), timeouts.directLine); | ||
await pageObjects.sendMessageViaSendBox('oauth', { waitForSend: true }); | ||
|
||
await driver.wait(minNumActivitiesShown(2), timeouts.directLine); | ||
await driver.wait(allImagesLoaded(), 2000); | ||
|
||
const base64PNG = await driver.takeScreenshot(); | ||
|
||
expect(base64PNG).toMatchImageSnapshot(imageSnapshotOptions); | ||
}); | ||
|
||
test('receipt card', async () => { | ||
const { driver, pageObjects } = await setupWebDriver(); | ||
|
||
await driver.wait(uiConnected(), timeouts.directLine); | ||
await pageObjects.sendMessageViaSendBox('receiptcard', { waitForSend: true }); | ||
|
||
await driver.wait(minNumActivitiesShown(2), timeouts.directLine); | ||
await driver.wait(allImagesLoaded(), 2000); | ||
|
||
const base64PNG = await driver.takeScreenshot(); | ||
|
||
expect(base64PNG).toMatchImageSnapshot(imageSnapshotOptions); | ||
}); | ||
|
||
test('sign-in card', async () => { | ||
const { driver, pageObjects } = await setupWebDriver({ useProductionBot: true }); | ||
|
||
await driver.wait(uiConnected(), timeouts.directLine); | ||
await pageObjects.sendMessageViaSendBox('signin', { waitForSend: true }); | ||
|
||
await driver.wait(minNumActivitiesShown(2), timeouts.directLine); | ||
await driver.wait(allImagesLoaded(), 2000); | ||
|
||
const base64PNG = await driver.takeScreenshot(); | ||
|
||
expect(base64PNG).toMatchImageSnapshot(imageSnapshotOptions); | ||
}); | ||
|
||
test('thumbnail card', async () => { | ||
const { driver, pageObjects } = await setupWebDriver(); | ||
|
||
await driver.wait(uiConnected(), timeouts.directLine); | ||
await pageObjects.sendMessageViaSendBox('thumbnailcard', { waitForSend: true }); | ||
|
||
await driver.wait(minNumActivitiesShown(2), timeouts.directLine); | ||
await driver.wait(allImagesLoaded(), 2000); | ||
|
||
const base64PNG = await driver.takeScreenshot(); | ||
|
||
expect(base64PNG).toMatchImageSnapshot(imageSnapshotOptions); | ||
}); |
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 |
---|---|---|
@@ -1,28 +1,11 @@ | ||
import { Condition } from 'selenium-webdriver'; | ||
|
||
import { timeouts } from '../../constants.json'; | ||
|
||
export default function scrollToBottomCompleted() { | ||
return new Condition('for UI to scroll to bottom', async driver => { | ||
const done = await driver.executeAsyncScript((timeoutInMS, callback) => { | ||
return new Condition('for UI to scroll to bottom', driver => | ||
driver.executeScript(() => { | ||
const scrollable = document.querySelector('[role="log"] > *'); | ||
|
||
// If we do not receive any "scroll" event at all, probably we are at the bottom. | ||
const defaultTimeout = setTimeout(() => callback(true), timeoutInMS); | ||
let timeout; | ||
const handleScroll = () => { | ||
clearTimeout(defaultTimeout); | ||
clearTimeout(timeout); | ||
|
||
timeout = setTimeout(() => { | ||
scrollable.removeEventListener('scroll', handleScroll); | ||
callback(true); | ||
}, 200); | ||
}; | ||
|
||
scrollable.addEventListener('scroll', handleScroll); | ||
}, timeouts.scrollToBottom); | ||
|
||
return done; | ||
}); | ||
return scrollable && scrollable.offsetHeight + scrollable.scrollTop === scrollable.scrollHeight; | ||
}) | ||
); | ||
} |
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 } from 'selenium-webdriver'; | ||
|
||
export default async function getScrollToBottomButton(driver) { | ||
return await driver.findElement(By.css('[role="log"] > button:last-child')); | ||
} |
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,22 @@ | ||
export default function marshal(props) { | ||
return ( | ||
props && | ||
Object.keys(props).reduce( | ||
(nextProps, key) => { | ||
const { [key]: value } = props; | ||
|
||
if (typeof value === 'function') { | ||
nextProps[key] = `() => ${value.toString()}`; | ||
nextProps.__evalKeys.push(key); | ||
} else { | ||
nextProps[key] = value; | ||
} | ||
|
||
return nextProps; | ||
}, | ||
{ | ||
__evalKeys: [] | ||
} | ||
) | ||
); | ||
} |
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 getScrollToBottomButton from '../elements/getScrollToBottomButton'; | ||
|
||
export default async function clickScrollToBottomButton(driver) { | ||
(await getScrollToBottomButton(driver)).click(); | ||
} |
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 marshal from '../marshal'; | ||
|
||
export default function updateProps(driver, mergeProps) { | ||
return driver.executeScript(mergeProps => { | ||
window.WebChatTest.updateProps(unmarshal(mergeProps)); | ||
}, marshal(mergeProps)); | ||
} |
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
Oops, something went wrong.