Skip to content

Commit

Permalink
fix: remove Cortana from Channels enum (#3730)
Browse files Browse the repository at this point in the history
* remove Cortana from Channels enum

* clean up linted choices_* tests
  • Loading branch information
stevengum authored and Josh Gummersall committed Jun 21, 2021
1 parent 8b192fd commit 02eeb9a
Show file tree
Hide file tree
Showing 5 changed files with 137 additions and 173 deletions.
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
99 changes: 38 additions & 61 deletions libraries/botbuilder-dialogs/tests/choices_channel.test.js
Original file line number Diff line number Diff line change
@@ -1,103 +1,80 @@
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() {
const validNumOfSuggestedActions = supportsSuggestedActions('line', 13);
assert(validNumOfSuggestedActions, `returned false.`);
it('should return true for supportsSuggestedActions() with line and 13', function () {
assert(supportsSuggestedActions(Channels.Line, 13));
});

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

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

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

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

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

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

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

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

it(`should return false for supportsCardActions() with line and 100`, function() {
const validNumOfCardActions = supportsCardActions('line', 100);
assert(validNumOfCardActions === false, `returned false.`);
it('should return false for supportsCardActions() with line and 100', function () {
assert.strictEqual(supportsCardActions(Channels.Line, 100), 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 () {
assert.strictEqual(supportsCardActions(Channels.Slack, 101), false);
});

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

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

it(`should return false for supportsCardActions() with skype and 5`, function() {
const validNumOfCardActions = supportsCardActions('skype', 5);
assert(validNumOfCardActions === false, `returned true.`);
it('should return the channelId from context.activity.', function () {
assert.strictEqual(getChannelId({ activity: { channelId: Channels.Facebook } }), Channels.Facebook);
});

it(`should return false for hasMessageFeed() with cortana`, function() {
const hasFeed = hasMessageFeed('cortana');
assert(hasFeed === false, `returned true.`);
it('should return true for any channel', function () {
assert(hasMessageFeed(Channels.Directline));
});

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 an empty string if context.activity.channelId is falsey.`, function() {
const channel = getChannelId({ activity: {} });
assert(channel === '', `expected "", instead received ${ channel }`);
it('should return an empty string if context.activity.channelId is falsey.', function () {
assert.strictEqual(getChannelId({ activity: {} }), '');
});

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

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

0 comments on commit 02eeb9a

Please sign in to comment.