@elisra-devops/docgen-skins 0.3.4 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/sonar-project.properties +4 -4
- package/.github/workflows/ci.yml +23 -18
- package/.github/workflows/release.yml +47 -45
- package/Readme.md +6 -6
- package/bin/index.d.ts +15 -0
- package/bin/index.js +277 -0
- package/bin/index.js.map +1 -0
- package/bin/models/json/JSONRun.d.ts +7 -0
- package/bin/models/json/JSONRun.js +84 -0
- package/bin/models/json/JSONRun.js.map +1 -0
- package/bin/models/json/default.d.ts +3 -0
- package/bin/models/json/default.js +25 -0
- package/bin/models/json/default.js.map +1 -0
- package/bin/models/json/html/JSONHtml.d.ts +6 -0
- package/bin/models/json/html/JSONHtml.js +13 -0
- package/bin/models/json/html/JSONHtml.js.map +1 -0
- package/bin/models/json/paragraph/JSONParagraph.d.ts +9 -0
- package/bin/models/json/paragraph/JSONParagraph.js +62 -0
- package/bin/models/json/paragraph/JSONParagraph.js.map +1 -0
- package/bin/models/json/paragraph/JSONRichTextParagraph.d.ts +9 -0
- package/bin/models/json/paragraph/JSONRichTextParagraph.js +72 -0
- package/bin/models/json/paragraph/JSONRichTextParagraph.js.map +1 -0
- package/bin/models/json/paragraph/JSONTestSuiteHeaderParagraph.d.ts +10 -0
- package/bin/models/json/paragraph/JSONTestSuiteHeaderParagraph.js +76 -0
- package/bin/models/json/paragraph/JSONTestSuiteHeaderParagraph.js.map +1 -0
- package/bin/models/json/table/JSONTable.d.ts +9 -0
- package/bin/models/json/table/JSONTable.js +60 -0
- package/bin/models/json/table/JSONTable.js.map +1 -0
- package/bin/models/json/table/JSONTableCell.d.ts +8 -0
- package/bin/models/json/table/JSONTableCell.js +105 -0
- package/bin/models/json/table/JSONTableCell.js.map +1 -0
- package/bin/models/json/table/JSONTableRow.d.ts +7 -0
- package/bin/models/json/table/JSONTableRow.js +27 -0
- package/bin/models/json/table/JSONTableRow.js.map +1 -0
- package/bin/models/json/wordJsonModels.d.ts +97 -0
- package/bin/models/json/wordJsonModels.js +3 -0
- package/bin/models/json/wordJsonModels.js.map +1 -0
- package/bin/services/logger.d.ts +3 -0
- package/bin/services/logger.js +46 -0
- package/bin/services/logger.js.map +1 -0
- package/bin/snippets/free-runs.d.ts +1 -0
- package/bin/snippets/free-runs.js +58 -0
- package/bin/snippets/free-runs.js.map +1 -0
- package/bin/test/skins.test.d.ts +1 -0
- package/bin/test/skins.test.js +116 -0
- package/bin/test/skins.test.js.map +1 -0
- package/package.json +46 -46
- package/samples/document-skins-examples/document-attchament-table.json +25 -25
- package/samples/document-skins-examples/documentExample.json +66 -66
- package/samples/document-skins-examples/paragraphExample.json +16 -16
- package/samples/document-skins-examples/tableExample.json +29 -29
- package/src/index.ts +338 -401
- package/src/models/json/JSONRun.ts +80 -80
- package/src/models/json/default.ts +23 -23
- package/src/models/json/html/JSONHtml.ts +13 -13
- package/src/models/json/paragraph/JSONParagraph.ts +76 -76
- package/src/models/json/paragraph/JSONRichTextParagraph.ts +84 -84
- package/src/models/json/paragraph/JSONTestSuiteHeaderParagraph.ts +94 -94
- package/src/models/json/table/JSONTable.ts +74 -74
- package/src/models/json/table/JSONTableCell.ts +117 -117
- package/src/models/json/table/JSONTableRow.ts +34 -34
- package/src/models/json/wordJsonModels.ts +97 -97
- package/src/services/logger.ts +26 -26
- package/src/snippets/free-runs.ts +53 -53
- package/src/test/skins.test.ts +171 -171
- package/tsconfig.json +61 -61
package/src/index.ts
CHANGED
|
@@ -1,401 +1,338 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
} from
|
|
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
|
-
populatedSkin
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
);
|
|
56
|
-
return false;
|
|
57
|
-
}
|
|
58
|
-
break;
|
|
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
|
-
switch
|
|
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
|
-
testcase.
|
|
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
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
IsUnderline: false,
|
|
340
|
-
Size: 12,
|
|
341
|
-
Uri: null,
|
|
342
|
-
Font: "Arial",
|
|
343
|
-
InsertLineBreak: false,
|
|
344
|
-
InsertSpace: true,
|
|
345
|
-
};
|
|
346
|
-
testSkin.push(testProcedureTitleParagraph.getJSONParagraph());
|
|
347
|
-
//create test steps table
|
|
348
|
-
let tableSkin = new JSONTable(
|
|
349
|
-
testcase.testCaseStepsSkinData,
|
|
350
|
-
TableContentStyles,
|
|
351
|
-
headingLvl
|
|
352
|
-
);
|
|
353
|
-
let populatedTableSkin = tableSkin.getJSONTable();
|
|
354
|
-
testSkin.push(populatedTableSkin);
|
|
355
|
-
}
|
|
356
|
-
} catch (error) {
|
|
357
|
-
logger.warn(
|
|
358
|
-
`For suite id : ${testSuite.suiteSkinData.fields[0].value} , the testCaseStepsSkinData is not defined for ${testcase.testCaseHeaderSkinData.fields[0].value} `
|
|
359
|
-
);
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
//attachments table
|
|
363
|
-
if (testcase.testCaseAttachments) {
|
|
364
|
-
if (
|
|
365
|
-
testcase.testCaseAttachments.length > 0 &&
|
|
366
|
-
includeAttachments == true
|
|
367
|
-
) {
|
|
368
|
-
|
|
369
|
-
let testDescriptionTitleParagraph = new JSONParagraph(
|
|
370
|
-
{ name: "Title", value: "Test Case Attachments:" },
|
|
371
|
-
styles,
|
|
372
|
-
testcase.id || 0,
|
|
373
|
-
0
|
|
374
|
-
);
|
|
375
|
-
testSkin.push(testDescriptionTitleParagraph.getJSONParagraph());
|
|
376
|
-
//create test steps table
|
|
377
|
-
let tableSkin = new JSONTable(
|
|
378
|
-
testcase.testCaseAttachments,
|
|
379
|
-
styles,
|
|
380
|
-
headingLvl
|
|
381
|
-
);
|
|
382
|
-
let populatedTableSkin = tableSkin.getJSONTable();
|
|
383
|
-
testSkin.push(populatedTableSkin);
|
|
384
|
-
}
|
|
385
|
-
}
|
|
386
|
-
});
|
|
387
|
-
});
|
|
388
|
-
return testSkin;
|
|
389
|
-
break;
|
|
390
|
-
case "html":
|
|
391
|
-
logger.info(`Generating html test data!`);
|
|
392
|
-
break;
|
|
393
|
-
default:
|
|
394
|
-
return false;
|
|
395
|
-
} //switch
|
|
396
|
-
} //generateTestBasedSkin
|
|
397
|
-
|
|
398
|
-
getDocumentSkin(): DocumentSkin {
|
|
399
|
-
return this.documentSkin;
|
|
400
|
-
} //getDocumentSkin
|
|
401
|
-
}
|
|
1
|
+
import { DocumentSkin, WIQueryResults, WIData, WIProperty, StyleOptions } from './models/json/wordJsonModels';
|
|
2
|
+
import logger from './services/logger';
|
|
3
|
+
import JSONTable from './models/json/table/JSONTable';
|
|
4
|
+
import JSONParagraph from './models/json/paragraph/JSONParagraph';
|
|
5
|
+
import JSONHeaderParagraph from './models/json/paragraph/JSONTestSuiteHeaderParagraph';
|
|
6
|
+
import JSONRichTextParagraph from './models/json/paragraph/JSONRichTextParagraph';
|
|
7
|
+
import { DescriptionandProcedureStyle } from './models/json/default';
|
|
8
|
+
|
|
9
|
+
export default class Skins {
|
|
10
|
+
SKIN_TYPE_TABLE = 'table';
|
|
11
|
+
SKIN_TYPE_PARAGRAPH = 'paragraph';
|
|
12
|
+
SKIN_TYPE_TEST_PLAN = 'test-plan';
|
|
13
|
+
|
|
14
|
+
documentSkin: DocumentSkin = {
|
|
15
|
+
templatePath: '',
|
|
16
|
+
contentControls: [],
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
skinFormat: string = 'json';
|
|
20
|
+
|
|
21
|
+
constructor(skinFormat: string = 'json', templatePath: string) {
|
|
22
|
+
this.documentSkin.templatePath = templatePath;
|
|
23
|
+
this.skinFormat = skinFormat;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
async addNewContentToDocumentSkin(
|
|
27
|
+
contetnControlTitle: string,
|
|
28
|
+
skinType: string,
|
|
29
|
+
data: any,
|
|
30
|
+
styles: StyleOptions,
|
|
31
|
+
headingLvl: number = 0,
|
|
32
|
+
includeAttachments: boolean = true
|
|
33
|
+
): Promise<any> {
|
|
34
|
+
try {
|
|
35
|
+
let populatedSkin;
|
|
36
|
+
|
|
37
|
+
switch (skinType) {
|
|
38
|
+
case this.SKIN_TYPE_TABLE:
|
|
39
|
+
populatedSkin = this.generateQueryBasedTable(data, styles, headingLvl);
|
|
40
|
+
if (populatedSkin === false) {
|
|
41
|
+
logger.error(`Could not generate table for content control :${contetnControlTitle}`);
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
break;
|
|
45
|
+
case this.SKIN_TYPE_PARAGRAPH:
|
|
46
|
+
populatedSkin = this.generateQueryBasedParagraphs(data, styles, headingLvl);
|
|
47
|
+
if (populatedSkin === false) {
|
|
48
|
+
logger.error(`Could not generate paragraph for content control :${contetnControlTitle}`);
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
break;
|
|
52
|
+
case this.SKIN_TYPE_TEST_PLAN:
|
|
53
|
+
populatedSkin = this.generateTestBasedSkin(data, styles, headingLvl, includeAttachments);
|
|
54
|
+
if (populatedSkin === false) {
|
|
55
|
+
logger.error(`Could not generate test skin for content control :${contetnControlTitle}`);
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
break;
|
|
59
|
+
default:
|
|
60
|
+
logger.error(`Unknown skinType : ${skinType} - not appended to document skin`);
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return populatedSkin;
|
|
65
|
+
|
|
66
|
+
// await this.validateAndAppendContentControl(
|
|
67
|
+
// contetnControlTitle,
|
|
68
|
+
// populatedSkin
|
|
69
|
+
// );
|
|
70
|
+
} catch (error) {
|
|
71
|
+
logger.error(`Fatal error happened when generate skin for : ${contetnControlTitle}`);
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
} //addNewContentToDocumentSkin
|
|
75
|
+
|
|
76
|
+
// iterates on content controls array:
|
|
77
|
+
// if finds return true else creates content control and returns true
|
|
78
|
+
// on error returns false
|
|
79
|
+
async validateAndAppendContentControl(contetnControlTitle: string, populatedSkin: any): Promise<boolean> {
|
|
80
|
+
try {
|
|
81
|
+
let isContetnControlExists: boolean[] = await Promise.all(
|
|
82
|
+
this.documentSkin.contentControls.map((contentControl, i) => {
|
|
83
|
+
if (contentControl.title === contetnControlTitle) {
|
|
84
|
+
logger.debug(`Content control - ${contetnControlTitle} found on index ${i}
|
|
85
|
+
populating with: ${contetnControlTitle}`);
|
|
86
|
+
this.documentSkin.contentControls[i].wordObjects = [
|
|
87
|
+
...this.documentSkin.contentControls[i].wordObjects,
|
|
88
|
+
...populatedSkin,
|
|
89
|
+
];
|
|
90
|
+
return true;
|
|
91
|
+
}
|
|
92
|
+
return false;
|
|
93
|
+
}) //.map
|
|
94
|
+
); //Promise.all
|
|
95
|
+
|
|
96
|
+
if (!isContetnControlExists.includes(true)) {
|
|
97
|
+
let contentControlToAppend = {
|
|
98
|
+
title: contetnControlTitle,
|
|
99
|
+
wordObjects: populatedSkin,
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
logger.debug(`Content control - ${contetnControlTitle} not found
|
|
103
|
+
appending to document title:
|
|
104
|
+
${JSON.stringify(contetnControlTitle)}`);
|
|
105
|
+
this.documentSkin.contentControls.unshift(contentControlToAppend);
|
|
106
|
+
}
|
|
107
|
+
logger.info(`Appended new content control document: ${contetnControlTitle}`);
|
|
108
|
+
return true;
|
|
109
|
+
} catch (error) {
|
|
110
|
+
logger.error(`Error validating and appending to content control`);
|
|
111
|
+
console.log(error);
|
|
112
|
+
}
|
|
113
|
+
} //validateAndAppendContentControl
|
|
114
|
+
|
|
115
|
+
//parses data to the class skin format and returns the parsed data
|
|
116
|
+
//returns false if supplied an invalid type or error occurd during parsing
|
|
117
|
+
generateQueryBasedTable(data: WIQueryResults, styles: StyleOptions, headingLvl: number = 0) {
|
|
118
|
+
logger.debug(`Generating table as ${this.skinFormat}`);
|
|
119
|
+
|
|
120
|
+
switch (this.skinFormat) {
|
|
121
|
+
case 'json':
|
|
122
|
+
let tableSkin = new JSONTable(data, styles, headingLvl);
|
|
123
|
+
return [tableSkin.getJSONTable()];
|
|
124
|
+
case 'html':
|
|
125
|
+
logger.info(`Generating html table!`);
|
|
126
|
+
break;
|
|
127
|
+
default:
|
|
128
|
+
return false;
|
|
129
|
+
} //switch
|
|
130
|
+
} //generateTable
|
|
131
|
+
|
|
132
|
+
generateQueryBasedParagraphs(data: any, styles: StyleOptions, headingLvl: number = 0) {
|
|
133
|
+
logger.debug(`Generating paragraph as ${this.skinFormat}`);
|
|
134
|
+
|
|
135
|
+
switch (this.skinFormat) {
|
|
136
|
+
case 'json':
|
|
137
|
+
let paragraphs: any[] = [];
|
|
138
|
+
data.forEach((wi: WIData) => {
|
|
139
|
+
wi.fields.forEach((field: WIProperty) => {
|
|
140
|
+
//Description and Test Description are handled in richText handler
|
|
141
|
+
if (field.name === 'Description: ' || field.name === 'Test Description:') {
|
|
142
|
+
let paragraphSkin = new JSONRichTextParagraph(field, styles, wi.Source, headingLvl + wi.level);
|
|
143
|
+
paragraphs.push(paragraphSkin.getJSONRichTextParagraph());
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
//making sure ID is not printed
|
|
147
|
+
//excluding Description and Test Description are handled in richText handler
|
|
148
|
+
if (field.name !== 'ID' && field.name !== 'Description: ' && field.name !== 'Test Description:') {
|
|
149
|
+
let paragraphSkin = new JSONParagraph(field, styles, wi.Source, headingLvl + wi.level);
|
|
150
|
+
paragraphs.push(paragraphSkin.getJSONParagraph());
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
});
|
|
154
|
+
return paragraphs;
|
|
155
|
+
case 'html':
|
|
156
|
+
logger.info(`Generating html paragraphs!`);
|
|
157
|
+
break;
|
|
158
|
+
default:
|
|
159
|
+
return false;
|
|
160
|
+
} //switch
|
|
161
|
+
} //generateParagraph
|
|
162
|
+
|
|
163
|
+
generateTestBasedSkin(
|
|
164
|
+
data: any,
|
|
165
|
+
styles: StyleOptions,
|
|
166
|
+
headingLvl: number = 0,
|
|
167
|
+
includeAttachments: boolean = true
|
|
168
|
+
) {
|
|
169
|
+
logger.debug(`Generating testSkin as ${this.skinFormat}`);
|
|
170
|
+
switch (this.skinFormat) {
|
|
171
|
+
case 'json':
|
|
172
|
+
let testSkin: any[] = [];
|
|
173
|
+
//create suite Header pragraph
|
|
174
|
+
data.forEach((testSuite: any) => {
|
|
175
|
+
let SuiteStyles = {
|
|
176
|
+
isBold: true,
|
|
177
|
+
IsItalic: false,
|
|
178
|
+
IsUnderline: false,
|
|
179
|
+
Size: 16,
|
|
180
|
+
Uri: null,
|
|
181
|
+
Font: 'Arial',
|
|
182
|
+
InsertLineBreak: false,
|
|
183
|
+
InsertSpace: true,
|
|
184
|
+
};
|
|
185
|
+
let testSuiteParagraphSkin = new JSONHeaderParagraph(
|
|
186
|
+
testSuite.suiteSkinData.fields,
|
|
187
|
+
SuiteStyles,
|
|
188
|
+
testSuite.suiteSkinData.id || 0,
|
|
189
|
+
testSuite.suiteSkinData.level
|
|
190
|
+
? headingLvl + testSuite.suiteSkinData.level
|
|
191
|
+
: headingLvl
|
|
192
|
+
? headingLvl
|
|
193
|
+
: 1
|
|
194
|
+
);
|
|
195
|
+
testSkin.push(testSuiteParagraphSkin.getJSONParagraph());
|
|
196
|
+
|
|
197
|
+
testSuite.testCases.forEach((testcase) => {
|
|
198
|
+
//create testcase Header paragraph
|
|
199
|
+
let testCaseHeaderFields = [
|
|
200
|
+
testcase.testCaseHeaderSkinData.fields[0],
|
|
201
|
+
testcase.testCaseHeaderSkinData.fields[1],
|
|
202
|
+
];
|
|
203
|
+
let TestCaseStyles = {
|
|
204
|
+
isBold: true,
|
|
205
|
+
IsItalic: false,
|
|
206
|
+
IsUnderline: false,
|
|
207
|
+
Size: 14,
|
|
208
|
+
Uri: null,
|
|
209
|
+
Font: 'Arial',
|
|
210
|
+
InsertLineBreak: false,
|
|
211
|
+
InsertSpace: true,
|
|
212
|
+
};
|
|
213
|
+
let testCaseParagraphSkin = new JSONHeaderParagraph(
|
|
214
|
+
testCaseHeaderFields,
|
|
215
|
+
TestCaseStyles,
|
|
216
|
+
testcase.id || 0,
|
|
217
|
+
testcase.testCaseHeaderSkinData.level
|
|
218
|
+
? headingLvl + testcase.testCaseHeaderSkinData.level
|
|
219
|
+
: headingLvl
|
|
220
|
+
? headingLvl
|
|
221
|
+
: 1
|
|
222
|
+
);
|
|
223
|
+
testSkin.push(testCaseParagraphSkin.getJSONParagraph());
|
|
224
|
+
|
|
225
|
+
let testDescriptionTitleParagraph = new JSONParagraph(
|
|
226
|
+
{ name: 'Title', value: 'Test Description:' },
|
|
227
|
+
DescriptionandProcedureStyle,
|
|
228
|
+
testcase.id || 0,
|
|
229
|
+
0
|
|
230
|
+
);
|
|
231
|
+
testSkin.push(testDescriptionTitleParagraph.getJSONParagraph());
|
|
232
|
+
let testDescriptionParagraph = new JSONRichTextParagraph(
|
|
233
|
+
testcase.testCaseHeaderSkinData.fields[2],
|
|
234
|
+
styles,
|
|
235
|
+
testcase.id || 0,
|
|
236
|
+
0
|
|
237
|
+
);
|
|
238
|
+
let richTextSkin: any[] = testDescriptionParagraph.getJSONRichTextParagraph();
|
|
239
|
+
testSkin = [...testSkin, ...richTextSkin];
|
|
240
|
+
|
|
241
|
+
if (testcase.testCaseRequirements) {
|
|
242
|
+
if (testcase.testCaseRequirements.length > 0) {
|
|
243
|
+
let testDescriptionTitleParagraph = new JSONParagraph(
|
|
244
|
+
{ name: 'Title', value: 'Covered Requirements:' },
|
|
245
|
+
DescriptionandProcedureStyle,
|
|
246
|
+
testcase.id || 0,
|
|
247
|
+
0
|
|
248
|
+
);
|
|
249
|
+
testSkin.push(testDescriptionTitleParagraph.getJSONParagraph());
|
|
250
|
+
//create test steps table
|
|
251
|
+
let tableSkin = new JSONTable(testcase.testCaseRequirements, styles, headingLvl);
|
|
252
|
+
|
|
253
|
+
let populatedTableSkin = tableSkin.getJSONTable();
|
|
254
|
+
|
|
255
|
+
testSkin.push(populatedTableSkin);
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
if (testcase.testCaseBugs) {
|
|
260
|
+
if (testcase.testCaseBugs.length > 0) {
|
|
261
|
+
let testDescriptionTitleParagraph = new JSONParagraph(
|
|
262
|
+
{ name: 'Title', value: 'Linked Bugs:' },
|
|
263
|
+
DescriptionandProcedureStyle,
|
|
264
|
+
testcase.id || 0,
|
|
265
|
+
0
|
|
266
|
+
);
|
|
267
|
+
testSkin.push(testDescriptionTitleParagraph.getJSONParagraph());
|
|
268
|
+
//create test steps table
|
|
269
|
+
let tableSkin = new JSONTable(testcase.testCaseBugs, styles, headingLvl);
|
|
270
|
+
|
|
271
|
+
let populatedTableSkin = tableSkin.getJSONTable();
|
|
272
|
+
|
|
273
|
+
testSkin.push(populatedTableSkin);
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
try {
|
|
278
|
+
if (testcase.testCaseStepsSkinData.length > 0) {
|
|
279
|
+
let testProcedureTitleParagraph = new JSONParagraph(
|
|
280
|
+
{ name: 'Title', value: 'Test Procedure:' },
|
|
281
|
+
DescriptionandProcedureStyle,
|
|
282
|
+
testcase.id || 0,
|
|
283
|
+
0
|
|
284
|
+
);
|
|
285
|
+
let TableContentStyles = {
|
|
286
|
+
isBold: false,
|
|
287
|
+
IsItalic: false,
|
|
288
|
+
IsUnderline: false,
|
|
289
|
+
Size: 12,
|
|
290
|
+
Uri: null,
|
|
291
|
+
Font: 'Arial',
|
|
292
|
+
InsertLineBreak: false,
|
|
293
|
+
InsertSpace: true,
|
|
294
|
+
};
|
|
295
|
+
testSkin.push(testProcedureTitleParagraph.getJSONParagraph());
|
|
296
|
+
//create test steps table
|
|
297
|
+
let tableSkin = new JSONTable(testcase.testCaseStepsSkinData, TableContentStyles, headingLvl);
|
|
298
|
+
let populatedTableSkin = tableSkin.getJSONTable();
|
|
299
|
+
testSkin.push(populatedTableSkin);
|
|
300
|
+
}
|
|
301
|
+
} catch (error) {
|
|
302
|
+
logger.warn(
|
|
303
|
+
`For suite id : ${testSuite.suiteSkinData.fields[0].value} , the testCaseStepsSkinData is not defined for ${testcase.testCaseHeaderSkinData.fields[0].value} `
|
|
304
|
+
);
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
//attachments table
|
|
308
|
+
if (testcase.testCaseAttachments) {
|
|
309
|
+
if (testcase.testCaseAttachments.length > 0 && includeAttachments == true) {
|
|
310
|
+
let testDescriptionTitleParagraph = new JSONParagraph(
|
|
311
|
+
{ name: 'Title', value: 'Test Case Attachments:' },
|
|
312
|
+
styles,
|
|
313
|
+
testcase.id || 0,
|
|
314
|
+
0
|
|
315
|
+
);
|
|
316
|
+
testSkin.push(testDescriptionTitleParagraph.getJSONParagraph());
|
|
317
|
+
//create test steps table
|
|
318
|
+
let tableSkin = new JSONTable(testcase.testCaseAttachments, styles, headingLvl);
|
|
319
|
+
let populatedTableSkin = tableSkin.getJSONTable();
|
|
320
|
+
testSkin.push(populatedTableSkin);
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
});
|
|
324
|
+
});
|
|
325
|
+
return testSkin;
|
|
326
|
+
break;
|
|
327
|
+
case 'html':
|
|
328
|
+
logger.info(`Generating html test data!`);
|
|
329
|
+
break;
|
|
330
|
+
default:
|
|
331
|
+
return false;
|
|
332
|
+
} //switch
|
|
333
|
+
} //generateTestBasedSkin
|
|
334
|
+
|
|
335
|
+
getDocumentSkin(): DocumentSkin {
|
|
336
|
+
return this.documentSkin;
|
|
337
|
+
} //getDocumentSkin
|
|
338
|
+
}
|