Skip to content

Commit 2bb7475

Browse files
authored
port: [#4270] Choice options separator should be multi language (#6366) (#4293)
* Add ChoiceOptionsSet * Add unit tests for ChoiceOptionsSet * Update schema files * Fix test:compat
1 parent 57e2642 commit 2bb7475

15 files changed

+578
-9
lines changed

libraries/botbuilder-dialogs-adaptive-testing/tests/action.test.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,14 @@ describe('ActionTests', function () {
206206
await TestUtils.runTestScript(resourceExplorer, 'Action_ChoiceStringInMemory');
207207
});
208208

209+
it('ChoicesWithChoiceOptions', async function () {
210+
await TestUtils.runTestScript(resourceExplorer, 'Action_ChoicesWithChoiceOptions');
211+
});
212+
213+
it('ChoicesWithChoiceOptionsTemplate', async function () {
214+
await TestUtils.runTestScript(resourceExplorer, 'Action_ChoicesWithChoiceOptionsTemplate');
215+
});
216+
209217
it('ConfirmInput', async function () {
210218
await TestUtils.runTestScript(resourceExplorer, 'Action_ConfirmInput');
211219
});
@@ -234,6 +242,14 @@ describe('ActionTests', function () {
234242
await TestUtils.runTestScript(resourceExplorer, 'Action_ConfirmInput_ComplexTemplate_es');
235243
});
236244

245+
it('ConfirmInputWithChoiceOptions', async function () {
246+
await TestUtils.runTestScript(resourceExplorer, 'Action_ConfirmInputWithChoiceOptions');
247+
});
248+
249+
it('ConfirmInputWithChoiceOptionsTemplate', async function () {
250+
await TestUtils.runTestScript(resourceExplorer, 'Action_ConfirmInputWithChoiceOptionsTemplate');
251+
});
252+
237253
it('DeleteProperties', async function () {
238254
await TestUtils.runTestScript(resourceExplorer, 'Action_DeleteProperties');
239255
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
{
2+
"$schema": "../../../tests.schema",
3+
"$kind": "Microsoft.Test.Script",
4+
"dialog": {
5+
"$kind": "Microsoft.AdaptiveDialog",
6+
"id": "planningTest",
7+
"triggers": [
8+
{
9+
"$kind": "Microsoft.OnBeginDialog",
10+
"actions": [
11+
{
12+
"$kind": "Microsoft.ChoiceInput",
13+
"choices": [
14+
{
15+
"value": "red"
16+
},
17+
{
18+
"value": "green"
19+
},
20+
{
21+
"value": "blue"
22+
}
23+
],
24+
"style": "inline",
25+
"choiceOptions": {
26+
"inlineSeparator": ", ",
27+
"inlineOr": " or2 ",
28+
"inlineOrMore": ", or2 ",
29+
"includeNumbers": true
30+
},
31+
"property": "user.color",
32+
"prompt": "Please select a color:",
33+
"unrecognizedPrompt": "Not a color. Please select a color:"
34+
},
35+
{
36+
"$kind": "Microsoft.SendActivity",
37+
"activity": "${user.color}"
38+
},
39+
{
40+
"$kind": "Microsoft.ChoiceInput",
41+
"choices": [
42+
{
43+
"value": "red"
44+
},
45+
{
46+
"value": "green"
47+
},
48+
{
49+
"value": "blue"
50+
}
51+
],
52+
"style": "inline",
53+
"alwaysPrompt": true,
54+
"choiceOptions": {
55+
"inlineSeparator": ", ",
56+
"inlineOr": " or2 ",
57+
"inlineOrMore": ", or2 ",
58+
"includeNumbers": true
59+
},
60+
"property": "user.color",
61+
"prompt": "Please select a color:",
62+
"unrecognizedPrompt": "Please select a color:"
63+
},
64+
{
65+
"$kind": "Microsoft.SendActivity",
66+
"activity": "${user.color}"
67+
},
68+
{
69+
"$kind": "Microsoft.ChoiceInput",
70+
"choices": [
71+
{
72+
"value": "red"
73+
},
74+
{
75+
"value": "green"
76+
},
77+
{
78+
"value": "blue"
79+
}
80+
],
81+
"style": "inline",
82+
"alwaysPrompt": true,
83+
"choiceOptions": {
84+
"inlineSeparator": ", ",
85+
"inlineOr": " or2 ",
86+
"inlineOrMore": ", or2 ",
87+
"includeNumbers": true
88+
},
89+
"property": "user.color",
90+
"prompt": "Please select a color:",
91+
"unrecognizedPrompt": "Please select a color:"
92+
},
93+
{
94+
"$kind": "Microsoft.SendActivity",
95+
"activity": "${user.color}"
96+
}
97+
]
98+
}
99+
],
100+
"defaultResultProperty": "dialog.result"
101+
},
102+
"script": [
103+
{
104+
"$kind": "Microsoft.Test.UserSays",
105+
"text": "hi"
106+
},
107+
{
108+
"$kind": "Microsoft.Test.AssertReply",
109+
"text": "Please select a color: (1) red, (2) green, or2 (3) blue"
110+
},
111+
{
112+
"$kind": "Microsoft.Test.UserSays",
113+
"text": "asdasd"
114+
},
115+
{
116+
"$kind": "Microsoft.Test.AssertReply",
117+
"text": "Not a color. Please select a color: (1) red, (2) green, or2 (3) blue"
118+
},
119+
{
120+
"$kind": "Microsoft.Test.UserSays",
121+
"text": "blue"
122+
},
123+
{
124+
"$kind": "Microsoft.Test.AssertReply",
125+
"text": "blue"
126+
},
127+
{
128+
"$kind": "Microsoft.Test.AssertReply",
129+
"text": "Please select a color: (1) red, (2) green, or2 (3) blue"
130+
},
131+
{
132+
"$kind": "Microsoft.Test.UserSays",
133+
"text": "red"
134+
},
135+
{
136+
"$kind": "Microsoft.Test.AssertReply",
137+
"text": "red"
138+
}
139+
]
140+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
{
2+
"$schema": "../../../tests.schema",
3+
"$kind": "Microsoft.Test.Script",
4+
"dialog": {
5+
"$kind": "Microsoft.AdaptiveDialog",
6+
"id": "planningTest",
7+
"generator": "test.lg",
8+
"triggers": [
9+
{
10+
"$kind": "Microsoft.OnBeginDialog",
11+
"actions": [
12+
{
13+
"$kind": "Microsoft.ChoiceInput",
14+
"alwaysPrompt": true,
15+
"choices": "${MyChoices_simple()}",
16+
"choiceOptions": "${MyChoiceOptions()}",
17+
"style": "inline",
18+
"property": "user.choice",
19+
"prompt": "${MyChoices_Prompt()}",
20+
"unrecognizedPrompt": "${MyChoices_UnknownPrompt()}"
21+
},
22+
{
23+
"$kind": "Microsoft.SendActivity",
24+
"activity": "${user.choice}"
25+
}
26+
]
27+
}
28+
],
29+
"defaultResultProperty": "dialog.result"
30+
},
31+
"locale": "en",
32+
"script": [
33+
{
34+
"$kind": "Microsoft.Test.UserSays",
35+
"text": "hi"
36+
},
37+
{
38+
"$kind": "Microsoft.Test.AssertReply",
39+
"text": "Please select (1) dog or2 (2) cat"
40+
},
41+
{
42+
"$kind": "Microsoft.Test.UserSays",
43+
"text": "kitty"
44+
},
45+
{
46+
"$kind": "Microsoft.Test.AssertReply",
47+
"text": "Not a dog or cat. Please select (1) dog or2 (2) cat"
48+
},
49+
{
50+
"$kind": "Microsoft.Test.UserSays",
51+
"text": "cat"
52+
},
53+
{
54+
"$kind": "Microsoft.Test.AssertReply",
55+
"text": "cat"
56+
}
57+
]
58+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
{
2+
"$schema": "../../../tests.schema",
3+
"$kind": "Microsoft.Test.Script",
4+
"dialog": {
5+
"$kind": "Microsoft.AdaptiveDialog",
6+
"id": "planningTest",
7+
"generator": "test.lg",
8+
"triggers": [
9+
{
10+
"$kind": "Microsoft.OnBeginDialog",
11+
"actions": [
12+
{
13+
"$kind": "Microsoft.ConfirmInput",
14+
"style": "inline",
15+
"alwaysPrompt": true,
16+
"choiceOptions": {
17+
"inlineSeparator": ", ",
18+
"inlineOr": " or2 ",
19+
"inlineOrMore": ", or2 ",
20+
"includeNumbers": true
21+
},
22+
"property": "user.confirmed",
23+
"prompt": "${ConfirmInput_Prompt()}",
24+
"unrecognizedPrompt": "${ConfirmInput_UnknownPrompt()}",
25+
"confirmChoices": "${ConfirmInput_simple()}"
26+
},
27+
{
28+
"$kind": "Microsoft.SendActivity",
29+
"activity": "confirmation: ${user.confirmed}"
30+
}
31+
]
32+
}
33+
],
34+
"defaultResultProperty": "dialog.result"
35+
},
36+
"locale": "en",
37+
"script": [
38+
{
39+
"$kind": "Microsoft.Test.UserSays",
40+
"text": "hi"
41+
},
42+
{
43+
"$kind": "Microsoft.Test.AssertReply",
44+
"text": "Please select (1) yep or2 (2) nope"
45+
},
46+
{
47+
"$kind": "Microsoft.Test.UserSays",
48+
"text": "asdasd"
49+
},
50+
{
51+
"$kind": "Microsoft.Test.AssertReply",
52+
"text": "Not yep or nope. Please select (1) yep or2 (2) nope"
53+
},
54+
{
55+
"$kind": "Microsoft.Test.UserSays",
56+
"text": "yep"
57+
},
58+
{
59+
"$kind": "Microsoft.Test.AssertReply",
60+
"text": "confirmation: true"
61+
}
62+
]
63+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
{
2+
"$schema": "../../../tests.schema",
3+
"$kind": "Microsoft.Test.Script",
4+
"dialog": {
5+
"$kind": "Microsoft.AdaptiveDialog",
6+
"id": "planningTest",
7+
"generator": "test.lg",
8+
"triggers": [
9+
{
10+
"$kind": "Microsoft.OnBeginDialog",
11+
"actions": [
12+
{
13+
"$kind": "Microsoft.ConfirmInput",
14+
"style": "inline",
15+
"alwaysPrompt": true,
16+
"property": "user.confirmed",
17+
"choiceOptions": "${MyChoiceOptions()}",
18+
"prompt": "${ConfirmInput_Prompt()}",
19+
"unrecognizedPrompt": "${ConfirmInput_UnknownPrompt()}",
20+
"confirmChoices": "${ConfirmInput_simple()}"
21+
},
22+
{
23+
"$kind": "Microsoft.SendActivity",
24+
"activity": "confirmation: ${user.confirmed}"
25+
}
26+
]
27+
}
28+
],
29+
"defaultResultProperty": "dialog.result"
30+
},
31+
"locale": "en",
32+
"script": [
33+
{
34+
"$kind": "Microsoft.Test.UserSays",
35+
"text": "hi"
36+
},
37+
{
38+
"$kind": "Microsoft.Test.AssertReply",
39+
"text": "Please select (1) yep or2 (2) nope"
40+
},
41+
{
42+
"$kind": "Microsoft.Test.UserSays",
43+
"text": "asdasd"
44+
},
45+
{
46+
"$kind": "Microsoft.Test.AssertReply",
47+
"text": "Not yep or nope. Please select (1) yep or2 (2) nope"
48+
},
49+
{
50+
"$kind": "Microsoft.Test.UserSays",
51+
"text": "yep"
52+
},
53+
{
54+
"$kind": "Microsoft.Test.AssertReply",
55+
"text": "confirmation: true"
56+
}
57+
]
58+
}

libraries/botbuilder-dialogs-adaptive-testing/tests/resources/ActionTests/test.en.lg

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
]
1818
```
1919

20+
# MyChoiceOptions
21+
- [", "," or2 ",", or2 ",true]
22+
2023
> CONFIRM INPUT UNIT TEST
2124

2225
# ConfirmInput_Prompt

libraries/botbuilder-dialogs-adaptive/etc/botbuilder-dialogs-adaptive.api.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -526,6 +526,20 @@ export interface ChoiceInputOptions {
526526
choices: Choice[];
527527
}
528528

529+
// @public
530+
export class ChoiceOptionsSet implements ChoiceFactoryOptions, TemplateInterface<ChoiceFactoryOptions> {
531+
constructor(obj: any);
532+
bind(dialogContext: DialogContext, data?: any): Promise<ChoiceFactoryOptions>;
533+
// (undocumented)
534+
includeNumbers?: boolean;
535+
// (undocumented)
536+
inlineOr?: string;
537+
// (undocumented)
538+
inlineOrMore?: string;
539+
// (undocumented)
540+
inlineSeparator?: string;
541+
}
542+
529543
// @public (undocumented)
530544
export enum ChoiceOutputFormat {
531545
// (undocumented)

libraries/botbuilder-dialogs-adaptive/schemas/Dialogs/Microsoft.ChoiceInput.schema

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@
170170
}
171171
},
172172
{
173-
"$ref": "schema:#/definitions/equalsExpression"
173+
"$ref": "schema:#/definitions/stringExpression"
174174
}
175175
]
176176
},

0 commit comments

Comments
 (0)