Skip to content

Commit f799b81

Browse files
chon219Stevenic
authored andcommitted
Ported declarative test script from C# (#1483)
* added the rest of conditions * fixed todo sample to use OnBeginDialog * removed unused samples * removed addRule method * merge adaptiveDialog's actions into dialogs * implemented new declarative test framework in adaptive dialogs * ported declarative tests from dotnet version * bug fix * refactored DialogStateManager to implement MemoryInterface * fixed test cases for DialogStateManager * fixed samples to use refactored DialogStateManager * getMemorySnapshot is no longer required while evaluating expressions * minor changes * removed dependency to adaptive dialogs in declarative library * moved declarative tests to new directory * replaced resource provider with resource explorer in test runner * Revert "refactored DialogStateManager to implement MemoryInterface" This reverts commit 21c5e06. * Revert "fixed test cases for DialogStateManager" This reverts commit ba9172a. * Revert "fixed samples to use refactored DialogStateManager" This reverts commit f28fcde. * let DialogStateManager implement MemoryInterface * allow testRunner to exit after running tests * Ported declarative tests for actions * cached parsed expressions * cached parsed expression for rest of components * cached parsed expression in ConfirmInput * added comment header for conditions * added comment headers for testing components * removed dependency to botframework-expressions in botbuilder-dialogs * use cammelCase for enum values * removed unneeded SequenceContext check * fixed typo * moved botbuilder-dialogs-adaptive-tests out of adaptive library folder * added turnPath constants and implemented error handler * refactored actions to align with dotnet sdk * minor changes * cut off dependency to declarative library in adaptive dialog library * added tests for test script * added missing actions * added tests for actionScope
1 parent 431dcc6 commit f799b81

File tree

184 files changed

+9343
-1855
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

184 files changed

+9343
-1855
lines changed

lerna.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"libraries/botbuilder-core",
1010
"libraries/botbuilder-dialogs",
1111
"libraries/botbuilder-dialogs-adaptive",
12+
"libraries/botbuilder-dialogs-adaptive-tests",
1213
"libraries/botbuilder-dialogs-declarative",
1314
"libraries/botbuilder-testing",
1415
"libraries/botbuilder-lg",
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/**/node_modules
2+
/**/.vscode
3+
/**/lib/*
4+
coverage
5+
.nyc_output
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"name": "botbuilder-dialogs-adaptive-tests",
3+
"version": "1.0.0",
4+
"description": "",
5+
"scripts": {
6+
"test": "tsc && nyc mocha lib/*.test.js"
7+
},
8+
"dependencies": {
9+
"botbuilder-core": "4.1.6",
10+
"botbuilder-dialogs": "4.1.6",
11+
"botbuilder-dialogs-adaptive": "4.1.6",
12+
"botbuilder-dialogs-declarative": "4.1.6",
13+
"botframework-expressions": "~4.1.6"
14+
},
15+
"devDependencies": {
16+
"@types/mocha": "^2.2.47",
17+
"mocha": "^5.2.0"
18+
},
19+
"author": "Microsoft",
20+
"license": "MIT"
21+
}
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
{
2+
"$schema": "../../../../schemas/sdk.schema",
3+
"$kind": "Microsoft.Test.Script",
4+
"dialog": {
5+
"$kind": "Microsoft.AdaptiveDialog",
6+
"id": "root",
7+
"triggers": [
8+
{
9+
"$kind": "Microsoft.OnBeginDialog",
10+
"actions": [
11+
{
12+
"$kind": "Microsoft.InitProperty",
13+
"property": "dialog.todo",
14+
"type": "array"
15+
},
16+
{
17+
"$kind": "Microsoft.EditArray",
18+
"itemsProperty": "dialog.todo",
19+
"changeType": "push",
20+
"value": "1"
21+
},
22+
{
23+
"$kind": "Microsoft.EditArray",
24+
"itemsProperty": "dialog.todo",
25+
"changeType": "push",
26+
"value": "2"
27+
},
28+
{
29+
"$kind": "Microsoft.EditArray",
30+
"itemsProperty": "dialog.todo",
31+
"changeType": "push",
32+
"value": "3"
33+
},
34+
{
35+
"$kind": "Microsoft.EditArray",
36+
"itemsProperty": "dialog.todo",
37+
"changeType": "push",
38+
"value": "4"
39+
},
40+
{
41+
"$kind": "Microsoft.EditArray",
42+
"itemsProperty": "dialog.todo",
43+
"changeType": "push",
44+
"value": "5"
45+
},
46+
{
47+
"$kind": "Microsoft.EditArray",
48+
"itemsProperty": "dialog.todo",
49+
"changeType": "push",
50+
"value": "6"
51+
},
52+
{
53+
"$kind": "Microsoft.Foreach",
54+
"itemsProperty": "dialog.todo",
55+
"actions": [
56+
{
57+
"$kind": "Microsoft.IfCondition",
58+
"condition": "dialog.foreach.index > 2",
59+
"actions": [
60+
{
61+
"$kind": "Microsoft.BreakLoop"
62+
}
63+
]
64+
},
65+
{
66+
"$kind": "Microsoft.SendActivity",
67+
"activity": "index is: @{dialog.foreach.index} and value is: @{dialog.foreach.value}"
68+
}
69+
]
70+
},
71+
{
72+
"$kind": "Microsoft.SendActivity",
73+
"activity": "done"
74+
}
75+
]
76+
}
77+
],
78+
"autoEndDialog": true,
79+
"defaultResultProperty": "dialog.result"
80+
},
81+
"script": [
82+
{
83+
"$kind": "Microsoft.Test.UserSays",
84+
"text": "hi"
85+
},
86+
{
87+
"$kind": "Microsoft.Test.AssertReply",
88+
"text": "index is: 0 and value is: 1"
89+
},
90+
{
91+
"$kind": "Microsoft.Test.AssertReply",
92+
"text": "index is: 1 and value is: 2"
93+
},
94+
{
95+
"$kind": "Microsoft.Test.AssertReply",
96+
"text": "index is: 2 and value is: 3"
97+
},
98+
{
99+
"$kind": "Microsoft.Test.AssertReply",
100+
"text": "done"
101+
}
102+
]
103+
}
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
{
2+
"$schema": "../../../../schemas/sdk.schema",
3+
"$kind": "Microsoft.Test.Script",
4+
"dialog": {
5+
"$kind": "Microsoft.AdaptiveDialog",
6+
"id": "root",
7+
"triggers": [
8+
{
9+
"$kind": "Microsoft.OnBeginDialog",
10+
"actions": [
11+
{
12+
"$kind": "Microsoft.InitProperty",
13+
"property": "dialog.todo",
14+
"type": "array"
15+
},
16+
{
17+
"$kind": "Microsoft.EditArray",
18+
"itemsProperty": "dialog.todo",
19+
"changeType": "push",
20+
"value": "1"
21+
},
22+
{
23+
"$kind": "Microsoft.EditArray",
24+
"itemsProperty": "dialog.todo",
25+
"changeType": "push",
26+
"value": "2"
27+
},
28+
{
29+
"$kind": "Microsoft.EditArray",
30+
"itemsProperty": "dialog.todo",
31+
"changeType": "push",
32+
"value": "3"
33+
},
34+
{
35+
"$kind": "Microsoft.EditArray",
36+
"itemsProperty": "dialog.todo",
37+
"changeType": "push",
38+
"value": "4"
39+
},
40+
{
41+
"$kind": "Microsoft.EditArray",
42+
"itemsProperty": "dialog.todo",
43+
"changeType": "push",
44+
"value": "5"
45+
},
46+
{
47+
"$kind": "Microsoft.EditArray",
48+
"itemsProperty": "dialog.todo",
49+
"changeType": "push",
50+
"value": "6"
51+
},
52+
{
53+
"$kind": "Microsoft.Foreach",
54+
"itemsProperty": "dialog.todo",
55+
"actions": [
56+
{
57+
"$kind": "Microsoft.IfCondition",
58+
"condition": "(dialog.foreach.value % 2) == 1",
59+
"actions": [
60+
{
61+
"$kind": "Microsoft.ContinueLoop"
62+
}
63+
]
64+
},
65+
{
66+
"$kind": "Microsoft.SendActivity",
67+
"activity": "index is: @{dialog.foreach.index} and value is: @{dialog.foreach.value}"
68+
}
69+
]
70+
},
71+
{
72+
"$kind": "Microsoft.SendActivity",
73+
"activity": "done"
74+
}
75+
]
76+
}
77+
],
78+
"autoEndDialog": true,
79+
"defaultResultProperty": "dialog.result"
80+
},
81+
"script": [
82+
{
83+
"$kind": "Microsoft.Test.UserSays",
84+
"text": "hi"
85+
},
86+
{
87+
"$kind": "Microsoft.Test.AssertReply",
88+
"text": "index is: 1 and value is: 2"
89+
},
90+
{
91+
"$kind": "Microsoft.Test.AssertReply",
92+
"text": "index is: 3 and value is: 4"
93+
},
94+
{
95+
"$kind": "Microsoft.Test.AssertReply",
96+
"text": "index is: 5 and value is: 6"
97+
},
98+
{
99+
"$kind": "Microsoft.Test.AssertReply",
100+
"text": "done"
101+
}
102+
]
103+
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
{
2+
"$schema": "../../../../schemas/sdk.schema",
3+
"$kind": "Microsoft.Test.Script",
4+
"dialog": {
5+
"$kind": "Microsoft.AdaptiveDialog",
6+
"triggers": [
7+
{
8+
"$kind": "Microsoft.OnBeginDialog",
9+
"actions": [
10+
{
11+
"$kind": "Microsoft.SetProperty",
12+
"property": "$counter",
13+
"value": "0"
14+
},
15+
{
16+
"id": "target",
17+
"$kind": "Microsoft.IfCondition",
18+
"condition": "$counter > 2",
19+
"actions": [
20+
{
21+
"$type": "Microsoft.EndDialog"
22+
}
23+
]
24+
},
25+
{
26+
"$kind": "Microsoft.SendActivity",
27+
"activity": "@{$counter}"
28+
},
29+
{
30+
"$kind": "Microsoft.SetProperty",
31+
"property": "$counter",
32+
"value": "$counter + 1"
33+
},
34+
{
35+
"$kind": "Microsoft.GotoAction",
36+
"actionId": "target"
37+
}
38+
]
39+
}
40+
]
41+
},
42+
"script": [
43+
{
44+
"$kind": "Microsoft.Test.UserConversationUpdate"
45+
},
46+
{
47+
"$kind": "Microsoft.Test.AssertReply",
48+
"text": "0"
49+
},
50+
{
51+
"$kind": "Microsoft.Test.AssertReply",
52+
"text": "1"
53+
},
54+
{
55+
"$kind": "Microsoft.Test.AssertReply",
56+
"text": "2"
57+
}
58+
]
59+
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
{
2+
"$schema": "../../../../schemas/sdk.schema",
3+
"$kind": "Microsoft.Test.Script",
4+
"dialog": {
5+
"$kind": "Microsoft.AdaptiveDialog",
6+
"triggers": [
7+
{
8+
"$kind": "Microsoft.OnBeginDialog",
9+
"actions": [
10+
{
11+
"$kind": "Microsoft.SetProperty",
12+
"property": "user.counter",
13+
"value": "10"
14+
},
15+
{
16+
"$kind": "Microsoft.IfCondition",
17+
"condition": "user.counter > 0",
18+
"actions": [
19+
{
20+
"$type": "Microsoft.GotoAction",
21+
"actionId": "wherethesundontshine"
22+
}
23+
]
24+
},
25+
{
26+
"$kind": "Microsoft.Test.AssertCondition",
27+
"condition": "false",
28+
"description": "Step after Goto should never be executed!"
29+
}
30+
]
31+
},
32+
{
33+
"$kind": "Microsoft.OnError",
34+
"actions": [
35+
{
36+
"$kind": "Microsoft.SendActivity",
37+
"activity": "error"
38+
}
39+
]
40+
}
41+
]
42+
},
43+
"script": [
44+
{
45+
"$kind": "Microsoft.Test.UserConversationUpdate"
46+
},
47+
{
48+
"$kind": "Microsoft.Test.AssertReply",
49+
"text": "error"
50+
}
51+
]
52+
}

0 commit comments

Comments
 (0)