Skip to content

Commit

Permalink
Added required text to card action type messageBack (#3003)
Browse files Browse the repository at this point in the history
* Added required text to card action type messageBack

* Added required text to card action type messageBack

* Add tests

* Add entry

* Clean up

Co-authored-by: Guy Ambar <[email protected]>
Co-authored-by: William Wong <[email protected]>
  • Loading branch information
3 people authored Apr 1, 2020
1 parent ef2629b commit 15d89bd
Show file tree
Hide file tree
Showing 10 changed files with 94 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Fixes [#3024](https://github.com/microsoft/BotFramework-WebChat/issues/3024). Using bridge package [`markdown-it-attrs-es5`](https://npmjs.com/package/markdown-it-attrs-es5) for consuming [`markdown-it-attrs`](https://npmjs.com/package/markdown-it-attrs) for IE11, by [@compulim](https://github.com/compulim) in PR [#3025](https://github.com/microsoft/BotFramework-WebChat/pull/3025)
- Fixes [#2818](https://github.com/microsoft/BotFramework-WebChat/issues/2818). Fix user ID is not set when passing to embed as query parameter, by [@p-nagpal](https://github.com/p-nagpal) in PR [#3031](https://github.com/microsoft/BotFramework-WebChat/pull/3031)
- Fixes [#3026](https://github.com/microsoft/BotFramework-WebChat/issues/3026). Fix link `rel` attribute in the `renderMarkdown` function, by [@tdurnford](https://github.com/tdurnford) in PR [#3033](https://github.com/microsoft/BotFramework-WebChat/pull/3033)
- Fixes [#2933](https://github.com/microsoft/BotFramework-WebChat/issues/2933). Fix `text` should not be ignored in `messageBack` action in hero card, by [@geea-develop](https://github.com/geea-develop) and [@compulim](https://github.com/compulim) in PR [#3003](https://github.com/microsoft/BotFramework-WebChat/pull/3003)

### Changed

Expand Down
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.
2 changes: 1 addition & 1 deletion __tests__/disabledUI.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { imageSnapshotOptions, timeouts } from './constants.json';
import uiConnected from './setup/conditions/uiConnected.js';
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
Expand Down
90 changes: 90 additions & 0 deletions __tests__/heroCardActions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
import { By, until } from 'selenium-webdriver';

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

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);
jest.setTimeout(15000);

describe('hero card actions', () => {
let driver;

async function clickHeroCardButton(nthChild) {
await driver.wait(
() =>
driver.executeScript(nthChild => {
const button = document.querySelector('.ac-actionSet button:nth-of-type(' + nthChild + ')');

button && button.click();

return button;
}, nthChild),
timeouts.ui
);
}

beforeEach(async () => {
const setup = await setupWebDriver({ useProductionBot: true });

driver = setup.driver;

await driver.wait(uiConnected(), timeouts.directLine);

await setup.pageObjects.sendMessageViaSendBox('herocardactions');
await driver.wait(minNumActivitiesShown(2), timeouts.directLine);
});

test('imBack', async () => {
await clickHeroCardButton(1);

await driver.wait(minNumActivitiesShown(4), timeouts.directLine);
await driver.wait(scrollToBottomCompleted(), timeouts.scrollToBottom);
expect(await driver.takeScreenshot()).toMatchImageSnapshot(imageSnapshotOptions);
});

test('postBack (string)', async () => {
await clickHeroCardButton(2);

await driver.wait(minNumActivitiesShown(3), timeouts.directLine);
await driver.wait(scrollToBottomCompleted(), timeouts.scrollToBottom);
expect(await driver.takeScreenshot()).toMatchImageSnapshot(imageSnapshotOptions);
});

test('postBack (JSON)', async () => {
await clickHeroCardButton(3);

await driver.wait(minNumActivitiesShown(3), timeouts.directLine);
await driver.wait(scrollToBottomCompleted(), timeouts.scrollToBottom);
expect(await driver.takeScreenshot()).toMatchImageSnapshot(imageSnapshotOptions);
});

test('messageBack (displayText + text + value)', async () => {
await clickHeroCardButton(4);

await driver.wait(minNumActivitiesShown(4), timeouts.directLine);
await driver.wait(scrollToBottomCompleted(), timeouts.scrollToBottom);
expect(await driver.takeScreenshot()).toMatchImageSnapshot(imageSnapshotOptions);
});

test('messageBack (displayText + text)', async () => {
await clickHeroCardButton(5);

await driver.wait(minNumActivitiesShown(4), timeouts.directLine);
await driver.wait(scrollToBottomCompleted(), timeouts.scrollToBottom);
expect(await driver.takeScreenshot()).toMatchImageSnapshot(imageSnapshotOptions);
});

test('messageBack (value)', async () => {
await clickHeroCardButton(6);

await driver.wait(minNumActivitiesShown(3), timeouts.directLine);
await driver.wait(scrollToBottomCompleted(), timeouts.scrollToBottom);
expect(await driver.takeScreenshot()).toMatchImageSnapshot(imageSnapshotOptions);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,9 @@ const AdaptiveCardRenderer = ({ adaptiveCard, tapAction }) => {

if (actionData && actionData.__isBotFrameworkCardAction) {
const { cardAction } = actionData;
const { displayText, type, value } = cardAction;
const { displayText, text, type, value } = cardAction;

performCardAction({ displayText, type, value });
performCardAction({ displayText, text, type, value });
} else {
performCardAction({
type: typeof action.data === 'string' ? 'imBack' : 'postBack',
Expand Down

0 comments on commit 15d89bd

Please sign in to comment.