@elisra-devops/docgen-skins 0.10.12 → 0.10.14
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/bin/index.d.ts +7 -7
- package/bin/index.js +150 -151
- package/bin/index.js.map +1 -1
- package/bin/models/json/table/JSONTableCell.js +55 -39
- package/bin/models/json/table/JSONTableCell.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +230 -212
- package/src/models/json/table/JSONTableCell.ts +50 -36
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"JSONTableCell.js","sourceRoot":"","sources":["../../../../src/models/json/table/JSONTableCell.ts"],"names":[],"mappings":";;;;;AAAA,+BAA+B;AAW/B,yDAAiC;AACjC,sEAA8C;AAE9C,MAAqB,aAAa;IAEhC,YACE,IAAgB,EAChB,WAAyB,EACzB,gBAAgB,GAAG,KAAK,EACxB,OAAO,GAAG,SAAS,EACnB,WAAW,GAAG,KAAK;QAEnB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,gBAAgB,CAAC,IAAI,EAAE,WAAW,EAAE,gBAAgB,EAAE,OAAO,EAAE,WAAW,CAAC,CAAC;IAC/F,CAAC;IAEO,mBAAmB,CAAC,QAAQ;QAClC,MAAM,YAAY,GAAG,QAAQ,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;QAC/C,IAAI,YAAY,GAAG,CAAC,EAAE;YACpB,OAAO,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,YAAY,CAAC,CAAC;SACxC;QACD,OAAO,QAAQ,CAAC,CAAC,yDAAyD;IAC5E,CAAC;IAED,gBAAgB,CACd,IAA0C,EAC1C,MAAM,EACN,gBAAgB,EAChB,OAAgB,EAChB,WAAW;QAEX,IAAI,IAAI,GAAU,EAAE,CAAC;QACrB,IAAI,WAAW,GAAiB,EAAE,CAAC;QACnC,IAAI,QAAQ,GAAW,EAAE,CAAC;QAC1B,iBAAiB;QACjB,IAAI,OAAO,IAAI,CAAC,K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;AA5IT,gCA4IC"}
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
DocumentSkin,
|
|
3
|
+
WIQueryResults,
|
|
4
|
+
WIData,
|
|
5
|
+
WIProperty,
|
|
6
|
+
StyleOptions,
|
|
7
|
+
Table,
|
|
8
|
+
} from './models/json/wordJsonModels';
|
|
2
9
|
import logger from './services/logger';
|
|
3
10
|
import JSONTable from './models/json/table/JSONTable';
|
|
4
11
|
import JSONParagraph from './models/json/paragraph/JSONParagraph';
|
|
@@ -37,24 +44,17 @@ export default class Skins {
|
|
|
37
44
|
includeAttachments: boolean = true,
|
|
38
45
|
insertPageBreak?: boolean,
|
|
39
46
|
isFlattened: boolean = false
|
|
40
|
-
): Promise<any> {
|
|
47
|
+
): Promise<any[]> {
|
|
41
48
|
try {
|
|
42
|
-
let populatedSkin;
|
|
49
|
+
let populatedSkin: any[] = [];
|
|
43
50
|
|
|
44
51
|
switch (skinType) {
|
|
45
52
|
case this.SKIN_TYPE_TABLE:
|
|
46
53
|
populatedSkin = this.generateQueryBasedTable(data, headerStyles, styles, headingLvl);
|
|
47
|
-
|
|
48
|
-
logger.error(`Could not generate table for content control :${contentControlTitle}`);
|
|
49
|
-
return false;
|
|
50
|
-
}
|
|
54
|
+
|
|
51
55
|
break;
|
|
52
56
|
case this.SKIN_TYPE_TRACE:
|
|
53
57
|
populatedSkin = this.generateTraceTable(data, headerStyles, styles, headingLvl);
|
|
54
|
-
if (populatedSkin === false) {
|
|
55
|
-
logger.error(`Could not generate table for content control :${contentControlTitle}`);
|
|
56
|
-
return false;
|
|
57
|
-
}
|
|
58
58
|
break;
|
|
59
59
|
case this.SKIN_TYPE_TABLE_STR:
|
|
60
60
|
const insertPageBreakEnabled: boolean = insertPageBreak ?? false;
|
|
@@ -66,17 +66,9 @@ export default class Skins {
|
|
|
66
66
|
insertPageBreakEnabled,
|
|
67
67
|
contentControlTitle
|
|
68
68
|
);
|
|
69
|
-
if (populatedSkin === false) {
|
|
70
|
-
logger.error(`Could not generate STR table for content control :${contentControlTitle}`);
|
|
71
|
-
return false;
|
|
72
|
-
}
|
|
73
69
|
break;
|
|
74
70
|
case this.SKIN_TYPE_PARAGRAPH:
|
|
75
71
|
populatedSkin = this.generateQueryBasedParagraphs(data, styles, headingLvl);
|
|
76
|
-
if (populatedSkin === false) {
|
|
77
|
-
logger.error(`Could not generate paragraph for content control :${contentControlTitle}`);
|
|
78
|
-
return false;
|
|
79
|
-
}
|
|
80
72
|
break;
|
|
81
73
|
case this.SKIN_TYPE_TEST_PLAN:
|
|
82
74
|
populatedSkin = this.generateTestBasedSkin(
|
|
@@ -87,17 +79,12 @@ export default class Skins {
|
|
|
87
79
|
includeAttachments,
|
|
88
80
|
isFlattened
|
|
89
81
|
);
|
|
90
|
-
if (populatedSkin === false) {
|
|
91
|
-
logger.error(`Could not generate test skin for content control :${contentControlTitle}`);
|
|
92
|
-
return false;
|
|
93
|
-
}
|
|
94
82
|
break;
|
|
95
83
|
case this.SKIN_TYPE_SYSTEM_OVERVIEW:
|
|
96
84
|
populatedSkin = this.generateSystemOverviewSkin(data, styles);
|
|
97
85
|
break;
|
|
98
86
|
default:
|
|
99
|
-
|
|
100
|
-
return false;
|
|
87
|
+
throw new Error(`Unknown skinType : ${skinType} - not appended to document skin`);
|
|
101
88
|
}
|
|
102
89
|
|
|
103
90
|
return populatedSkin;
|
|
@@ -109,8 +96,7 @@ export default class Skins {
|
|
|
109
96
|
} catch (error) {
|
|
110
97
|
logger.error(`Fatal error happened when generate skin for : ${contentControlTitle}`);
|
|
111
98
|
logger.error(`Error Message: ${error.message}`);
|
|
112
|
-
|
|
113
|
-
return false;
|
|
99
|
+
throw error;
|
|
114
100
|
}
|
|
115
101
|
} //addNewContentToDocumentSkin
|
|
116
102
|
|
|
@@ -160,7 +146,7 @@ export default class Skins {
|
|
|
160
146
|
headerStyles: StyleOptions,
|
|
161
147
|
styles: StyleOptions,
|
|
162
148
|
headingLvl: number = 0
|
|
163
|
-
) {
|
|
149
|
+
): Table[] {
|
|
164
150
|
logger.debug(`Generating table as ${this.skinFormat}`);
|
|
165
151
|
try {
|
|
166
152
|
switch (this.skinFormat) {
|
|
@@ -169,14 +155,13 @@ export default class Skins {
|
|
|
169
155
|
return [tableSkin.getJSONTable()];
|
|
170
156
|
case 'html':
|
|
171
157
|
logger.info(`Generating html table!`);
|
|
172
|
-
|
|
158
|
+
return [];
|
|
173
159
|
default:
|
|
174
|
-
|
|
160
|
+
throw new Error(`Invalid skin format ${this.skinFormat}`);
|
|
175
161
|
} //switch
|
|
176
162
|
} catch (error: any) {
|
|
177
163
|
logger.error(`Error occurred in generateQueryBasedTable: ${error.message}`);
|
|
178
|
-
|
|
179
|
-
return false;
|
|
164
|
+
throw error;
|
|
180
165
|
}
|
|
181
166
|
} //generateTable
|
|
182
167
|
|
|
@@ -194,7 +179,7 @@ export default class Skins {
|
|
|
194
179
|
headingLvl: number = 0,
|
|
195
180
|
insertPageBreak: boolean,
|
|
196
181
|
contentControlTitle: string
|
|
197
|
-
) {
|
|
182
|
+
): any[] {
|
|
198
183
|
logger.debug(`Generating table as ${this.skinFormat}`);
|
|
199
184
|
try {
|
|
200
185
|
switch (this.skinFormat) {
|
|
@@ -260,12 +245,11 @@ export default class Skins {
|
|
|
260
245
|
logger.info(`Generating html table!`);
|
|
261
246
|
break;
|
|
262
247
|
default:
|
|
263
|
-
|
|
248
|
+
throw new Error(`Invalid skin format ${this.skinFormat}`);
|
|
264
249
|
} //switch
|
|
265
250
|
} catch (error: any) {
|
|
266
251
|
logger.error(`Error occurred in generateStrBasedTable: ${error.message}`);
|
|
267
|
-
|
|
268
|
-
return false;
|
|
252
|
+
throw error;
|
|
269
253
|
}
|
|
270
254
|
} //generateTable
|
|
271
255
|
|
|
@@ -300,38 +284,56 @@ export default class Skins {
|
|
|
300
284
|
return testSkins;
|
|
301
285
|
}
|
|
302
286
|
|
|
303
|
-
generateQueryBasedParagraphs(data: any, styles: StyleOptions, headingLvl: number = 0) {
|
|
287
|
+
generateQueryBasedParagraphs(data: any, styles: StyleOptions, headingLvl: number = 0): any[] {
|
|
304
288
|
logger.debug(`Generating paragraph as ${this.skinFormat}`);
|
|
289
|
+
try {
|
|
290
|
+
switch (this.skinFormat) {
|
|
291
|
+
case 'json':
|
|
292
|
+
let paragraphs: any[] = [];
|
|
293
|
+
data.forEach((wi: WIData) => {
|
|
294
|
+
wi.fields.forEach((field: WIProperty) => {
|
|
295
|
+
//Description and Test Description are handled in richText handler
|
|
296
|
+
if (field.name === 'Description: ' || field.name === 'Test Description:') {
|
|
297
|
+
let paragraphSkin = new JSONRichTextParagraph(
|
|
298
|
+
field,
|
|
299
|
+
styles,
|
|
300
|
+
wi.Source,
|
|
301
|
+
headingLvl + wi.level
|
|
302
|
+
);
|
|
303
|
+
paragraphs.push(paragraphSkin.getJSONRichTextParagraph());
|
|
304
|
+
}
|
|
305
305
|
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
//making sure ID is not printed
|
|
318
|
-
//excluding Description and Test Description are handled in richText handler
|
|
319
|
-
if (field.name !== 'ID' && field.name !== 'Description: ' && field.name !== 'Test Description:') {
|
|
320
|
-
let paragraphSkin = new JSONParagraph(field, styles, wi.Source, headingLvl + wi.level);
|
|
321
|
-
paragraphs.push(paragraphSkin.getJSONParagraph());
|
|
322
|
-
}
|
|
306
|
+
//making sure ID is not printed
|
|
307
|
+
//excluding Description and Test Description are handled in richText handler
|
|
308
|
+
if (
|
|
309
|
+
field.name !== 'ID' &&
|
|
310
|
+
field.name !== 'Description: ' &&
|
|
311
|
+
field.name !== 'Test Description:'
|
|
312
|
+
) {
|
|
313
|
+
let paragraphSkin = new JSONParagraph(field, styles, wi.Source, headingLvl + wi.level);
|
|
314
|
+
paragraphs.push(paragraphSkin.getJSONParagraph());
|
|
315
|
+
}
|
|
316
|
+
});
|
|
323
317
|
});
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
}
|
|
318
|
+
return paragraphs;
|
|
319
|
+
case 'html':
|
|
320
|
+
logger.info(`Generating html paragraphs!`);
|
|
321
|
+
return [];
|
|
322
|
+
default:
|
|
323
|
+
throw new Error(`Invalid skin format ${this.skinFormat}`);
|
|
324
|
+
} //switch
|
|
325
|
+
} catch (error) {
|
|
326
|
+
logger.error(`Error occurred in generateQueryBasedParagraphs: ${error.message}`);
|
|
327
|
+
throw error;
|
|
328
|
+
}
|
|
332
329
|
} //generateParagraph
|
|
333
330
|
|
|
334
|
-
generateTraceTable(
|
|
331
|
+
generateTraceTable(
|
|
332
|
+
data: any,
|
|
333
|
+
headerStyles: StyleOptions,
|
|
334
|
+
styles: StyleOptions,
|
|
335
|
+
headingLvl: number = 0
|
|
336
|
+
): any[] {
|
|
335
337
|
logger.debug(`Generating table as ${this.skinFormat}`);
|
|
336
338
|
try {
|
|
337
339
|
switch (this.skinFormat) {
|
|
@@ -351,14 +353,13 @@ export default class Skins {
|
|
|
351
353
|
return traceSkin;
|
|
352
354
|
case 'html':
|
|
353
355
|
logger.info(`Generating html table!`);
|
|
354
|
-
|
|
356
|
+
return [];
|
|
355
357
|
default:
|
|
356
|
-
|
|
358
|
+
throw new Error(`Invalid skin format ${this.skinFormat}`);
|
|
357
359
|
} //switch
|
|
358
360
|
} catch (error: any) {
|
|
359
361
|
logger.error(`Error occurred in generateTraceTable: ${error.message}`);
|
|
360
|
-
|
|
361
|
-
return false;
|
|
362
|
+
throw error;
|
|
362
363
|
}
|
|
363
364
|
} //generateTraceTable
|
|
364
365
|
|
|
@@ -369,188 +370,205 @@ export default class Skins {
|
|
|
369
370
|
headingLvl: number = 0,
|
|
370
371
|
includeAttachments: boolean = true,
|
|
371
372
|
isFlattened = false
|
|
372
|
-
) {
|
|
373
|
+
): any[] {
|
|
373
374
|
logger.debug(`Generating testSkin as ${this.skinFormat}`);
|
|
374
|
-
|
|
375
|
-
case 'json':
|
|
376
|
-
let testSkin: any[] = [];
|
|
377
|
-
//create suite Header pragraph
|
|
378
|
-
data.forEach((testSuite: any) => {
|
|
379
|
-
let SuiteStyles = {
|
|
380
|
-
isBold: true,
|
|
381
|
-
IsItalic: false,
|
|
382
|
-
IsUnderline: false,
|
|
383
|
-
Size: 16,
|
|
384
|
-
Uri: null,
|
|
385
|
-
Font: 'Arial',
|
|
386
|
-
InsertLineBreak: false,
|
|
387
|
-
InsertSpace: true,
|
|
388
|
-
};
|
|
389
|
-
let testSuiteParagraphSkin = new JSONHeaderParagraph(
|
|
390
|
-
testSuite.suiteSkinData.fields,
|
|
391
|
-
SuiteStyles,
|
|
392
|
-
testSuite.suiteSkinData.id || 0,
|
|
393
|
-
testSuite.suiteSkinData.level
|
|
394
|
-
? headingLvl + testSuite.suiteSkinData.level
|
|
395
|
-
: headingLvl
|
|
396
|
-
? headingLvl
|
|
397
|
-
: 1
|
|
398
|
-
);
|
|
399
|
-
testSkin.push(testSuiteParagraphSkin.getJSONParagraph());
|
|
375
|
+
let aggregatedErrors: string[] = [];
|
|
400
376
|
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
377
|
+
try {
|
|
378
|
+
switch (this.skinFormat) {
|
|
379
|
+
case 'json':
|
|
380
|
+
let testSkin: any[] = [];
|
|
381
|
+
if (!data) {
|
|
382
|
+
throw new Error('No data provided to generate test based skin');
|
|
383
|
+
}
|
|
384
|
+
//create suite Header pragraph
|
|
385
|
+
data.forEach((testSuite: any) => {
|
|
386
|
+
let SuiteStyles = {
|
|
408
387
|
isBold: true,
|
|
409
388
|
IsItalic: false,
|
|
410
389
|
IsUnderline: false,
|
|
411
|
-
Size:
|
|
390
|
+
Size: 16,
|
|
412
391
|
Uri: null,
|
|
413
392
|
Font: 'Arial',
|
|
414
393
|
InsertLineBreak: false,
|
|
415
394
|
InsertSpace: true,
|
|
416
395
|
};
|
|
417
|
-
let
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
? headingLvl +
|
|
396
|
+
let testSuiteParagraphSkin = new JSONHeaderParagraph(
|
|
397
|
+
testSuite.suiteSkinData.fields,
|
|
398
|
+
SuiteStyles,
|
|
399
|
+
testSuite.suiteSkinData.id || 0,
|
|
400
|
+
testSuite.suiteSkinData.level
|
|
401
|
+
? headingLvl + testSuite.suiteSkinData.level
|
|
423
402
|
: headingLvl
|
|
424
403
|
? headingLvl
|
|
425
404
|
: 1
|
|
426
405
|
);
|
|
427
|
-
testSkin.push(
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
let tableSkin = new JSONTable(
|
|
457
|
-
testcase.testCaseRequirements,
|
|
458
|
-
headerStyles,
|
|
459
|
-
styles,
|
|
460
|
-
headingLvl
|
|
461
|
-
);
|
|
462
|
-
|
|
463
|
-
let populatedTableSkin = tableSkin.getJSONTable();
|
|
406
|
+
testSkin.push(testSuiteParagraphSkin.getJSONParagraph());
|
|
407
|
+
|
|
408
|
+
testSuite.testCases.forEach((testcase) => {
|
|
409
|
+
//create testcase Header paragraph
|
|
410
|
+
let testCaseHeaderFields = [
|
|
411
|
+
testcase.testCaseHeaderSkinData.fields[0],
|
|
412
|
+
testcase.testCaseHeaderSkinData.fields[1],
|
|
413
|
+
];
|
|
414
|
+
let TestCaseStyles = {
|
|
415
|
+
isBold: true,
|
|
416
|
+
IsItalic: false,
|
|
417
|
+
IsUnderline: false,
|
|
418
|
+
Size: 14,
|
|
419
|
+
Uri: null,
|
|
420
|
+
Font: 'Arial',
|
|
421
|
+
InsertLineBreak: false,
|
|
422
|
+
InsertSpace: true,
|
|
423
|
+
};
|
|
424
|
+
let testCaseParagraphSkin = new JSONHeaderParagraph(
|
|
425
|
+
testCaseHeaderFields,
|
|
426
|
+
TestCaseStyles,
|
|
427
|
+
testcase.id || 0,
|
|
428
|
+
testcase.testCaseHeaderSkinData.level
|
|
429
|
+
? headingLvl + testcase.testCaseHeaderSkinData.level
|
|
430
|
+
: headingLvl
|
|
431
|
+
? headingLvl
|
|
432
|
+
: 1
|
|
433
|
+
);
|
|
434
|
+
testSkin.push(testCaseParagraphSkin.getJSONParagraph());
|
|
464
435
|
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
436
|
+
let testDescriptionTitleParagraph = new JSONParagraph(
|
|
437
|
+
{ name: 'Title', value: 'Test Description:' },
|
|
438
|
+
DescriptionandProcedureStyle,
|
|
439
|
+
testcase.id || 0,
|
|
440
|
+
0
|
|
441
|
+
);
|
|
442
|
+
testSkin.push(testDescriptionTitleParagraph.getJSONParagraph());
|
|
468
443
|
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
testSkin.push(testDescriptionTitleParagraph.getJSONParagraph());
|
|
478
|
-
//create test steps table
|
|
479
|
-
let tableSkin = new JSONTable(testcase.testCaseBugs, headerStyles, styles, headingLvl);
|
|
444
|
+
let testDescriptionParagraph = new JSONRichTextParagraph(
|
|
445
|
+
testcase.testCaseHeaderSkinData.fields[2],
|
|
446
|
+
styles,
|
|
447
|
+
testcase.id || 0,
|
|
448
|
+
0
|
|
449
|
+
);
|
|
450
|
+
let richTextSkin: any[] = testDescriptionParagraph.getJSONRichTextParagraph();
|
|
451
|
+
testSkin = [...testSkin, ...richTextSkin];
|
|
480
452
|
|
|
481
|
-
|
|
453
|
+
if (testcase.testCaseRequirements) {
|
|
454
|
+
if (testcase.testCaseRequirements.length > 0) {
|
|
455
|
+
let testDescriptionTitleParagraph = new JSONParagraph(
|
|
456
|
+
{ name: 'Title', value: 'Covered Requirements:' },
|
|
457
|
+
DescriptionandProcedureStyle,
|
|
458
|
+
testcase.id || 0,
|
|
459
|
+
0
|
|
460
|
+
);
|
|
461
|
+
testSkin.push(testDescriptionTitleParagraph.getJSONParagraph());
|
|
462
|
+
//create test steps table
|
|
463
|
+
let tableSkin = new JSONTable(
|
|
464
|
+
testcase.testCaseRequirements,
|
|
465
|
+
headerStyles,
|
|
466
|
+
styles,
|
|
467
|
+
headingLvl
|
|
468
|
+
);
|
|
482
469
|
|
|
483
|
-
|
|
484
|
-
}
|
|
485
|
-
}
|
|
470
|
+
let populatedTableSkin = tableSkin.getJSONTable();
|
|
486
471
|
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
let testProcedureTitleParagraph = new JSONParagraph(
|
|
490
|
-
{ name: 'Title', value: 'Test Procedure:' },
|
|
491
|
-
DescriptionandProcedureStyle,
|
|
492
|
-
testcase.id || 0,
|
|
493
|
-
0
|
|
494
|
-
);
|
|
495
|
-
testSkin.push(testProcedureTitleParagraph.getJSONParagraph());
|
|
496
|
-
//create test steps table
|
|
497
|
-
let tableSkin = new JSONTable(
|
|
498
|
-
testcase.testCaseStepsSkinData,
|
|
499
|
-
headerStyles,
|
|
500
|
-
styles,
|
|
501
|
-
headingLvl,
|
|
502
|
-
undefined,
|
|
503
|
-
undefined,
|
|
504
|
-
isFlattened
|
|
505
|
-
);
|
|
506
|
-
let populatedTableSkin = tableSkin.getJSONTable();
|
|
507
|
-
testSkin.push(populatedTableSkin);
|
|
472
|
+
testSkin.push(populatedTableSkin);
|
|
473
|
+
}
|
|
508
474
|
}
|
|
509
|
-
} catch (error) {
|
|
510
|
-
logger.warn(
|
|
511
|
-
`For suite id : ${testSuite.suiteSkinData.fields[0].value} , the testCaseStepsSkinData is not defined for ${testcase.testCaseHeaderSkinData.fields[0].value} `
|
|
512
|
-
);
|
|
513
|
-
logger.warn(`data ${JSON.stringify(testcase.testCaseStepsSkinData)}`);
|
|
514
|
-
logger.error(`Error occurred when building test steps ${error.message}}`);
|
|
515
|
-
}
|
|
516
475
|
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
if (testcase.testCaseAttachments) {
|
|
520
|
-
if (testcase.testCaseAttachments.length > 0 && includeAttachments) {
|
|
476
|
+
if (testcase.testCaseBugs) {
|
|
477
|
+
if (testcase.testCaseBugs.length > 0) {
|
|
521
478
|
let testDescriptionTitleParagraph = new JSONParagraph(
|
|
522
|
-
{ name: 'Title', value: '
|
|
523
|
-
|
|
479
|
+
{ name: 'Title', value: 'Linked Bugs:' },
|
|
480
|
+
DescriptionandProcedureStyle,
|
|
524
481
|
testcase.id || 0,
|
|
525
482
|
0
|
|
526
483
|
);
|
|
527
484
|
testSkin.push(testDescriptionTitleParagraph.getJSONParagraph());
|
|
528
485
|
//create test steps table
|
|
486
|
+
let tableSkin = new JSONTable(testcase.testCaseBugs, headerStyles, styles, headingLvl);
|
|
529
487
|
|
|
488
|
+
let populatedTableSkin = tableSkin.getJSONTable();
|
|
489
|
+
|
|
490
|
+
testSkin.push(populatedTableSkin);
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
try {
|
|
495
|
+
if (testcase.testCaseStepsSkinData?.length > 0) {
|
|
496
|
+
let testProcedureTitleParagraph = new JSONParagraph(
|
|
497
|
+
{ name: 'Title', value: 'Test Procedure:' },
|
|
498
|
+
DescriptionandProcedureStyle,
|
|
499
|
+
testcase.id || 0,
|
|
500
|
+
0
|
|
501
|
+
);
|
|
502
|
+
testSkin.push(testProcedureTitleParagraph.getJSONParagraph());
|
|
503
|
+
//create test steps table
|
|
530
504
|
let tableSkin = new JSONTable(
|
|
531
|
-
testcase.
|
|
505
|
+
testcase.testCaseStepsSkinData,
|
|
532
506
|
headerStyles,
|
|
533
|
-
|
|
507
|
+
styles,
|
|
534
508
|
headingLvl,
|
|
535
|
-
|
|
509
|
+
undefined,
|
|
510
|
+
undefined,
|
|
511
|
+
isFlattened
|
|
536
512
|
);
|
|
537
513
|
let populatedTableSkin = tableSkin.getJSONTable();
|
|
538
514
|
testSkin.push(populatedTableSkin);
|
|
539
515
|
}
|
|
516
|
+
} catch (error) {
|
|
517
|
+
logger.warn(
|
|
518
|
+
`For suite id : ${testSuite.suiteSkinData.fields[0].value} , the testCaseStepsSkinData is not defined for ${testcase.testCaseHeaderSkinData.fields[0].value} `
|
|
519
|
+
);
|
|
520
|
+
logger.warn(`data ${JSON.stringify(testcase.testCaseStepsSkinData)}`);
|
|
521
|
+
logger.error(`Error occurred when building test steps ${error.message}}`);
|
|
522
|
+
aggregatedErrors.push(error.message);
|
|
540
523
|
}
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
524
|
+
|
|
525
|
+
//attachments table
|
|
526
|
+
try {
|
|
527
|
+
if (testcase.testCaseAttachments) {
|
|
528
|
+
if (testcase.testCaseAttachments.length > 0 && includeAttachments) {
|
|
529
|
+
let testDescriptionTitleParagraph = new JSONParagraph(
|
|
530
|
+
{ name: 'Title', value: 'Test Case Attachments:' },
|
|
531
|
+
styles,
|
|
532
|
+
testcase.id || 0,
|
|
533
|
+
0
|
|
534
|
+
);
|
|
535
|
+
testSkin.push(testDescriptionTitleParagraph.getJSONParagraph());
|
|
536
|
+
//create test steps table
|
|
537
|
+
|
|
538
|
+
let tableSkin = new JSONTable(
|
|
539
|
+
testcase.testCaseAttachments,
|
|
540
|
+
headerStyles,
|
|
541
|
+
{ ...styles, Font: 'Arial' },
|
|
542
|
+
headingLvl,
|
|
543
|
+
true
|
|
544
|
+
);
|
|
545
|
+
let populatedTableSkin = tableSkin.getJSONTable();
|
|
546
|
+
testSkin.push(populatedTableSkin);
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
} catch (error: any) {
|
|
550
|
+
logger.error(`Error occurred when building attachments ${error.message}}`);
|
|
551
|
+
aggregatedErrors.push(error.message);
|
|
552
|
+
}
|
|
553
|
+
});
|
|
545
554
|
});
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
555
|
+
return testSkin;
|
|
556
|
+
case 'html':
|
|
557
|
+
logger.info(`Generating html test data!`);
|
|
558
|
+
break;
|
|
559
|
+
default:
|
|
560
|
+
throw new Error(`Invalid skin format ${this.skinFormat}`);
|
|
561
|
+
} //switch
|
|
562
|
+
|
|
563
|
+
if (aggregatedErrors.length > 0) {
|
|
564
|
+
let errors = aggregatedErrors.join(', ');
|
|
565
|
+
logger.error(`Aggregated errors: ${errors}`);
|
|
566
|
+
throw new Error(errors);
|
|
567
|
+
}
|
|
568
|
+
} catch (error) {
|
|
569
|
+
logger.error(`One or more errors occurred in generateTestBasedSkin: ${error.message}`);
|
|
570
|
+
throw error;
|
|
571
|
+
}
|
|
554
572
|
} //generateTestBasedSkin
|
|
555
573
|
|
|
556
574
|
getDocumentSkin(): DocumentSkin {
|