@sun-asterisk/sungen 3.2.6 → 3.2.8

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 (105) hide show
  1. package/dist/cli/commands/delivery.d.ts +25 -0
  2. package/dist/cli/commands/delivery.d.ts.map +1 -1
  3. package/dist/cli/commands/delivery.js +30 -47
  4. package/dist/cli/commands/delivery.js.map +1 -1
  5. package/dist/dashboard/snapshot-builder.d.ts.map +1 -1
  6. package/dist/dashboard/snapshot-builder.js +28 -6
  7. package/dist/dashboard/snapshot-builder.js.map +1 -1
  8. package/dist/dashboard/templates/index.html +20 -20
  9. package/dist/dashboard/types.d.ts +18 -0
  10. package/dist/dashboard/types.d.ts.map +1 -1
  11. package/dist/exporters/api-catalog-loader.d.ts +18 -0
  12. package/dist/exporters/api-catalog-loader.d.ts.map +1 -0
  13. package/dist/exporters/api-catalog-loader.js +77 -0
  14. package/dist/exporters/api-catalog-loader.js.map +1 -0
  15. package/dist/exporters/api-testcase-formatter.d.ts.map +1 -1
  16. package/dist/exporters/api-testcase-formatter.js +80 -4
  17. package/dist/exporters/api-testcase-formatter.js.map +1 -1
  18. package/dist/exporters/csv-exporter.d.ts.map +1 -1
  19. package/dist/exporters/csv-exporter.js +6 -1
  20. package/dist/exporters/csv-exporter.js.map +1 -1
  21. package/dist/exporters/json-exporter.d.ts +10 -1
  22. package/dist/exporters/json-exporter.d.ts.map +1 -1
  23. package/dist/exporters/json-exporter.js +34 -2
  24. package/dist/exporters/json-exporter.js.map +1 -1
  25. package/dist/exporters/playwright-report-parser.d.ts +14 -0
  26. package/dist/exporters/playwright-report-parser.d.ts.map +1 -1
  27. package/dist/exporters/playwright-report-parser.js +30 -0
  28. package/dist/exporters/playwright-report-parser.js.map +1 -1
  29. package/dist/exporters/types.d.ts +5 -0
  30. package/dist/exporters/types.d.ts.map +1 -1
  31. package/dist/exporters/xlsx-exporter.d.ts +18 -17
  32. package/dist/exporters/xlsx-exporter.d.ts.map +1 -1
  33. package/dist/exporters/xlsx-exporter.js +25 -595
  34. package/dist/exporters/xlsx-exporter.js.map +1 -1
  35. package/dist/exporters/xlsx-report-builder.d.ts +196 -0
  36. package/dist/exporters/xlsx-report-builder.d.ts.map +1 -0
  37. package/dist/exporters/xlsx-report-builder.js +653 -0
  38. package/dist/exporters/xlsx-report-builder.js.map +1 -0
  39. package/dist/generators/test-generator/adapters/playwright/templates/steps/assertions/column-cell-assertion.hbs +3 -3
  40. package/dist/generators/test-generator/adapters/playwright/templates/steps/assertions/table-empty.hbs +1 -1
  41. package/dist/generators/test-generator/adapters/playwright/templates/steps/assertions/table-match-data.hbs +2 -2
  42. package/dist/generators/test-generator/adapters/playwright/templates/steps/assertions/table-row-count.hbs +1 -1
  43. package/dist/generators/test-generator/adapters/playwright/templates/steps/assertions/table-row-exists.hbs +2 -2
  44. package/dist/generators/test-generator/adapters/playwright/templates/steps/assertions/table-row-not-exists.hbs +2 -2
  45. package/dist/generators/test-generator/step-mapper.d.ts +6 -2
  46. package/dist/generators/test-generator/step-mapper.d.ts.map +1 -1
  47. package/dist/generators/test-generator/step-mapper.js +10 -6
  48. package/dist/generators/test-generator/step-mapper.js.map +1 -1
  49. package/dist/orchestrator/templates/ai-src/skills/sungen-api-design/SKILL.md +8 -0
  50. package/dist/orchestrator/templates/ai-src/skills/sungen-error-mapping/SKILL.md +12 -1
  51. package/dist/orchestrator/templates/ai-src/skills/sungen-selector-fix/SKILL.md +3 -0
  52. package/dist/orchestrator/templates/specs-api.d.ts +14 -2
  53. package/dist/orchestrator/templates/specs-api.d.ts.map +1 -1
  54. package/dist/orchestrator/templates/specs-api.js +38 -14
  55. package/dist/orchestrator/templates/specs-api.js.map +1 -1
  56. package/dist/orchestrator/templates/specs-api.ts +43 -14
  57. package/package.json +3 -3
  58. package/src/cli/commands/delivery.ts +32 -46
  59. package/src/dashboard/snapshot-builder.ts +31 -7
  60. package/src/dashboard/templates/index.html +20 -20
  61. package/src/dashboard/types.ts +19 -0
  62. package/src/exporters/api-catalog-loader.ts +44 -0
  63. package/src/exporters/api-testcase-formatter.ts +77 -4
  64. package/src/exporters/csv-exporter.ts +6 -1
  65. package/src/exporters/json-exporter.ts +46 -4
  66. package/src/exporters/playwright-report-parser.ts +27 -0
  67. package/src/exporters/types.ts +5 -0
  68. package/src/exporters/xlsx-exporter.ts +34 -658
  69. package/src/exporters/xlsx-report-builder.ts +806 -0
  70. package/src/generators/test-generator/adapters/playwright/templates/steps/assertions/column-cell-assertion.hbs +3 -3
  71. package/src/generators/test-generator/adapters/playwright/templates/steps/assertions/table-empty.hbs +1 -1
  72. package/src/generators/test-generator/adapters/playwright/templates/steps/assertions/table-match-data.hbs +2 -2
  73. package/src/generators/test-generator/adapters/playwright/templates/steps/assertions/table-row-count.hbs +1 -1
  74. package/src/generators/test-generator/adapters/playwright/templates/steps/assertions/table-row-exists.hbs +2 -2
  75. package/src/generators/test-generator/adapters/playwright/templates/steps/assertions/table-row-not-exists.hbs +2 -2
  76. package/src/generators/test-generator/step-mapper.ts +10 -6
  77. package/src/orchestrator/templates/ai-src/skills/sungen-api-design/SKILL.md +8 -0
  78. package/src/orchestrator/templates/ai-src/skills/sungen-error-mapping/SKILL.md +12 -1
  79. package/src/orchestrator/templates/ai-src/skills/sungen-selector-fix/SKILL.md +3 -0
  80. package/src/orchestrator/templates/specs-api.ts +43 -14
  81. package/dist/cli/types.d.ts +0 -9
  82. package/dist/cli/types.d.ts.map +0 -1
  83. package/dist/cli/types.js +0 -7
  84. package/dist/cli/types.js.map +0 -1
  85. package/dist/generators/gherkin-parser/selector-extractor.d.ts +0 -37
  86. package/dist/generators/gherkin-parser/selector-extractor.d.ts.map +0 -1
  87. package/dist/generators/gherkin-parser/selector-extractor.js +0 -108
  88. package/dist/generators/gherkin-parser/selector-extractor.js.map +0 -1
  89. package/dist/generators/test-generator/types.d.ts +0 -25
  90. package/dist/generators/test-generator/types.d.ts.map +0 -1
  91. package/dist/generators/test-generator/types.js +0 -7
  92. package/dist/generators/test-generator/types.js.map +0 -1
  93. package/dist/generators/types.d.ts +0 -119
  94. package/dist/generators/types.d.ts.map +0 -1
  95. package/dist/generators/types.js +0 -48
  96. package/dist/generators/types.js.map +0 -1
  97. package/dist/orchestrator/figma/node-path-collapser.d.ts +0 -16
  98. package/dist/orchestrator/figma/node-path-collapser.d.ts.map +0 -1
  99. package/dist/orchestrator/figma/node-path-collapser.js +0 -37
  100. package/dist/orchestrator/figma/node-path-collapser.js.map +0 -1
  101. package/src/cli/types.ts +0 -9
  102. package/src/generators/gherkin-parser/selector-extractor.ts +0 -142
  103. package/src/generators/test-generator/types.ts +0 -26
  104. package/src/generators/types.ts +0 -227
  105. package/src/orchestrator/figma/node-path-collapser.ts +0 -38
@@ -1,13 +1,16 @@
1
1
  "use strict";
2
2
  /**
3
- * Render the same rows/summary the CSV exporter produces into a styled .xlsx
4
- * workbook. Keeps the BM-2-901-13 layout but adds:
5
- * - bold header row with filled background + white font
6
- * - borders on the data region
7
- * - text wrapping in Steps / Expected / Pre-condition / Test Data
8
- * - frozen header so the first data rows stay aligned with the title row
9
- * - sensible column widths
10
- * - category-separator rows rendered as a filled bar spanning the table
3
+ * Node-side wrapper around the shared pure workbook builder
4
+ * (`xlsx-report-builder.ts` the single source of truth for the BM-2-901-13
5
+ * report rendering, also bundled into the dashboard). This module keeps only:
6
+ * - Node file I/O: `writeXlsx` + the `lockEmbeddedImages` post-process
7
+ * - the CLI version lookup (`getPackageVersion`, fs-based) injected as
8
+ * `opts.sungenVersion`
9
+ * - thin adapters mapping core domain types (ScreenSummary / TestCaseRow /
10
+ * LocaleSheet / ApiCatalogEntry) onto the builder input pure field
11
+ * mapping, no rendering logic.
12
+ * Public API is unchanged: `renderXlsx`, `renderXlsxMultiSheet`, `writeXlsx`,
13
+ * `buildApiDetailRows`, `addApiDetailSheet`, `ApiDetailContext`, `LocaleSheet`.
11
14
  */
12
15
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
13
16
  if (k2 === undefined) k2 = k;
@@ -46,614 +49,42 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
46
49
  return (mod && mod.__esModule) ? mod : { "default": mod };
47
50
  };
48
51
  Object.defineProperty(exports, "__esModule", { value: true });
52
+ exports.addApiDetailSheet = void 0;
49
53
  exports.renderXlsx = renderXlsx;
50
54
  exports.renderXlsxMultiSheet = renderXlsxMultiSheet;
51
55
  exports.buildApiDetailRows = buildApiDetailRows;
52
- exports.addApiDetailSheet = addApiDetailSheet;
53
56
  exports.writeXlsx = writeXlsx;
54
57
  exports.lockEmbeddedImages = lockEmbeddedImages;
55
58
  const fs = __importStar(require("fs"));
56
59
  const path = __importStar(require("path"));
57
- const exceljs_1 = __importDefault(require("exceljs"));
58
60
  const jszip_1 = __importDefault(require("jszip"));
59
61
  const package_info_1 = require("./package-info");
60
- const sun_logo_1 = require("./sun-logo");
61
62
  const csv_exporter_1 = require("./csv-exporter");
62
63
  const feature_parser_1 = require("./feature-parser");
63
- const COL_COUNT = 16;
64
- const HEADER_FILL = 'FFD9D2E9'; // lavender matches the summary-header band on row 6
65
- const HEADER_FONT = 'FF000000'; // black text reads better on the light lavender
66
- const META_FILL = 'FFDCE6F1'; // soft blue for meta rows
67
- const CATEGORY_FILL = 'FFD9D2E9'; // same lavender for group dividers (Accessing / GUI / Function)
68
- const BORDER_COLOR = 'FFBFBFBF';
69
- // Shared masthead + table styling (BM-2-901-13 header band, summary band, Overview table).
70
- const TIMES = 'Times New Roman';
71
- const ARIAL_FONT = 'Arial';
72
- const BLACK = { argb: 'FF000000' };
73
- const WHITE = { argb: 'FFFFFFFF' };
74
- const LAVENDER = { argb: 'FFD9D2E9' };
75
- const thinBlack = { style: 'thin', color: BLACK };
76
- const allBordersBlack = { top: thinBlack, left: thinBlack, bottom: thinBlack, right: thinBlack };
77
- function applyBorder(cell) {
78
- cell.border = {
79
- top: { style: 'thin', color: { argb: BORDER_COLOR } },
80
- left: { style: 'thin', color: { argb: BORDER_COLOR } },
81
- bottom: { style: 'thin', color: { argb: BORDER_COLOR } },
82
- right: { style: 'thin', color: { argb: BORDER_COLOR } },
83
- };
84
- }
64
+ const xlsx_report_builder_1 = require("./xlsx-report-builder");
65
+ Object.defineProperty(exports, "addApiDetailSheet", { enumerable: true, get: function () { return xlsx_report_builder_1.addApiDetailSheet; } });
85
66
  function renderXlsx(summary, rows, specLink, apiDetail) {
86
- const wb = new exceljs_1.default.Workbook();
87
- wb.creator = 'sungen delivery';
88
- wb.created = new Date();
89
- addTestcaseSheet(wb, 'Testcases', summary, rows, specLink);
90
- if (apiDetail) {
91
- addApiDetailSheet(wb, apiDetail.rows);
92
- }
93
- return wb;
67
+ return (0, xlsx_report_builder_1.buildSingleTestcaseWorkbook)({ sheetName: 'Testcases', summary, rows, specLink }, apiDetail, { sungenVersion: (0, package_info_1.getPackageVersion)() });
94
68
  }
95
69
  function renderXlsxMultiSheet(sheets) {
96
- if (sheets.length === 0) {
97
- throw new Error('renderXlsxMultiSheet requires at least one locale sheet');
98
- }
99
- const wb = new exceljs_1.default.Workbook();
100
- wb.creator = 'sungen delivery';
101
- wb.created = new Date();
102
- // Overview first — a per-sheet roll-up (Passed/Failed/Pending/N/A/Remain/Total)
103
- // plus a grand-total row, so QA sees the whole picture before the detail sheets.
104
- addOverviewSheet(wb, sheets);
105
- for (const s of sheets) {
106
- addTestcaseSheet(wb, s.sheetName, s.summary, s.rows, s.specLink);
107
- }
108
- return wb;
109
- }
110
- /**
111
- * Render the shared BM-2-901-13 masthead (rows 1-4) onto a worksheet:
112
- * Sun* logo (A1:C3), TESTCASE title (D1:F3), No/Version/Issue-Date block
113
- * (G1:H3), company line (A4:F4), ISO line (G4:H4). Every sheet in a delivery
114
- * workbook — Overview, Auto, Manual — carries this same header band.
115
- */
116
- function renderReportHeaderBand(wb, ws, titleLabel) {
117
- const issueDate = (() => {
118
- const d = new Date();
119
- return `${String(d.getDate()).padStart(2, '0')}/${String(d.getMonth() + 1).padStart(2, '0')}/${d.getFullYear()}`;
120
- })();
121
- // Ensure rows 1..4 exist before merging.
122
- for (let r = 1; r <= 4; r++)
123
- ws.getRow(r);
124
- ws.mergeCells('A1:C3');
125
- ws.mergeCells('D1:F3');
126
- ws.mergeCells('G1:H1');
127
- ws.mergeCells('G2:H2');
128
- ws.mergeCells('G3:H3');
129
- ws.mergeCells('A4:F4');
130
- ws.mergeCells('G4:H4');
131
- // A1 (logo band, merged A1:C3) — border + embedded Sun* logo (base64 inline).
132
- const a1 = ws.getCell('A1');
133
- a1.alignment = { horizontal: 'center', vertical: 'middle' };
134
- a1.border = allBordersBlack;
135
- try {
136
- const imageId = wb.addImage({
137
- buffer: Buffer.from(sun_logo_1.SUN_LOGO_PNG_BASE64, 'base64'),
138
- extension: 'png',
139
- });
140
- // Centre a fixed-size 90×51 logo inside A1:C3 using absolute EMU offsets.
141
- ws.addImage(imageId, {
142
- tl: { nativeCol: 0, nativeColOff: 1237500, nativeRow: 0, nativeRowOff: 42862 },
143
- ext: { width: 90, height: 51 },
144
- editAs: 'oneCell',
145
- });
146
- }
147
- catch { /* logo is decorative — never block export */ }
148
- // D1 (TESTCASE title)
149
- const d1 = ws.getCell('D1');
150
- d1.value = titleLabel;
151
- d1.font = { bold: true, size: 18, name: TIMES };
152
- d1.alignment = { horizontal: 'center', vertical: 'middle', wrapText: true };
153
- d1.border = allBordersBlack;
154
- // G1 — No: BM-2-901-13
155
- const g1 = ws.getCell('G1');
156
- g1.value = 'No: BM-2-901-13';
157
- g1.font = { size: 12, name: TIMES };
158
- g1.alignment = { vertical: 'middle' };
159
- g1.border = { top: thinBlack, left: thinBlack, right: thinBlack };
160
- // G2 — Version
161
- const g2 = ws.getCell('G2');
162
- g2.value = `Version: ${(0, package_info_1.getPackageVersion)()}`;
163
- g2.font = { size: 12, name: TIMES };
164
- g2.alignment = { vertical: 'middle' };
165
- g2.border = { left: thinBlack, right: thinBlack };
166
- // G3 — Issue Date
167
- const g3 = ws.getCell('G3');
168
- g3.value = `Issue Date: ${issueDate}`;
169
- g3.font = { size: 12, name: TIMES };
170
- g3.alignment = { vertical: 'middle' };
171
- g3.border = { left: thinBlack, right: thinBlack, bottom: thinBlack };
172
- // A4 — SUN ASTERISK VIETNAM CO., LTD
173
- const a4 = ws.getCell('A4');
174
- a4.value = 'SUN ASTERISK VIETNAM CO., LTD';
175
- a4.font = { bold: true, size: 10, name: TIMES };
176
- a4.alignment = { vertical: 'middle' };
177
- a4.border = allBordersBlack;
178
- // G4 — ISO/IEC ...
179
- const g4 = ws.getCell('G4');
180
- g4.value = 'ISO/IEC 27001:2022 & ISO 9001:2015';
181
- g4.font = { bold: true, size: 10, name: TIMES };
182
- g4.alignment = { horizontal: 'right', vertical: 'middle', wrapText: true };
183
- g4.border = allBordersBlack;
184
- }
185
- // ---------------------------------------------------------------------------
186
- // Overview sheet — the first tab in every multi-sheet delivery workbook.
187
- // Rolls up each testcase sheet's Passed/Failed/Pending/N/A/Remain/Total into
188
- // one summary table (+ a grand-total row) under the shared masthead. Reads
189
- // only each sheet's summary — never touches the detail sheets themselves.
190
- // ---------------------------------------------------------------------------
191
- /** Column headers for the Overview roll-up table (cols A..H). */
192
- const OVERVIEW_HEADERS = ['#', 'Sheet name', 'Passed', 'Failed', 'Pending', 'N/A', 'Remain', 'Total'];
193
- /**
194
- * Prepend an "Overview" worksheet summarizing every sheet in `sheets`.
195
- *
196
- * `Remain = Total − Passed − N/A` (i.e. Failed + Pending) so the number
197
- * reconciles with the "Remaining" cell in each detail sheet's summary band.
198
- */
199
- function addOverviewSheet(wb, sheets) {
200
- const ws = wb.addWorksheet('Overview');
201
- // Table starts at column B row 7 (A is a thin left margin). Widths keep the
202
- // A..H masthead readable AND the count columns tidy.
203
- ws.columns = [
204
- { width: 4 }, // A — left margin
205
- { width: 6 }, // B — #
206
- { width: 26 }, // C — Sheet name
207
- { width: 13 }, // D — Passed
208
- { width: 13 }, // E — Failed
209
- { width: 13 }, // F — Pending
210
- { width: 13 }, // G — N/A
211
- { width: 13 }, // H — Remain
212
- { width: 13 }, // I — Total
213
- ];
214
- const titleScreen = sheets[0]?.summary.screen ?? '';
215
- renderReportHeaderBand(wb, ws, `${titleScreen.toUpperCase()} TESTCASE`);
216
- // Roll-up table: header on row 7, first column B (index 2).
217
- const HEADER_ROW = 7;
218
- const FIRST_COL = 2; // column B
219
- const headerRow = ws.getRow(HEADER_ROW);
220
- headerRow.height = 20;
221
- OVERVIEW_HEADERS.forEach((label, i) => {
222
- const c = headerRow.getCell(FIRST_COL + i);
223
- c.value = label;
224
- c.font = { bold: true, size: 10, color: BLACK, name: ARIAL_FONT };
225
- c.fill = { type: 'pattern', pattern: 'solid', fgColor: LAVENDER };
226
- c.alignment = { horizontal: 'center', vertical: 'middle', wrapText: true };
227
- c.border = allBordersBlack;
228
- });
229
- const totals = { passed: 0, failed: 0, pending: 0, na: 0, remain: 0, total: 0 };
230
- const writeDataRow = (rowIdx, values, isTotal) => {
231
- const row = ws.getRow(rowIdx);
232
- values.forEach((v, i) => {
233
- const c = row.getCell(FIRST_COL + i);
234
- c.value = v;
235
- c.font = { bold: isTotal, size: 10, color: BLACK, name: ARIAL_FONT };
236
- // The '#' + 'Sheet name' columns read left; the counts centre like the band.
237
- c.alignment = { horizontal: i <= 1 ? 'left' : 'center', vertical: 'middle' };
238
- c.border = allBordersBlack;
239
- if (isTotal)
240
- c.fill = { type: 'pattern', pattern: 'solid', fgColor: LAVENDER };
241
- });
242
- };
243
- // Each detail sheet carries a LIVE summary band (row 7): C7 Total · D7 Passed · E7 Failed ·
244
- // F7 Pending · G7 N/A · H7 Remaining, all COUNTA/COUNTIF over the data area. The Overview
245
- // REFERENCES those cells (`='<sheet>'!D7`) instead of freezing a number at export time — so when
246
- // QA adds/edits/removes a row in the Auto or Manual sheet, the roll-up recomputes automatically.
247
- const qname = (name) => name.replace(/'/g, "''"); // Excel escapes ' by doubling
248
- const ref = (name, cell, result) => ({ formula: `'${qname(name)}'!${cell}`, result });
249
- let rowIdx = HEADER_ROW + 1;
250
- const firstDataRow = rowIdx;
251
- sheets.forEach((s, i) => {
252
- const su = s.summary;
253
- const remain = Math.max(0, su.total - su.passed - su.na);
254
- writeDataRow(rowIdx, [
255
- i + 1,
256
- s.sheetName,
257
- ref(s.sheetName, 'D7', su.passed),
258
- ref(s.sheetName, 'E7', su.failed),
259
- ref(s.sheetName, 'F7', su.pending),
260
- ref(s.sheetName, 'G7', su.na),
261
- ref(s.sheetName, 'H7', remain),
262
- ref(s.sheetName, 'C7', su.total),
263
- ], false);
264
- totals.passed += su.passed;
265
- totals.failed += su.failed;
266
- totals.pending += su.pending;
267
- totals.na += su.na;
268
- totals.remain += remain;
269
- totals.total += su.total;
270
- rowIdx += 1;
271
- });
272
- const lastDataRow = rowIdx - 1;
273
- // Grand total = SUM of the per-sheet Overview cells (also live — recomputes with the references
274
- // above). Overview count columns are D..I (Passed·Failed·Pending·N/A·Remain·Total).
275
- const sumCol = (col, result) => ({ formula: `SUM(${col}${firstDataRow}:${col}${lastDataRow})`, result });
276
- writeDataRow(rowIdx, [
277
- '', 'Total',
278
- sumCol('D', totals.passed),
279
- sumCol('E', totals.failed),
280
- sumCol('F', totals.pending),
281
- sumCol('G', totals.na),
282
- sumCol('H', totals.remain),
283
- sumCol('I', totals.total),
284
- ], true);
285
- }
286
- /**
287
- * Append one BM-2-901-13 testcase sheet to the given workbook. Sheet content
288
- * (layout, summary band, data rows, auto-filter, protection) is identical to
289
- * the single-sheet `renderXlsx` output — only the sheet name differs.
290
- */
291
- function addTestcaseSheet(wb, sheetName, summary, rows, specLink) {
292
- const ws = wb.addWorksheet(sheetName, {
293
- views: [{ state: 'frozen', ySplit: 0, xSplit: 0 }],
294
- });
295
- // -- Column widths matching template_report.xlsx (Sample sheet) --
296
- ws.columns = [
297
- { width: 20 }, // A — TC ID (wider to fit long flow IDs like FLOW-KUDO-…)
298
- { width: 12.5 }, // B — Screen/Function
299
- { width: 15.38 }, // C — Big item
300
- { width: 16.25 }, // D — Medium item
301
- { width: 17 }, // E — Test Object
302
- { width: 25.5 }, // F — Pre-condition
303
- { width: 24.88 }, // G — Test Data
304
- { width: 50 }, // H — Steps (widened ~2× — steps are the longest cell)
305
- { width: 41 }, // I — Expected results
306
- { width: 12 }, // J — Priority
307
- { width: 13.5 }, // K — Testcase type
308
- { width: 15.88 }, // L — Test Result
309
- { width: 13.5 }, // M — Executed Date
310
- { width: 16.5 }, // N — Test Executor
311
- { width: 23 }, // O — Test Environment
312
- { width: 29 }, // P — Note
313
- ];
314
- // -- Top metadata band (rows 1-4) — shared BM-2-901-13 masthead --
315
- renderReportHeaderBand(wb, ws, `${summary.screen.toUpperCase()} TESTCASE`);
316
- // Materialize rows 5..8 so the summary band + row-9 spacer land at the right offsets.
317
- for (let r = 5; r <= 8; r++)
318
- ws.getRow(r);
319
- // -- Row 5: spacer (height auto-fit). --
320
- // -- Row 6: Summary headers (cols C..H), lavender fill --
321
- const sumLabels = {
322
- C: 'Total TCs', D: 'Passed', E: 'Failed', F: 'Pending', G: 'N/A', H: 'Remaining',
323
- };
324
- for (const [col, label] of Object.entries(sumLabels)) {
325
- const c = ws.getCell(`${col}6`);
326
- c.value = label;
327
- c.font = { bold: true, size: 10, color: BLACK, name: ARIAL_FONT };
328
- c.fill = { type: 'pattern', pattern: 'solid', fgColor: LAVENDER };
329
- c.alignment = { horizontal: 'center', vertical: 'top' };
330
- c.border = allBordersBlack;
331
- }
332
- // No explicit height → Excel auto-fits this row's content.
333
- // -- Row 7: Counts (cols C..H), live formulas referencing the data area --
334
- // The data region begins at row 14 — the row immediately AFTER the column-header row (row 13).
335
- // Start the ranges there (NOT row 15): the first category divider usually sits at row 14 with a
336
- // BLANK col A (so COUNTA skips it), but a sheet whose first row after the header is real data —
337
- // no leading divider — would be UNDER-counted by a range that started at 15. Row 14 covers both.
338
- const COUNT_RANGE_START = 14;
339
- const COUNT_RANGE_END = 10000;
340
- const r7Values = {
341
- C: { formula: `COUNTA(A${COUNT_RANGE_START}:A${COUNT_RANGE_END})`, result: summary.total },
342
- D: { formula: `COUNTIF(L${COUNT_RANGE_START}:L${COUNT_RANGE_END},"Passed")`, result: summary.passed },
343
- E: { formula: `COUNTIF(L${COUNT_RANGE_START}:L${COUNT_RANGE_END},"Failed")`, result: summary.failed },
344
- F: { formula: `COUNTIF(L${COUNT_RANGE_START}:L${COUNT_RANGE_END},"Pending")`, result: summary.pending },
345
- G: { formula: `COUNTIF(L${COUNT_RANGE_START}:L${COUNT_RANGE_END},"N/A")`, result: summary.na },
346
- H: { formula: 'C7-D7-G7', result: summary.failed + summary.pending },
347
- };
348
- for (const [col, val] of Object.entries(r7Values)) {
349
- const c = ws.getCell(`${col}7`);
350
- c.value = val;
351
- c.font = { size: 10, color: BLACK, name: ARIAL_FONT };
352
- c.fill = { type: 'pattern', pattern: 'solid', fgColor: WHITE };
353
- c.alignment = { horizontal: 'center', vertical: 'top' };
354
- c.border = allBordersBlack;
355
- if (col === 'H')
356
- c.numFmt = '#,##0';
357
- }
358
- // No explicit height → Excel auto-fits.
359
- // C8 has no value in the template but still needs a border so the band
360
- // visually closes underneath "Total TCs".
361
- const c8 = ws.getCell('C8');
362
- c8.font = { size: 10, color: BLACK, name: ARIAL_FONT };
363
- c8.fill = { type: 'pattern', pattern: 'solid', fgColor: WHITE };
364
- c8.alignment = { horizontal: 'center', vertical: 'top' };
365
- c8.border = allBordersBlack;
366
- // -- Row 8: Percentages (cols D..H), formula = count / (Total − N/A) --
367
- const r8Values = {
368
- D: { formula: 'IFERROR(D7/(C7-G7),0)', result: summary.passed / Math.max(1, summary.total - summary.na) },
369
- E: { formula: 'IFERROR(E7/(C7-G7),0)', result: summary.failed / Math.max(1, summary.total - summary.na) },
370
- F: { formula: 'IFERROR(F7/(C7-G7),0)', result: summary.pending / Math.max(1, summary.total - summary.na) },
371
- G: { formula: 'IFERROR(G7/(C7-G7),0)', result: summary.na / Math.max(1, summary.total - summary.na) },
372
- H: { formula: 'IFERROR(H7/(C7-G7),0)', result: (summary.failed + summary.pending) / Math.max(1, summary.total - summary.na) },
373
- };
374
- for (const [col, val] of Object.entries(r8Values)) {
375
- const c = ws.getCell(`${col}8`);
376
- c.value = val;
377
- c.font = { size: 10, color: BLACK, name: ARIAL_FONT };
378
- c.fill = { type: 'pattern', pattern: 'solid', fgColor: WHITE };
379
- c.alignment = { horizontal: 'center', vertical: 'top' };
380
- c.border = allBordersBlack;
381
- c.numFmt = '0%';
382
- }
383
- // No explicit height → Excel auto-fits.
384
- // After rows 1-8 are populated, append a blank row 9 spacer.
385
- while (ws.rowCount < 9)
386
- ws.addRow([]);
387
- const specRow = ws.addRow(['Spec/Design link:', specLink]);
388
- specRow.getCell(1).font = { bold: true };
389
- specRow.getCell(2).font = { color: { argb: 'FF1F4E78' }, underline: true };
390
- ws.addRow([]); // spacer
391
- const legendRow = ws.addRow(['*: Mandatory']);
392
- legendRow.getCell(1).font = { italic: true, color: { argb: 'FF808080' } };
393
- // -- Column header row (bold, filled, wrapped) --
394
- const headerRow = ws.addRow([
395
- 'TC ID*',
396
- 'Screen/Function',
397
- 'Big item',
398
- 'Medium item',
399
- 'Test Object',
400
- 'Pre-condition',
401
- 'Test Data',
402
- 'Steps*',
403
- 'Expected results*',
404
- 'Priority',
405
- 'Testcase type',
406
- 'Test Result*',
407
- 'Executed Date*',
408
- 'Test Executor*',
409
- 'Test Environment',
410
- 'Note\n(Test evidence, DefectID, Actual result)',
411
- ]);
412
- headerRow.height = 38;
413
- headerRow.eachCell((cell) => {
414
- cell.font = { bold: true, color: { argb: HEADER_FONT } };
415
- cell.fill = { type: 'pattern', pattern: 'solid', fgColor: { argb: HEADER_FILL } };
416
- cell.alignment = { horizontal: 'center', vertical: 'middle', wrapText: true };
417
- applyBorder(cell);
418
- });
419
- // No freeze — the whole sheet scrolls freely (the masthead + summary band + header scroll away
420
- // with the data). QA asked for this so the wide Steps/Expected columns aren't pinned under a frozen
421
- // header on smaller screens.
422
- ws.views = [{ state: 'normal' }];
423
- // -- Data rows grouped by category --
424
- const order = ['Accessing', 'GUI', 'Function'];
425
- const grouped = new Map();
426
- for (const r of rows) {
427
- const g = grouped.get(r.category2) || [];
428
- g.push(r);
429
- grouped.set(r.category2, g);
430
- }
431
- const emittedGroups = new Set();
432
- function emitGroup(groupName, groupRows) {
433
- // Column A (TC ID) must stay TRULY blank on a divider — never write '' here. COUNTA counts
434
- // empty-string cells, so an '' in A made the generated total (=COUNTA(A15:A…)) over-count by
435
- // one per group divider when recalculated (e.g. in Google Sheets). Set only the group name in B;
436
- // the lavender band still spans every column via the fill loop below (style only, no value).
437
- const divider = ws.addRow([]);
438
- divider.getCell(2).value = groupName;
439
- divider.getCell(2).font = { bold: true };
440
- divider.eachCell({ includeEmpty: false }, (cell) => {
441
- cell.fill = { type: 'pattern', pattern: 'solid', fgColor: { argb: CATEGORY_FILL } };
442
- });
443
- // Fill the full width so the band spans the whole table
444
- for (let i = 1; i <= COL_COUNT; i++) {
445
- const c = divider.getCell(i);
446
- c.fill = { type: 'pattern', pattern: 'solid', fgColor: { argb: CATEGORY_FILL } };
447
- applyBorder(c);
448
- }
449
- for (const r of groupRows) {
450
- const row = ws.addRow([
451
- r.tcId,
452
- '',
453
- '',
454
- '',
455
- r.category1,
456
- r.precondition,
457
- r.testData,
458
- r.steps,
459
- r.expectedResults,
460
- r.priority,
461
- r.testcaseType,
462
- r.testResult,
463
- r.executedDate,
464
- r.testExecutor,
465
- r.testEnvironment,
466
- r.note,
467
- ]);
468
- row.alignment = { vertical: 'top', wrapText: true };
469
- row.eachCell({ includeEmpty: true }, (cell, colNumber) => {
470
- applyBorder(cell);
471
- if (colNumber === 1) {
472
- cell.font = { bold: true };
473
- }
474
- if (colNumber === 12) {
475
- // Test Result — colour-code
476
- const val = String(cell.value || '');
477
- if (val === 'Passed') {
478
- cell.font = { color: { argb: 'FF107C41' }, bold: true };
479
- }
480
- else if (val === 'Failed') {
481
- cell.font = { color: { argb: 'FFC00000' }, bold: true };
482
- }
483
- else if (val === 'Pending') {
484
- cell.font = { color: { argb: 'FF996D00' }, bold: true };
485
- }
486
- else if (val === 'N/A') {
487
- cell.font = { color: { argb: 'FF808080' } };
488
- }
489
- }
490
- });
491
- }
492
- }
493
- for (const groupName of order) {
494
- const groupRows = grouped.get(groupName);
495
- if (!groupRows || groupRows.length === 0)
496
- continue;
497
- emittedGroups.add(groupName);
498
- emitGroup(groupName, groupRows);
499
- }
500
- for (const [groupName, groupRows] of grouped.entries()) {
501
- if (emittedGroups.has(groupName))
502
- continue;
503
- emitGroup(groupName, groupRows);
504
- }
505
- // Auto-filter on the header row so QA can filter by result / priority / category
506
- ws.autoFilter = {
507
- from: { row: headerRow.number, column: 1 },
508
- to: { row: ws.rowCount, column: COL_COUNT },
509
- };
510
- // Sheet protection lets the picLocks on the embedded logo take effect
511
- // (Excel honours image locks only when the sheet is protected). Empty
512
- // password — QA can run Review → Unprotect Sheet if they need to edit.
513
- // `objects: false` here is ExcelJS's inverted semantic that writes
514
- // `objects="1"` in XML (= objects ARE locked).
515
- ws.sheetProtection = {
516
- sheet: true,
517
- objects: false,
518
- scenarios: false,
519
- };
70
+ return (0, xlsx_report_builder_1.buildTestcaseWorkbook)(sheets, { sungenVersion: (0, package_info_1.getPackageVersion)() });
520
71
  }
521
- // ---------------------------------------------------------------------------
522
- // API detail sheet (api-kind units only)
523
- // Second worksheet appended after Testcases — never alters the Testcases sheet.
524
- // ---------------------------------------------------------------------------
525
- const API_DETAIL_HEADER_FILL = 'FF2E5984'; // dark blue header for differentiation
526
- const API_DETAIL_HEADER_FONT = 'FFFFFFFF'; // white text on dark header
527
72
  /**
528
73
  * Build ApiDetailRow[] from the apis.yaml catalog + feature-level annotations.
529
74
  * Called once per feature file for api-kind units in the delivery pipeline.
530
75
  *
76
+ * Delegates to the pure builder, injecting the feature-parser tag extractors
77
+ * (the builder cannot import feature-parser — it must stay browser-safe).
78
+ *
531
79
  * @param catalog Parsed apis.yaml keyed by endpoint name
532
80
  * @param scenarios Scenario-level tag arrays from parseFeatureMetadata().scenarios
533
81
  */
534
82
  function buildApiDetailRows(catalog, scenarios) {
535
- const rows = [];
536
- for (const [endpointName, entry] of Object.entries(catalog)) {
537
- const method = (entry.method ?? '').toUpperCase();
538
- const endpoint = entry.path ?? endpointName;
539
- const datasource = entry.datasource ?? '';
540
- // Auth: look for @auth: tag in any scenario that calls this endpoint.
541
- const authTags = scenarios.flatMap((s) => {
542
- const calls = (0, feature_parser_1.extractApiCallOrder)(s.tags);
543
- if (!calls.includes(endpointName))
544
- return [];
545
- return s.tags.filter((t) => t.startsWith('@auth:'));
546
- });
547
- const uniqueAuth = [...new Set(authTags.map((t) => t.slice('@auth:'.length)))];
548
- const authDatasource = [datasource, ...uniqueAuth].filter(Boolean).join('; ');
549
- // Request shape: compose from body + params + encoding.
550
- const bodyStr = entry.body
551
- ? `body: ${typeof entry.body === 'string' ? entry.body : JSON.stringify(entry.body)}`
552
- : '';
553
- const paramsArr = Array.isArray(entry.params) ? entry.params : [];
554
- const paramsStr = paramsArr.length > 0 ? `params: [${paramsArr.join(', ')}]` : '';
555
- const requestShape = [bodyStr, paramsStr].filter(Boolean).join('; ') || '—';
556
- // Expected-status matrix: aggregate @cases dataset labels + expected status
557
- // from scenarios that call this endpoint. Fall back to catalog expect.status.
558
- const statusEntries = [];
559
- for (const sc of scenarios) {
560
- const calls = (0, feature_parser_1.extractApiCallOrder)(sc.tags);
561
- if (!calls.includes(endpointName))
562
- continue;
563
- const dataset = (0, feature_parser_1.extractCasesDataset)(sc.tags);
564
- if (dataset) {
565
- // @cases dataset name as label — actual per-row statuses live in test-data.yaml
566
- statusEntries.push(`@cases:${dataset}`);
567
- }
568
- }
569
- // Show the catalog baseline status plus a pointer to any @cases matrix dataset (the per-row
570
- // statuses live in test-data; resolving them into this cell is a later enrichment).
571
- const catalogStatus = entry.expect?.status != null ? String(entry.expect.status) : '';
572
- const expectedStatusMatrix = [catalogStatus, ...new Set(statusEntries)].filter(Boolean).join('; ') || '—';
573
- // Flow steps: ordered @api names from flow-tagged scenarios referencing this endpoint.
574
- const flowStepsSet = new Set();
575
- for (const sc of scenarios) {
576
- const calls = (0, feature_parser_1.extractApiCallOrder)(sc.tags);
577
- if (!calls.includes(endpointName))
578
- continue;
579
- // All scenarios show their call order; flow scenarios show multi-step chains.
580
- if (calls.length > 1) {
581
- flowStepsSet.add(calls.join(' → '));
582
- }
583
- }
584
- const flowSteps = [...flowStepsSet].join('; ') || '—';
585
- // Concurrency invariant: from @concurrent scenarios calling this endpoint.
586
- const concurrencyParts = [];
587
- for (const sc of scenarios) {
588
- const calls = (0, feature_parser_1.extractApiCallOrder)(sc.tags);
589
- if (!calls.includes(endpointName))
590
- continue;
591
- const inv = (0, feature_parser_1.extractConcurrencyInvariant)(sc.tags);
592
- if (inv)
593
- concurrencyParts.push(inv);
594
- }
595
- const concurrencyInvariant = concurrencyParts.join('; ') || '—';
596
- rows.push({
597
- endpoint,
598
- method,
599
- authDatasource,
600
- requestShape,
601
- expectedStatusMatrix,
602
- flowSteps,
603
- concurrencyInvariant,
604
- });
605
- }
606
- return rows;
607
- }
608
- /**
609
- * Append a second "API detail" worksheet to the workbook.
610
- * Called only for api-kind units; no effect on the Testcases sheet or other sheets.
611
- *
612
- * Columns: Endpoint · Method · Auth/Datasource · Request shape ·
613
- * Expected-status matrix · Flow steps · Concurrency invariant
614
- */
615
- function addApiDetailSheet(wb, detailRows) {
616
- const ws = wb.addWorksheet('API detail');
617
- const ARIAL_FONT = 'Arial';
618
- ws.columns = [
619
- { header: 'Endpoint', width: 35 },
620
- { header: 'Method', width: 10 },
621
- { header: 'Auth / Datasource', width: 22 },
622
- { header: 'Request shape', width: 40 },
623
- { header: 'Expected-status matrix', width: 30 },
624
- { header: 'Flow steps', width: 40 },
625
- { header: 'Concurrency invariant', width: 35 },
626
- ];
627
- // Style the auto-generated header row (row 1).
628
- const headerRow = ws.getRow(1);
629
- headerRow.height = 30;
630
- headerRow.eachCell((cell) => {
631
- cell.font = { bold: true, color: { argb: API_DETAIL_HEADER_FONT }, name: ARIAL_FONT };
632
- cell.fill = { type: 'pattern', pattern: 'solid', fgColor: { argb: API_DETAIL_HEADER_FILL } };
633
- cell.alignment = { horizontal: 'center', vertical: 'middle', wrapText: true };
634
- applyBorder(cell);
83
+ return (0, xlsx_report_builder_1.buildApiDetailRows)(catalog, scenarios, {
84
+ extractApiCallOrder: feature_parser_1.extractApiCallOrder,
85
+ extractCasesDataset: feature_parser_1.extractCasesDataset,
86
+ extractConcurrencyInvariant: feature_parser_1.extractConcurrencyInvariant,
635
87
  });
636
- ws.views = [{ state: 'frozen', ySplit: 1 }];
637
- for (const r of detailRows) {
638
- const row = ws.addRow([
639
- r.endpoint,
640
- r.method,
641
- r.authDatasource,
642
- r.requestShape,
643
- r.expectedStatusMatrix,
644
- r.flowSteps,
645
- r.concurrencyInvariant,
646
- ]);
647
- row.alignment = { vertical: 'top', wrapText: true };
648
- row.eachCell({ includeEmpty: true }, (cell) => {
649
- applyBorder(cell);
650
- cell.font = { name: ARIAL_FONT };
651
- });
652
- }
653
- ws.autoFilter = {
654
- from: { row: 1, column: 1 },
655
- to: { row: ws.rowCount, column: 7 },
656
- };
657
88
  }
658
89
  /**
659
90
  * Write the workbook to `qa/deliverables/<screen>-testcases[.env].xlsx`.
@@ -678,7 +109,8 @@ async function writeXlsx(cwd, screen, wb, locale) {
678
109
  /**
679
110
  * Post-process the workbook buffer: extend `<a:picLocks>` on every drawing
680
111
  * with `noMove`, `noResize`, `noSelect`. Combined with the sheet protection
681
- * above, the embedded logo can't be dragged, resized, or selected via the UI.
112
+ * set by the builder, the embedded logo can't be dragged, resized, or
113
+ * selected via the UI.
682
114
  */
683
115
  async function lockEmbeddedImages(buffer) {
684
116
  const zip = await jszip_1.default.loadAsync(buffer);
@@ -700,6 +132,4 @@ async function lockEmbeddedImages(buffer) {
700
132
  }
701
133
  return zip.generateAsync({ type: 'nodebuffer', compression: 'DEFLATE' });
702
134
  }
703
- void applyBorder;
704
- void {};
705
135
  //# sourceMappingURL=xlsx-exporter.js.map