From 14da002576278a79acd36b7b1fffed3c8b7cc22b Mon Sep 17 00:00:00 2001 From: Kyle Delaney Date: Tue, 29 Jan 2019 11:48:41 -0800 Subject: [PATCH 1/2] Prevent Cortana from trying to use suggested actions in prompts --- libraries/botbuilder-dialogs/src/choices/choiceFactory.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/libraries/botbuilder-dialogs/src/choices/choiceFactory.ts b/libraries/botbuilder-dialogs/src/choices/choiceFactory.ts index d2b8d35972..6600e3a29c 100644 --- a/libraries/botbuilder-dialogs/src/choices/choiceFactory.ts +++ b/libraries/botbuilder-dialogs/src/choices/choiceFactory.ts @@ -107,11 +107,9 @@ export class ChoiceFactory { // Determine list style const supportsSuggestedActions: boolean = channel.supportsSuggestedActions(channelId, choices.length); - const supportsCardActions: boolean = channel.supportsCardActions(channelId, choices.length); const maxActionTitleLength: number = channel.maxActionTitleLength(channelId); - const hasMessageFeed: boolean = channel.hasMessageFeed(channelId); const longTitles: boolean = maxTitleLength > maxActionTitleLength; - if (!longTitles && (supportsSuggestedActions || (!hasMessageFeed && supportsCardActions))) { + if (!longTitles && supportsSuggestedActions) { // We always prefer showing choices using suggested actions. If the titles are too long, however, // we'll have to show them as a text list. return ChoiceFactory.suggestedAction(list, text, speak); From 7c29740599f6ed64eefd6dea0c9c14d8b094fee1 Mon Sep 17 00:00:00 2001 From: Kyle Delaney Date: Tue, 29 Jan 2019 16:16:17 -0800 Subject: [PATCH 2/2] Include Cortana test --- .../tests/choices_choiceFactory.test.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/libraries/botbuilder-dialogs/tests/choices_choiceFactory.test.js b/libraries/botbuilder-dialogs/tests/choices_choiceFactory.test.js index 547e92f84c..578a3cf6e5 100644 --- a/libraries/botbuilder-dialogs/tests/choices_choiceFactory.test.js +++ b/libraries/botbuilder-dialogs/tests/choices_choiceFactory.test.js @@ -21,6 +21,7 @@ function assertActivity(received, expected) { } const colorChoices = ['red', 'green', 'blue']; +const extraChoices = ['red', 'green', 'blue', 'alpha']; const choicesWithActionTitle = [ { @@ -167,6 +168,18 @@ describe('ChoiceFactory', function() { done(); }); + it('should choose correct styles for Cortana.', done => { + const inlineActivity = ChoiceFactory.forChannel('cortana', colorChoices, 'select from:'); + assertActivity(inlineActivity, { + text: `select from: (1) red, (2) green, or (3) blue` + }); + const listActivity = ChoiceFactory.forChannel('cortana', extraChoices, 'select from:'); + assertActivity(listActivity, { + text: `select from:\n\n 1. red\n 2. green\n 3. blue\n 4. alpha` + }); + done(); + }); + it('should use action.title to populate action.value if action.value is falsey.', done => { const preparedChoices = ChoiceFactory.toChoices(choicesWithActionTitle); assertChoices(preparedChoices, ['Red Color', 'Green Color', 'Blue Color']);