-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpromod.system.config.js
326 lines (311 loc) · 8.33 KB
/
promod.system.config.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
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
// @ts-check
/**
* @info common actions for all base lements
* that should be counted during action generation
*
* @example file ./lib/base/element.ts
*
* BaseElement has next availalbe for action generation
* setKeys
* click
* getContent
* getVisibility
*
* entryType property is used for dype definition
*
* @example file ./lib/elements/input.ts
* Input has next types list
*
* InputAction
* InputVisible
* InputContent
* InputSetKeys
*
* to represent these types usage it could be overriden like, but it does not required
* since main goal of these types is to be used in generated code
*
* class Input extends BaseElement {
* constructor(rootElement, id) {
* super(rootElement, id);
* }
*
* async setKeys(setKeysData: string) {
* await this.root.set(setKeysData);
* }
*
* async getContent(_arg: InputAction): Promise<InputContent> {
* return await this.root.getInputValue();
* }
*
* async getVisibility(_arg: InputAction): Promise<InputVisible> {
* return await super.getVisibility(_arg);
* }
*
* async click(_arg: InputAction): Promise<void> {
* await super.click(_arg);
* }
*
* Take a look on Input methods setKeys and getContent
* setKeys is a new method that is not available in BaseElement since it is
* not possible to set keys for Button or Text elements.
*
* getContent is overriden to return value from input element, since input content is a value
* that was set by user.
*
*/
const commonActions = {
click: {
entryType: 'Action',
},
getContent: {
entryType: 'Action',
resultType: 'Content',
},
getVisibility: {
entryType: 'Action',
resultType: 'Visible',
},
waitContent: {
entryType: 'Content',
},
_whereContent: {
resultType: 'Content',
},
_whereVisibiliy: {
resultType: 'Visible',
},
};
/**
* @info definition of the actions based on the base project element base
*
* @example file ./lib/elements/input.ts
*
* Input has setKeys action that is not available for other elements
* so it should be added to Input property details, so generation will
* include this action for all Fragments/Pages elements that
* setKeys action going to be generated.
* If Page elements and page Fragments do not have Input element
* setKeys action will not be generated
*/
const baseElementsActionsDescription = {
Input: {
setKeys: {
entryType: 'SetKeys',
},
...commonActions,
},
Button: {
...commonActions,
},
Text: {
...commonActions,
},
};
/**
* @info definition of the list actions
*
* @example file ./lib/base/list.ts
* next type has _whereContent, _whereVisibiliy, _action properties
*
* type TAction = {
* _whereContent?: unknown;
* _whereVisibiliy?: unknown;
* _action?: unknown;
* };
* it is used for list element search by criteria
*
* e.g hext html page
* <input />
* <input style="display: none;"/>
* <input />
* <input />
* some values were filled before so inputs have next values
* <input /> // value: 1
* <input style="display: none;"/>
* <input /> // value: 4
* <input /> // value: 5
*
* goal is to set "add to current data" value in field which is bilitble and has value 4,
* so action object should be next
* const listSetKeysAction = {
* _whereVisibiliy: true,
* _whereContent: '4',
* _action: 'add to current data',
* }
*
*/
const collectionActionTypes = {
action: 'TItemListAction',
check: 'TItemListCheck',
compare: 'TItemListCompare',
};
/**
* @info collectionDescription
* collectionDescription is used to define collection actions object
* that is used in generated code and usage on test level
*
* @see promod.system.config.js:110
*
*/
const collectionDescription = {
action: '_action',
where: '_whereContent',
visible: '_whereVisibiliy',
length: 'length',
};
const collectionGenericAction = {
where: { action: '_whereContent', actionType: 'resultType' },
visible: { action: '_whereVisibiliy', actionType: 'resultType' },
generic: collectionActionTypes.action,
};
const baseCollectionActionsDescription = {
getContent: {
entryType: {
...collectionGenericAction,
action: { action: 'getContent', actionType: 'entryType' },
},
resultType: {
action: { action: 'getContent', actionType: 'resultType' },
endType: '[]',
},
},
getVisibility: {
entryType: {
...collectionGenericAction,
action: { action: 'getVisibility', actionType: 'entryType' },
},
resultType: {
click: { action: 'getVisibility', actionType: 'resultType' },
endType: '[]',
},
},
setKeys: {
entryType: {
...collectionGenericAction,
action: { action: 'setKeys', actionType: 'entryType' },
},
},
click: {
entryType: {
...collectionGenericAction,
action: { action: 'click', actionType: 'entryType' },
},
},
_whereContent: {
entryType: {
where: { action: '_whereContent', actionType: 'resultType' },
visible: { action: '_whereVisibiliy', actionType: 'resultType' },
generic: collectionActionTypes.action,
action: { action: 'getContent', actionType: 'entryType' },
},
resultType: {
where: { action: '_whereContent', actionType: 'resultType' },
visible: { action: '_whereVisibiliy', actionType: 'resultType' },
action: { action: 'getContent', actionType: 'entryType' },
generic: collectionActionTypes.action,
},
},
_whereVisibiliy: {
entryType: {
...collectionGenericAction,
},
resultType: {
...collectionGenericAction,
},
},
waitContent: {
entryType: {
where: { action: '_whereContent', actionType: 'resultType' },
visible: { action: '_whereVisibiliy', actionType: 'resultType' },
action: { action: 'getContent', actionType: 'entryType' },
generic: collectionActionTypes.check,
},
},
};
/**
* @info definitions of the actions that are used in generated types
* to avoid any misconceptions in generated code and expected behavior
* on actions usage level
*/
const resultActionsMap = {
click: 'void',
getContent: 'resultType',
getVisibility: 'resultType',
setKeys: 'void',
waitVisibility: 'void',
waitContent: 'void',
};
/**
* @info base library description
*
*
* @example file ./lib/base/list.ts
* getListItem method is used to get collection item instance
*
* const listItems = new ItemList($$('input'), 'Inputs list', Input);
*
* const secondInput = listItems.getListItem(1);
* used index 1 to get second input element since indexes are started from 0
*
*
* @property getPageInstance is used by generator to get page instance
* @property entityId is used to proper name of the action
* @property pageId is used to indentify page class from the module if getPageInstance property is not defined
* @property fragmentId is used to define entity id property name
* @property getCollectionTypeFormat is used to define strategy of collection type generation
* @example file ./lib/base/list.ts
*
* type declaration of the list requires generated type to be defined as one type
* which is used for generic
*
* type TAction = {
* _whereContent?: unknown;
* _whereVisibiliy?: unknown;
* _action?: unknown;
* };
*
* export type TItemListAction<T extends TAction> = {
* _whereContent?: T['_whereContent'];
* _whereVisibiliy?: T['_whereVisibiliy'];
* _action?: T['_action'];
* };
*
* it is possible to have TItemListAction<TWhere, TVilible, TAction> type
* which has 3 generic types used
*/
const baseLibraryDescription = {
getPageInstance: 'getPage',
getDataMethod: 'getContent',
getVisibilityMethod: 'getVisibility',
waitVisibilityMethod: 'waitVisibility',
waitContentMethod: 'waitContent',
entityId: 'id',
pageId: 'Page',
fragmentId: 'Fragment',
waitOptionsId: 'TWaitOpts',
generalActionOptionsId: 'TActionOpts',
collectionId: 'ItemList',
collectionRootElementsId: 'roots',
getCollectionItemInstance: 'getListItem',
getCollectionTypeFormat: 'object',
};
const collectionRandomDataDescription = {
_whereContent: {
action: '_whereContent',
actionType: 'resultType',
},
_whereVisibiliy: {
action: '_whereVisibiliy',
actionType: 'resultType',
},
};
module.exports = {
pathToBase: 'lib',
baseElementsActionsDescription,
baseCollectionActionsDescription,
resultActionsMap,
baseLibraryDescription,
collectionDescription,
collectionRandomDataDescription,
collectionActionTypes,
};