Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hide suggested actions not destinated to the user #1706

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- `bundle`: Fix [#1652](https://github.com/Microsoft/BotFramework-WebChat/issues/1652). Pass `pollingInterval` to DirectLineJS constructor, by [@neetu-das](https://github.com/neetu-das) in PR [#1655](https://github.com/Microsoft/BotFramework-WebChat/pull/1655)
- `core`: Reworked logic on connect/disconnect for reliability on handling corner cases, by [@compulim](https://github.com/compulim) in PR [#1649](https://github.com/Microsoft/BotFramework-WebChat/pull/1649)
- `core`: Fix [#1521](https://github.com/Microsoft/BotFramework-WebChat/issues/1521). Add connectivity status component and update localization, by [@corinagum](https://github.com/corinagum) in PR [#1679](https://github.com/Microsoft/BotFramework-WebChat/pull/1679)
- Fix [#1057](https://github.com/Microsoft/BotFramework-WebChat/issues/1057). Fixed suggested actions destinated for other recipients should not show up, by [@compulim](https://github.com/compulim) in PR [#1706](https://github.com/Microsoft/BotFramework-WebChat/pull/1706)
compulim marked this conversation as resolved.
Show resolved Hide resolved
compulim marked this conversation as resolved.
Show resolved Hide resolved

### Removed
- `botAvatarImage` and `userAvatarImage` props, as they are moved inside `styleOptions`, in PR [#1486](https://github.com/Microsoft/BotFramework-WebChat/pull/1486)
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 18 additions & 0 deletions __tests__/suggestedActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,4 +148,22 @@ describe('suggested-actions command', async () => {

expect(base64PNG).toMatchImageSnapshot(imageSnapshotOptions);
}, 60000);

test('should not show suggested actions not destinated for the user', async () => {
compulim marked this conversation as resolved.
Show resolved Hide resolved
compulim marked this conversation as resolved.
Show resolved Hide resolved
const { driver, pageObjects } = await setupWebDriver();

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

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

await input.sendKeys('suggested-actions others', Key.RETURN);
await driver.wait(allOutgoingActivitiesSent(), timeouts.directLine);

await driver.wait(minNumActivitiesShown(3), timeouts.directLine);
await pageObjects.hideCursor();

const base64PNG = await driver.takeScreenshot();

expect(base64PNG).toMatchImageSnapshot(imageSnapshotOptions);
}, 60000);
});
9 changes: 7 additions & 2 deletions packages/core/src/sagas/incomingActivitySaga.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,18 @@ function* observeActivity({ directLine, userID }) {
yield put(incomingActivity(activity));

// Update suggested actions
// TODO: [P3] We could put this logic inside reducer to minimize number of actions dispatched
const messageActivities = yield select(activitiesOfType('message'));
const lastMessageActivity = messageActivities[messageActivities.length - 1];

if (activityFromBot(lastMessageActivity)) {
const { suggestedActions: { actions } = {} } = lastMessageActivity;
const { suggestedActions: { actions, to } = {} } = lastMessageActivity;

yield put(setSuggestedActions(actions));
if (!to || !to.length || to.includes(userID)) {
compulim marked this conversation as resolved.
Show resolved Hide resolved
yield put(setSuggestedActions(actions));
} else {
yield put(setSuggestedActions());
}
}
});
}
Expand Down