Skip to content

Commit

Permalink
added test case for CancelAllDialogs (#2049)
Browse files Browse the repository at this point in the history
  • Loading branch information
chon219 authored Apr 22, 2020
1 parent 13b240a commit d32dd1d
Show file tree
Hide file tree
Showing 3 changed files with 105 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
{
"$schema": "../../../../schemas/sdk.schema",
"$kind": "Microsoft.Test.Script",
"dialog": {
"$schema": "../../app.schema",
"$kind": "Microsoft.AdaptiveDialog",
"recognizer": {
"$kind": "Microsoft.RegexRecognizer",
"intents": [
{
"intent": "CancelIntent",
"pattern": "(?i)cancel|never mind"
}
]
},
"triggers": [
{
"$kind": "Microsoft.OnBeginDialog",
"actions": [
{
"$schema": "../../app.schema",
"$kind": "Microsoft.AdaptiveDialog",
"recognizer": {
"$kind": "Microsoft.RegexRecognizer",
"intents": [
{
"intent": "CancelIntent",
"pattern": "(?i)cancel|never mind"
}
]
},
"triggers": [
{
"$kind": "Microsoft.OnBeginDialog",
"actions": [
{
"$kind": "Microsoft.SendActivity",
"activity": "Why did the chicken cross the road?"
},
{
"$kind": "Microsoft.EndTurn"
},
{
"$kind": "Microsoft.SendActivity",
"activity": "To get to the other side"
}
]
},
{
"$kind": "Microsoft.OnIntent",
"intent": "CancelIntent",
"actions": [
{
"$kind": "Microsoft.SendActivity",
"activity": "Canceled"
},
{
"$kind": "Microsoft.CancelAllDialogs"
}
]
}
]
},
{
"$kind": "Microsoft.SendActivity",
"activity": "What am I doing here?"
}
]
}
]
},
"script": [
{
"$kind": "Microsoft.Test.UserSays",
"text": "hi"
},
{
"$kind": "Microsoft.Test.AssertReply",
"text": "Why did the chicken cross the road?"
},
{
"$kind": "Microsoft.Test.UserSays",
"text": "cancel"
},
{
"$kind": "Microsoft.Test.AssertReply",
"text": "Canceled"
},
{
"$kind": "Microsoft.Test.UserSays",
"text": "hi"
},
{
"$kind": "Microsoft.Test.AssertReply",
"text": "Why did the chicken cross the road?"
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ describe('ActionTests', function() {
await testRunner.runTestScript('Action_BeginDialogWithActivity');
});

it('CancelAllDialogs', async () => {
await testRunner.runTestScript('Action_CancelAllDialogs');
});

it('ChoiceInput', async () => {
await testRunner.runTestScript('Action_ChoiceInput');
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ export class CancelAllDialogs<O extends object = {}> extends Dialog<O> {
}

if (!dc.parent) {
return await dc.cancelAllDialogs(true, this.eventName.getValue(dc.state), this.eventValue.getValue(dc.state));
return await dc.cancelAllDialogs(true, this.eventName && this.eventName.getValue(dc.state), this.eventValue && this.eventValue.getValue(dc.state));
} else {
const turnResult = await dc.cancelAllDialogs(true, this.eventName.getValue(dc.state), this.eventValue.getValue(dc.state));
const turnResult = await dc.cancelAllDialogs(true, this.eventName && this.eventName.getValue(dc.state), this.eventValue && this.eventValue.getValue(dc.state));
turnResult.parentEnded = true;
return turnResult;
}
}

protected onComputeId(): string {
return `CancelAllDialogs[${ this.eventName.toString() || '' }]`;
return `CancelAllDialogs[${ this.eventName ? this.eventName.toString() : '' }]`;
}
}

0 comments on commit d32dd1d

Please sign in to comment.