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

fix: remove Cortana from Channels enum #3730

Merged
merged 2 commits into from
Jun 8, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
18 changes: 9 additions & 9 deletions libraries/botbuilder-dialogs/src/choices/channel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ export function supportsCardActions(channelId: string, buttonCnt = 100): boolean
case Channels.Directline:
case Channels.DirectlineSpeech:
case Channels.Webchat:
case Channels.Cortana:
return buttonCnt <= 100;
default:
return false;
Expand All @@ -60,15 +59,16 @@ export function supportsCardActions(channelId: string, buttonCnt = 100): boolean

/**
* @private
* @param channelId id of a channel
* @param _channelId id of a channel
*/
export function hasMessageFeed(channelId: string): boolean {
switch (channelId) {
case Channels.Cortana:
return false;
default:
return true;
}
export function hasMessageFeed(_channelId: string): boolean {
// The removed 'cortana' channel was the only channel that returned false.
// This channel is no longer available for bot developers and was removed from
// the Channels enum while addressing issue #3603.
// Though it's marked as private in the docstring, the contents of channel.ts
// are publically available but not documented in the official reference docs.
// Thus, the method is retained.
return true;
}

/**
Expand Down
1 change: 0 additions & 1 deletion libraries/botbuilder-dialogs/src/prompts/oauthPrompt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,6 @@ export class OAuthPrompt extends Dialog {
*/
private static channelSupportsOAuthCard(channelId: string): boolean {
switch (channelId) {
case Channels.Cortana:
case Channels.Skype:
case Channels.Skypeforbusiness:
return false;
Expand Down
84 changes: 39 additions & 45 deletions libraries/botbuilder-dialogs/tests/choices_channel.test.js
Original file line number Diff line number Diff line change
@@ -1,103 +1,97 @@
const assert = require('assert');
const { Channels } = require('botbuilder-core');
const { supportsSuggestedActions, supportsCardActions, hasMessageFeed, getChannelId } = require('../lib');
const { getChannelId, hasMessageFeed, supportsSuggestedActions, supportsCardActions } = require('../');

describe('channel methods', function() {
describe('channel methods', function () {
this.timeout(5000);

it(`should return true for supportsSuggestedActions() with line and 13`, function() {
it('should return true for supportsSuggestedActions() with line and 13', function () {
const validNumOfSuggestedActions = supportsSuggestedActions('line', 13);
assert(validNumOfSuggestedActions, `returned false.`);
assert(validNumOfSuggestedActions, 'returned false.');
});

it(`should return false for supportsSuggestedActions() with line and 14`, function() {
it('should return false for supportsSuggestedActions() with line and 14', function () {
const validNumOfSuggestedActions = supportsSuggestedActions('line', 14);
assert(validNumOfSuggestedActions === false, `returned true.`);
assert(validNumOfSuggestedActions === false, 'returned true.');
stevengum marked this conversation as resolved.
Show resolved Hide resolved
});

it(`should return true for supportsSuggestedActions() with skype and 10`, function() {
it('should return true for supportsSuggestedActions() with skype and 10', function () {
const validNumOfSuggestedActions = supportsSuggestedActions('skype', 10);
assert(validNumOfSuggestedActions, `returned false.`);
assert(validNumOfSuggestedActions, 'returned false.');
});

it(`should return false for supportsSuggestedActions() with skype and 11`, function() {
it('should return false for supportsSuggestedActions() with skype and 11', function () {
const validNumOfSuggestedActions = supportsSuggestedActions('skype', 11);
assert(validNumOfSuggestedActions === false, `returned true.`);
assert(validNumOfSuggestedActions === false, 'returned true.');
});

it(`should return true for supportsSuggestedActions() with kik and 20`, function() {
it('should return true for supportsSuggestedActions() with kik and 20', function () {
const validNumOfSuggestedActions = supportsSuggestedActions('kik', 20);
assert(validNumOfSuggestedActions, `returned false.`);
assert(validNumOfSuggestedActions, 'returned false.');
});

it(`should return false for supportsSuggestedActions() with kik and 21`, function() {
it('should return false for supportsSuggestedActions() with kik and 21', function () {
const validNumOfSuggestedActions = supportsSuggestedActions('kik', 21);
assert(validNumOfSuggestedActions === false, `returned true.`);
assert(validNumOfSuggestedActions === false, 'returned true.');
});

it(`should return true for supportsSuggestedActions() with emulator and 100`, function() {
it('should return true for supportsSuggestedActions() with emulator and 100', function () {
const validNumOfSuggestedActions = supportsSuggestedActions('emulator', 100);
assert(validNumOfSuggestedActions, `returned false.`);
assert(validNumOfSuggestedActions, 'returned false.');
});

it(`should return false for supportsSuggestedActions() with emulator and 101`, function() {
it('should return false for supportsSuggestedActions() with emulator and 101', function () {
const validNumOfSuggestedActions = supportsSuggestedActions('emulator', 101);
assert(validNumOfSuggestedActions === false, `returned true.`);
assert(validNumOfSuggestedActions === false, 'returned true.');
});

it(`should return true for supportsCardActions() with line and 99`, function() {
it('should return true for supportsCardActions() with line and 99', function () {
const validNumOfCardActions = supportsCardActions('line', 99);
assert(validNumOfCardActions, `returned false.`);
assert(validNumOfCardActions, 'returned false.');
});

it(`should return false for supportsCardActions() with line and 100`, function() {
it('should return false for supportsCardActions() with line and 100', function () {
const validNumOfCardActions = supportsCardActions('line', 100);
assert(validNumOfCardActions === false, `returned false.`);
assert(validNumOfCardActions === false, 'returned false.');
});

it(`should return true for supportsCardActions() with cortana and 100`, function() {
const validNumOfCardActions = supportsCardActions('cortana', 100);
assert(validNumOfCardActions, `returned false.`);
});

it(`should return false for supportsCardActions() with slack and 101`, function() {
it('should return false for supportsCardActions() with slack and 101', function () {
const validNumOfCardActions = supportsCardActions('slack', 101);
assert(validNumOfCardActions === false, `returned true.`);
assert(validNumOfCardActions === false, 'returned true.');
});

it(`should return true for supportsCardActions() with skype and 3`, function() {
it('should return true for supportsCardActions() with skype and 3', function () {
const validNumOfCardActions = supportsCardActions('skype', 3);
assert(validNumOfCardActions, `returned false.`);
assert(validNumOfCardActions, 'returned false.');
});

it(`should return false for supportsCardActions() with skype and 5`, function() {
it('should return false for supportsCardActions() with skype and 5', function () {
const validNumOfCardActions = supportsCardActions('skype', 5);
assert(validNumOfCardActions === false, `returned true.`);
assert(validNumOfCardActions === false, 'returned true.');
});

it(`should return false for hasMessageFeed() with cortana`, function() {
const hasFeed = hasMessageFeed('cortana');
assert(hasFeed === false, `returned true.`);
it('should return the channelId from context.activity.', function () {
const channel = getChannelId({ activity: { channelId: 'facebook' } });
assert(channel === 'facebook', 'expected "facebook", instead received ${channel}');
});

it(`should return the channelId from context.activity.`, function() {
const channel = getChannelId({ activity: { channelId: 'facebook' } });
assert(channel === 'facebook', `expected "facebook", instead received ${ channel }`);
it('should return true for any channel', function () {
assert(hasMessageFeed('directline'));
});

it(`should return an empty string if context.activity.channelId is falsey.`, function() {
it('should return an empty string if context.activity.channelId is falsey.', function () {
const channel = getChannelId({ activity: {} });
assert(channel === '', `expected "", instead received ${ channel }`);
assert(channel === '', 'expected "", instead received ${channel}');
});

// "directlinespeech" tests
it(`should return true for supportsSuggestedActions() with directlinespeech and 100`, function() {
it('should return true for supportsSuggestedActions() with directlinespeech and 100', function () {
const validNumOfSuggestedActions = supportsSuggestedActions(Channels.DirectlineSpeech, 100);
assert(validNumOfSuggestedActions, `returned false.`);
assert(validNumOfSuggestedActions, 'returned false.');
});

it(`should return true for supportsCardActions() with directlinespeech and 100`, () => {
it('should return true for supportsCardActions() with directlinespeech and 100', function () {
const validNumOfCardActions = supportsCardActions(Channels.DirectlineSpeech, 100);
assert(validNumOfCardActions, `returned false.`);
assert(validNumOfCardActions, 'returned false.');
});
});
Loading