-
Notifications
You must be signed in to change notification settings - Fork 281
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* bug fix: log multi-choice options in App Insights * unit test
- Loading branch information
1 parent
d079cc7
commit a700088
Showing
4 changed files
with
99 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
libraries/botbuilder-dialogs-adaptive/tests/choiceInputDialog.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
const { ok, strictEqual } = require('assert'); | ||
const { createTelemetryClientAndStub } = require('./telemetryUtils'); | ||
const { ConversationState, MemoryStorage, TestAdapter } = require('botbuilder'); | ||
const { DialogManager, DialogSet, ChoicePrompt, ListStyle } = require('botbuilder-dialogs'); | ||
const { ChoiceInput, TelemetryLoggerConstants, ActivityTemplate, ChoiceSet } = require('../lib'); | ||
const { ObjectExpression, BoolExpression } = require('adaptive-expressions'); | ||
|
||
describe('ChoiceInput multi-choices properties', function () { | ||
this.timeout(3000); | ||
let telemetryName; | ||
let telemetryProperties; | ||
const captureTelemetryAction = (eventData) => { | ||
telemetryName = eventData.name; | ||
telemetryProperties = eventData.properties; | ||
}; | ||
// Create telemetryClient and trackEventStub | ||
const [telemetryClient, trackEventStub] = createTelemetryClientAndStub(captureTelemetryAction); | ||
|
||
// Setup dialog manager | ||
const storage = new MemoryStorage(); | ||
const conversationState = new ConversationState(storage); | ||
const dialogState = conversationState.createProperty('dialog'); | ||
const dialogs = new DialogSet(dialogState); | ||
const choicePrompt = new ChoicePrompt('prompt'); | ||
choicePrompt.style = ListStyle.none; | ||
dialogs.add(choicePrompt); | ||
const dm = new DialogManager(); | ||
dm.conversationState = conversationState; | ||
|
||
// Setup inputDialog dialog | ||
const dialog = new ChoiceInput(); | ||
dialog.prompt = new ActivityTemplate('testTemplate'); | ||
dialog.alwaysPrompt = true; | ||
|
||
// set up prompt choices | ||
const choiceSet = new ChoiceSet([{ value: 'test1' }, { value: 'test2' }, { value: 'test3' }]); | ||
dialog.choices = new ObjectExpression(choiceSet); | ||
dialog.alwaysPrompt = new BoolExpression(true); | ||
dialog._telemetryClient = telemetryClient; | ||
dm.rootDialog = dialog; | ||
|
||
it('Log ChoiceInput choices properties', async function () { | ||
// Send initial activity | ||
const adapter = new TestAdapter(async (turnContext) => { | ||
await dm.onTurn(turnContext); | ||
|
||
// assert telemetry result | ||
strictEqual(telemetryName, TelemetryLoggerConstants.GeneratorResultEvent); | ||
strictEqual(telemetryProperties.choices, choiceSet); | ||
ok(trackEventStub.calledOnce); | ||
}); | ||
await adapter.send('test').sendConversationUpdate().startTest(); | ||
}); | ||
}); |