-
Notifications
You must be signed in to change notification settings - Fork 857
/
Copy pathmatrixdropdown.js
233 lines (224 loc) · 7.08 KB
/
matrixdropdown.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
// import { fixture, test, Selector } from "testcafe";
// import { frameworks, url, initSurvey, getSurveyResult, getListItemByText, completeButton } from "../helper";
// const title = "matrixdropdown";
// const json = {
// questions: [
// {
// type: "matrixdropdown",
// name: "frameworksRate",
// title: "Please tells us your opinion about JavaScript MVVM frameworks",
// choices: ["Excelent", "Good", "Average", "Fair", "Poor"],
// columns: [
// {
// name: "using",
// title: "Do you use it?",
// choices: ["Yes", "No"],
// cellType: "radiogroup"
// },
// {
// name: "experience",
// title: "How long do you use it?",
// cellType: "dropdown",
// choices: [
// { value: 5, text: "3-5 years" },
// { value: 2, text: "1-2 years" },
// {
// value: 1,
// text: "less than a year"
// }
// ]
// },
// {
// name: "strength",
// title: "What is main strength?",
// choices: ["Easy", "Compact", "Fast", "Powerfull"],
// cellType: "checkbox"
// },
// {
// name: "knowledge",
// title: "Please describe your experience",
// cellType: "text"
// },
// { name: "rate", title: "Please rate the framework itself" }
// ],
// rows: [
// { value: "angularv1", text: "angularjs v1.x" },
// { value: "angularv2", text: "angularjs v2" },
// { value: "knockoutjs" },
// { value: "reactjs" }
// ]
// }
// ]
// };
// frameworks.forEach(framework => {
// fixture`${framework} ${title}`.page`${url}${framework}`.beforeEach(
// async t => {
// await t.resizeWindow(1920, 1080);
// await initSurvey(framework, json);
// }
// );
// test("choose several values", async t => {
// const matrixRowSelector = Selector(".sd-table__row");
// const Angular1Row = matrixRowSelector.nth(0);
// const KnockoutRow = matrixRowSelector.nth(2);
// const radioControlClassName = ".sd-radio__control";
// const questionDropdownClassName = ".sd-dropdown";
// const checkboxControlClassName = ".sd-checkbox__control";
// const textControlClassName = ".sd-text";
// // answer for row 1
// await t
// .click(Angular1Row.find(radioControlClassName).withAttribute("value", "Yes"))
// .click(Angular1Row.find(questionDropdownClassName).nth(0))
// .click(getListItemByText("2"))
// .click(Selector("body"), { offsetX: 1, offsetY: 1 })
// .click(Angular1Row.find(checkboxControlClassName).withAttribute("value", "Fast"))
// .typeText(Angular1Row.find(textControlClassName), "why hello world so hard")
// .click(Angular1Row.find(questionDropdownClassName).nth(1))
// .click(getListItemByText("Excelent"))
// .click(Selector("body"), { offsetX: 1, offsetY: 1 });
// // answer for row 3
// await t
// .click(KnockoutRow.find(radioControlClassName).withAttribute("value", "No"))
// .click(KnockoutRow.find(questionDropdownClassName).nth(0))
// .click(getListItemByText("5"))
// .click(Selector("body"), { offsetX: 1, offsetY: 1 })
// .click(KnockoutRow.find(checkboxControlClassName).withAttribute("value", "Easy"))
// .click(KnockoutRow.find(checkboxControlClassName).withAttribute("value", "Powerfull"))
// .typeText(KnockoutRow.find(textControlClassName), "it is not 2016")
// .click(KnockoutRow.find(questionDropdownClassName).nth(1))
// .click(getListItemByText("Good"));
// await t.click(completeButton);
// const surveyResult = await getSurveyResult();
// await t.expect(surveyResult.frameworksRate.angularv1).eql({
// using: "Yes",
// knowledge: "why hello world so hard",
// rate: "Excelent",
// strength: ["Fast"],
// experience: 2
// });
// await t.expect(surveyResult.frameworksRate.knockoutjs).eql({
// knowledge: "it is not 2016",
// rate: "Good",
// strength: ["Easy", "Powerfull"],
// experience: 5,
// using: "No"
// });
// });
// });
// const json2 = {
// "focusFirstQuestionAutomatic": true,
// "elements": [{
// "type": "radiogroup",
// "name": "question2",
// "defaultValue": "Item1",
// "choices": [
// "Item1",
// "Item2",
// "Item3"
// ]
// },
// {
// "type": "matrixdropdown",
// "name": "question1",
// "columns": [
// {
// "name": "Column 1",
// "cellType": "text",
// "requiredIf": "{question2} = 'Item1'"
// }
// ],
// "columnLayout": "vertical",
// "rows": [
// "Row 1",
// "Row 2"
// ]
// }]
// };
// frameworks.forEach(framework => {
// fixture`${framework} ${title}`.page`${url}${framework}`.beforeEach(
// async t => {
// await initSurvey(framework, json2);
// }
// );
// test("Column requiredIf and vertical layout", async t => {
// const requiredSpan = Selector("span").withExactText("*");
// await t.expect(requiredSpan.exists).ok();
// await t.pressKey("down");
// await t.expect(requiredSpan.exists).notOk();
// await t.pressKey("up");
// await t.expect(requiredSpan.exists).ok();
// });
// });
// const json3 = {
// "elements": [
// {
// "type": "matrixdropdown",
// "name": "question1",
// "columns": [
// {
// "name": "Column 1"
// },
// {
// "name": "Column 2"
// },
// {
// "name": "Column 3"
// },
// {
// "name": "Column 4"
// },
// {
// "name": "Column 5"
// },
// {
// "name": "Column 6"
// },
// {
// "name": "Column 7"
// },
// {
// "name": "Column 8"
// },
// {
// "name": "Column 9"
// },
// {
// "name": "Column 10",
// "isRequired": true
// }
// ],
// "choices": [
// 1,
// 2,
// 3,
// 4,
// 5
// ],
// "rows": [
// "Row 1",
// "Row 2"
// ]
// }
// ]
// };
// frameworks.forEach(framework => {
// fixture`${framework} ${title}`.page`${url}${framework}`.beforeEach(
// async t => {
// await initSurvey(framework, json3);
// }
// );
// test("Make a horizontal scroll to show a column with an error", async t => {
// function filterIsInViewport(node) {
// const rect = node.getBoundingClientRect();
// return (
// rect.top >= 0 &&
// rect.left >= 0 &&
// rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) &&
// rect.right <= (window.innerWidth || document.documentElement.clientWidth)
// );
// }
// const requiredSpan = Selector("span").withExactText("Response required.");
// await t.click("input[value=Complete]")
// .expect(Selector(requiredSpan).filter(filterIsInViewport).exists).ok();
// });
// });