@elisra-devops/docgen-skins 0.24.0 → 0.26.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.
Files changed (30) hide show
  1. package/.github/workflows/release.yml +22 -6
  2. package/Readme.md +11 -0
  3. package/bin/index.d.ts +7 -0
  4. package/bin/index.js +160 -2
  5. package/bin/index.js.map +1 -1
  6. package/bin/models/json/JSONRun.js +2 -0
  7. package/bin/models/json/JSONRun.js.map +1 -1
  8. package/bin/models/json/paragraph/JSONTestSuiteHeaderParagraph.js +3 -0
  9. package/bin/models/json/paragraph/JSONTestSuiteHeaderParagraph.js.map +1 -1
  10. package/bin/models/json/table/JSONTableCell.js +2 -0
  11. package/bin/models/json/table/JSONTableCell.js.map +1 -1
  12. package/bin/models/json/wordJsonModels.d.ts +5 -0
  13. package/bin/test/JSONTableCell.test.js +25 -0
  14. package/bin/test/JSONTableCell.test.js.map +1 -1
  15. package/bin/test/JSONTestSuiteHeaderParagraph.test.js +18 -0
  16. package/bin/test/JSONTestSuiteHeaderParagraph.test.js.map +1 -1
  17. package/bin/test/SkinsEdgeCases.test.js +41 -0
  18. package/bin/test/SkinsEdgeCases.test.js.map +1 -1
  19. package/bin/test/integration/skins.integration.test.js +41 -0
  20. package/bin/test/integration/skins.integration.test.js.map +1 -1
  21. package/package.json +1 -1
  22. package/src/index.ts +204 -2
  23. package/src/models/json/JSONRun.ts +2 -0
  24. package/src/models/json/paragraph/JSONTestSuiteHeaderParagraph.ts +4 -0
  25. package/src/models/json/table/JSONTableCell.ts +1 -0
  26. package/src/models/json/wordJsonModels.ts +5 -0
  27. package/src/test/JSONTableCell.test.ts +31 -0
  28. package/src/test/JSONTestSuiteHeaderParagraph.test.ts +24 -0
  29. package/src/test/SkinsEdgeCases.test.ts +51 -0
  30. package/src/test/integration/skins.integration.test.ts +52 -0
@@ -37,4 +37,28 @@ describe('JSONTestSuiteHeaderParagraph', () => {
37
37
  expect(json.headingLevel).toBe(2);
38
38
  expect(json.runs.length).toBeGreaterThan(0);
39
39
  });
40
+
41
+ test('emits bookmarkName when wiId is truthy', () => {
42
+ const fields: any[] = [{ name: 'Custom', value: 'Value' }];
43
+ const paragraph = new JSONTestSuiteHeaderParagraph(fields, { ...baseStyles }, 42, 2);
44
+ const json = paragraph.getJSONParagraph();
45
+
46
+ expect(json.bookmarkName).toBe('_WI42');
47
+ });
48
+
49
+ test('does not emit bookmarkName when wiId is 0 or falsy', () => {
50
+ const fields: any[] = [{ name: 'Custom', value: 'Value' }];
51
+ const paragraph = new JSONTestSuiteHeaderParagraph(fields, { ...baseStyles }, 0, 2);
52
+ const json = paragraph.getJSONParagraph();
53
+
54
+ expect(json.bookmarkName).toBeUndefined();
55
+ });
56
+
57
+ test('does not emit bookmarkName when wiId is undefined', () => {
58
+ const fields: any[] = [{ name: 'Custom', value: 'Value' }];
59
+ const paragraph = new JSONTestSuiteHeaderParagraph(fields, { ...baseStyles }, undefined as any, 2);
60
+ const json = paragraph.getJSONParagraph();
61
+
62
+ expect(json.bookmarkName).toBeUndefined();
63
+ });
40
64
  });
@@ -202,6 +202,57 @@ describe('Skins – edge cases and public API', () => {
202
202
  expect(groupedRow.Cells[0].gridSpan).toBeGreaterThan(0);
203
203
  });
204
204
 
205
+ test('generateTraceTable defaults to vertical merge enabled when the flag is omitted (SRS back-compat)', () => {
206
+ const skins = new Skins('json', 'c://template.dotx');
207
+
208
+ const buildRow = (nameValue: string) => ({
209
+ url: '',
210
+ level: 0,
211
+ Source: 1,
212
+ fields: [
213
+ { name: 'ID', value: 1 },
214
+ { name: 'Name', value: nameValue },
215
+ ],
216
+ });
217
+
218
+ const traceData = {
219
+ title: undefined,
220
+ adoptedData: [buildRow('Repeated'), buildRow('')],
221
+ errorMessage: null,
222
+ };
223
+
224
+ const result = skins.generateTraceTable(traceData as any, baseHeaderStyles as any, baseStyles as any, 0);
225
+ const table: any = result[0];
226
+
227
+ expect(table.Rows[2].Cells[1].vMerge).toBe('continue');
228
+ });
229
+
230
+ test('generateTraceTable does not merge when enableVerticalMerge is explicitly false', () => {
231
+ const skins = new Skins('json', 'c://template.dotx');
232
+
233
+ const buildRow = (nameValue: string) => ({
234
+ url: '',
235
+ level: 0,
236
+ Source: 1,
237
+ fields: [
238
+ { name: 'ID', value: 1 },
239
+ { name: 'Name', value: nameValue },
240
+ ],
241
+ });
242
+
243
+ const traceData = {
244
+ title: undefined,
245
+ adoptedData: [buildRow('Repeated'), buildRow('')],
246
+ errorMessage: null,
247
+ enableVerticalMerge: false,
248
+ };
249
+
250
+ const result = skins.generateTraceTable(traceData as any, baseHeaderStyles as any, baseStyles as any, 0);
251
+ const table: any = result[0];
252
+
253
+ expect(table.Rows[2].Cells[1].vMerge).toBeUndefined();
254
+ });
255
+
205
256
  test('generateTraceTable falls back to error paragraph when no adoptedData but errorMessage exists', () => {
206
257
  const skins = new Skins('json', 'c://template.dotx');
207
258
 
@@ -606,3 +606,55 @@ describe('Common functions - tests', () => {
606
606
  expect(hasHtml).toBe(true);
607
607
  });
608
608
  });
609
+
610
+ describe('Time machine report skin - tests', () => {
611
+ test('generate time-machine-report skin with compare summary and differences', async () => {
612
+ const skins = new Skins('json', 'c\\test\\test.dotx');
613
+ const result = await skins.addNewContentToDocumentSkin(
614
+ 'historical-compare-report-content-control',
615
+ skins.SKIN_TYPE_TIME_MACHINE,
616
+ {
617
+ teamProjectName: 'MEWP',
618
+ queryName: 'Shared Query',
619
+ compareResult: {
620
+ baseline: { asOf: '2025-12-22T17:08:00.000Z', total: 4 },
621
+ compareTo: { asOf: '2025-12-28T08:57:00.000Z', total: 4 },
622
+ summary: { updatedCount: 1 },
623
+ rows: [
624
+ {
625
+ id: 11,
626
+ workItemType: 'Requirement',
627
+ title: 'Req-11',
628
+ workItemUrl: 'https://dev.azure.com/org/project/_workitems/edit/11',
629
+ baselineRevisionId: 2,
630
+ compareToRevisionId: 20,
631
+ compareStatus: 'Changed',
632
+ differences: [{ field: 'Test Phase', baseline: 'FAT', compareTo: 'FAT; ATP' }],
633
+ },
634
+ ],
635
+ },
636
+ },
637
+ headerStyles,
638
+ styles,
639
+ 1,
640
+ );
641
+
642
+ expect(Array.isArray(result)).toBe(true);
643
+ expect(result.length).toBeGreaterThan(0);
644
+ expect(result.some((item: any) => item.type === 'table')).toBe(true);
645
+ expect(
646
+ result.some((item: any) => {
647
+ if (item?.type !== 'paragraph') return false;
648
+ const text = (item?.runs || []).map((run: any) => run?.text || '').join('');
649
+ return text.includes('Difference');
650
+ }),
651
+ ).toBe(true);
652
+ expect(
653
+ result.some((item: any) => {
654
+ if (item?.type !== 'paragraph') return false;
655
+ const text = (item?.runs || []).map((run: any) => run?.text || '').join('');
656
+ return text.includes('Work Item Differences');
657
+ }),
658
+ ).toBe(true);
659
+ });
660
+ });