@sun-asterisk/sungen 3.2.5 → 3.2.7

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 (126) hide show
  1. package/dist/cli/commands/delivery.d.ts.map +1 -1
  2. package/dist/cli/commands/delivery.js +7 -46
  3. package/dist/cli/commands/delivery.js.map +1 -1
  4. package/dist/dashboard/snapshot-builder.d.ts.map +1 -1
  5. package/dist/dashboard/snapshot-builder.js +28 -6
  6. package/dist/dashboard/snapshot-builder.js.map +1 -1
  7. package/dist/dashboard/templates/index.html +20 -20
  8. package/dist/dashboard/types.d.ts +18 -0
  9. package/dist/dashboard/types.d.ts.map +1 -1
  10. package/dist/exporters/api-catalog-loader.d.ts +18 -0
  11. package/dist/exporters/api-catalog-loader.d.ts.map +1 -0
  12. package/dist/exporters/api-catalog-loader.js +77 -0
  13. package/dist/exporters/api-catalog-loader.js.map +1 -0
  14. package/dist/exporters/csv-exporter.d.ts.map +1 -1
  15. package/dist/exporters/csv-exporter.js +20 -26
  16. package/dist/exporters/csv-exporter.js.map +1 -1
  17. package/dist/exporters/feature-parser.d.ts +6 -0
  18. package/dist/exporters/feature-parser.d.ts.map +1 -1
  19. package/dist/exporters/feature-parser.js +9 -3
  20. package/dist/exporters/feature-parser.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 +92 -50
  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/result-variants.d.ts +29 -0
  30. package/dist/exporters/result-variants.d.ts.map +1 -0
  31. package/dist/exporters/result-variants.js +33 -0
  32. package/dist/exporters/result-variants.js.map +1 -0
  33. package/dist/exporters/xlsx-exporter.d.ts +18 -17
  34. package/dist/exporters/xlsx-exporter.d.ts.map +1 -1
  35. package/dist/exporters/xlsx-exporter.js +25 -563
  36. package/dist/exporters/xlsx-exporter.js.map +1 -1
  37. package/dist/exporters/xlsx-report-builder.d.ts +196 -0
  38. package/dist/exporters/xlsx-report-builder.d.ts.map +1 -0
  39. package/dist/exporters/xlsx-report-builder.js +653 -0
  40. package/dist/exporters/xlsx-report-builder.js.map +1 -0
  41. package/dist/generators/test-generator/adapters/appium/templates/scenario.hbs +1 -1
  42. package/dist/generators/test-generator/adapters/playwright/templates/scenario.hbs +6 -6
  43. package/dist/generators/test-generator/adapters/playwright/templates/steps/actions/expand-action.hbs +30 -8
  44. package/dist/generators/test-generator/adapters/playwright/templates/steps/assertions/selected-assertion.hbs +16 -1
  45. package/dist/generators/test-generator/patterns/expect-patterns.d.ts.map +1 -1
  46. package/dist/generators/test-generator/patterns/expect-patterns.js +23 -0
  47. package/dist/generators/test-generator/patterns/expect-patterns.js.map +1 -1
  48. package/dist/generators/test-generator/utils/selector-resolver.d.ts +7 -0
  49. package/dist/generators/test-generator/utils/selector-resolver.d.ts.map +1 -1
  50. package/dist/generators/test-generator/utils/selector-resolver.js +13 -2
  51. package/dist/generators/test-generator/utils/selector-resolver.js.map +1 -1
  52. package/dist/orchestrator/project-initializer.d.ts +9 -0
  53. package/dist/orchestrator/project-initializer.d.ts.map +1 -1
  54. package/dist/orchestrator/project-initializer.js +66 -9
  55. package/dist/orchestrator/project-initializer.js.map +1 -1
  56. package/dist/orchestrator/templates/ai-src/commands/add-api.md +76 -0
  57. package/dist/orchestrator/templates/ai-src/commands/create-test.md +2 -2
  58. package/dist/orchestrator/templates/ai-src/config/codex.md +3 -2
  59. package/dist/orchestrator/templates/ai-src/skills/sungen-api-coverage-model/SKILL.md +73 -0
  60. package/dist/orchestrator/templates/ai-src/skills/sungen-api-design/SKILL.md +42 -8
  61. package/dist/orchestrator/templates/ai-src/skills/sungen-gherkin-syntax/SKILL.md +21 -0
  62. package/dist/orchestrator/templates/ai-src/skills/sungen-selector-fix/SKILL.md +2 -0
  63. package/dist/orchestrator/templates/ai-src/skills/sungen-selector-keys/SKILL.md +33 -0
  64. package/dist/orchestrator/templates/ai-src/skills/sungen-tc-review/SKILL.md +6 -0
  65. package/dist/orchestrator/templates/specs-api.d.ts +26 -0
  66. package/dist/orchestrator/templates/specs-api.d.ts.map +1 -1
  67. package/dist/orchestrator/templates/specs-api.js +131 -3
  68. package/dist/orchestrator/templates/specs-api.js.map +1 -1
  69. package/dist/orchestrator/templates/specs-api.ts +118 -5
  70. package/dist/orchestrator/templates/specs-test-data.ts +20 -1
  71. package/package.json +3 -3
  72. package/src/cli/commands/delivery.ts +8 -42
  73. package/src/dashboard/snapshot-builder.ts +31 -7
  74. package/src/dashboard/templates/index.html +20 -20
  75. package/src/dashboard/types.ts +19 -0
  76. package/src/exporters/api-catalog-loader.ts +44 -0
  77. package/src/exporters/csv-exporter.ts +19 -24
  78. package/src/exporters/feature-parser.ts +8 -2
  79. package/src/exporters/json-exporter.ts +102 -51
  80. package/src/exporters/playwright-report-parser.ts +27 -0
  81. package/src/exporters/result-variants.ts +47 -0
  82. package/src/exporters/xlsx-exporter.ts +34 -623
  83. package/src/exporters/xlsx-report-builder.ts +806 -0
  84. package/src/generators/test-generator/adapters/appium/templates/scenario.hbs +1 -1
  85. package/src/generators/test-generator/adapters/playwright/templates/scenario.hbs +6 -6
  86. package/src/generators/test-generator/adapters/playwright/templates/steps/actions/expand-action.hbs +30 -8
  87. package/src/generators/test-generator/adapters/playwright/templates/steps/assertions/selected-assertion.hbs +16 -1
  88. package/src/generators/test-generator/patterns/expect-patterns.ts +23 -0
  89. package/src/generators/test-generator/utils/selector-resolver.ts +30 -2
  90. package/src/orchestrator/project-initializer.ts +67 -9
  91. package/src/orchestrator/templates/ai-src/commands/add-api.md +76 -0
  92. package/src/orchestrator/templates/ai-src/commands/create-test.md +2 -2
  93. package/src/orchestrator/templates/ai-src/config/codex.md +3 -2
  94. package/src/orchestrator/templates/ai-src/skills/sungen-api-coverage-model/SKILL.md +73 -0
  95. package/src/orchestrator/templates/ai-src/skills/sungen-api-design/SKILL.md +42 -8
  96. package/src/orchestrator/templates/ai-src/skills/sungen-gherkin-syntax/SKILL.md +21 -0
  97. package/src/orchestrator/templates/ai-src/skills/sungen-selector-fix/SKILL.md +2 -0
  98. package/src/orchestrator/templates/ai-src/skills/sungen-selector-keys/SKILL.md +33 -0
  99. package/src/orchestrator/templates/ai-src/skills/sungen-tc-review/SKILL.md +6 -0
  100. package/src/orchestrator/templates/specs-api.ts +118 -5
  101. package/src/orchestrator/templates/specs-test-data.ts +20 -1
  102. package/dist/cli/types.d.ts +0 -9
  103. package/dist/cli/types.d.ts.map +0 -1
  104. package/dist/cli/types.js +0 -7
  105. package/dist/cli/types.js.map +0 -1
  106. package/dist/generators/gherkin-parser/selector-extractor.d.ts +0 -37
  107. package/dist/generators/gherkin-parser/selector-extractor.d.ts.map +0 -1
  108. package/dist/generators/gherkin-parser/selector-extractor.js +0 -108
  109. package/dist/generators/gherkin-parser/selector-extractor.js.map +0 -1
  110. package/dist/generators/test-generator/types.d.ts +0 -25
  111. package/dist/generators/test-generator/types.d.ts.map +0 -1
  112. package/dist/generators/test-generator/types.js +0 -7
  113. package/dist/generators/test-generator/types.js.map +0 -1
  114. package/dist/generators/types.d.ts +0 -119
  115. package/dist/generators/types.d.ts.map +0 -1
  116. package/dist/generators/types.js +0 -48
  117. package/dist/generators/types.js.map +0 -1
  118. package/dist/orchestrator/figma/node-path-collapser.d.ts +0 -16
  119. package/dist/orchestrator/figma/node-path-collapser.d.ts.map +0 -1
  120. package/dist/orchestrator/figma/node-path-collapser.js +0 -37
  121. package/dist/orchestrator/figma/node-path-collapser.js.map +0 -1
  122. package/src/cli/types.ts +0 -9
  123. package/src/generators/gherkin-parser/selector-extractor.ts +0 -142
  124. package/src/generators/test-generator/types.ts +0 -26
  125. package/src/generators/types.ts +0 -227
  126. 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,582 +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
- let rowIdx = HEADER_ROW + 1;
244
- sheets.forEach((s, i) => {
245
- const su = s.summary;
246
- const remain = Math.max(0, su.total - su.passed - su.na);
247
- writeDataRow(rowIdx, [i + 1, s.sheetName, su.passed, su.failed, su.pending, su.na, remain, su.total], false);
248
- totals.passed += su.passed;
249
- totals.failed += su.failed;
250
- totals.pending += su.pending;
251
- totals.na += su.na;
252
- totals.remain += remain;
253
- totals.total += su.total;
254
- rowIdx += 1;
255
- });
256
- writeDataRow(rowIdx, ['', 'Total', totals.passed, totals.failed, totals.pending, totals.na, totals.remain, totals.total], true);
257
- }
258
- /**
259
- * Append one BM-2-901-13 testcase sheet to the given workbook. Sheet content
260
- * (layout, summary band, data rows, auto-filter, protection) is identical to
261
- * the single-sheet `renderXlsx` output — only the sheet name differs.
262
- */
263
- function addTestcaseSheet(wb, sheetName, summary, rows, specLink) {
264
- const ws = wb.addWorksheet(sheetName, {
265
- views: [{ state: 'frozen', ySplit: 0, xSplit: 0 }],
266
- });
267
- // -- Column widths matching template_report.xlsx (Sample sheet) --
268
- ws.columns = [
269
- { width: 20 }, // A — TC ID (wider to fit long flow IDs like FLOW-KUDO-…)
270
- { width: 12.5 }, // B — Screen/Function
271
- { width: 15.38 }, // C — Big item
272
- { width: 16.25 }, // D — Medium item
273
- { width: 17 }, // E — Test Object
274
- { width: 25.5 }, // F — Pre-condition
275
- { width: 24.88 }, // G — Test Data
276
- { width: 24.88 }, // H — Steps
277
- { width: 41 }, // I — Expected results
278
- { width: 12 }, // J — Priority
279
- { width: 13.5 }, // K — Testcase type
280
- { width: 15.88 }, // L — Test Result
281
- { width: 13.5 }, // M — Executed Date
282
- { width: 16.5 }, // N — Test Executor
283
- { width: 23 }, // O — Test Environment
284
- { width: 29 }, // P — Note
285
- ];
286
- // -- Top metadata band (rows 1-4) — shared BM-2-901-13 masthead --
287
- renderReportHeaderBand(wb, ws, `${summary.screen.toUpperCase()} TESTCASE`);
288
- // Materialize rows 5..8 so the summary band + row-9 spacer land at the right offsets.
289
- for (let r = 5; r <= 8; r++)
290
- ws.getRow(r);
291
- // -- Row 5: spacer (height auto-fit). --
292
- // -- Row 6: Summary headers (cols C..H), lavender fill --
293
- const sumLabels = {
294
- C: 'Total TCs', D: 'Passed', E: 'Failed', F: 'Pending', G: 'N/A', H: 'Remaining',
295
- };
296
- for (const [col, label] of Object.entries(sumLabels)) {
297
- const c = ws.getCell(`${col}6`);
298
- c.value = label;
299
- c.font = { bold: true, size: 10, color: BLACK, name: ARIAL_FONT };
300
- c.fill = { type: 'pattern', pattern: 'solid', fgColor: LAVENDER };
301
- c.alignment = { horizontal: 'center', vertical: 'top' };
302
- c.border = allBordersBlack;
303
- }
304
- // No explicit height → Excel auto-fits this row's content.
305
- // -- Row 7: Counts (cols C..H), live formulas referencing the data area --
306
- // Data table starts at row 15 (col header at row 14, divider at row 14? actually
307
- // header at row 13 + divider at 14 + first data at 15). The formulas read col L
308
- // (Test Result) for status counts, col A (TC ID) for total via COUNTA.
309
- const COUNT_RANGE_END = 10000;
310
- const r7Values = {
311
- C: { formula: `COUNTA(A15:A${COUNT_RANGE_END})`, result: summary.total },
312
- D: { formula: `COUNTIF(L15:L${COUNT_RANGE_END},"Passed")`, result: summary.passed },
313
- E: { formula: `COUNTIF(L15:L${COUNT_RANGE_END},"Failed")`, result: summary.failed },
314
- F: { formula: `COUNTIF(L15:L${COUNT_RANGE_END},"Pending")`, result: summary.pending },
315
- G: { formula: `COUNTIF(L15:L${COUNT_RANGE_END},"N/A")`, result: summary.na },
316
- H: { formula: 'C7-D7-G7', result: summary.failed + summary.pending },
317
- };
318
- for (const [col, val] of Object.entries(r7Values)) {
319
- const c = ws.getCell(`${col}7`);
320
- c.value = val;
321
- c.font = { size: 10, color: BLACK, name: ARIAL_FONT };
322
- c.fill = { type: 'pattern', pattern: 'solid', fgColor: WHITE };
323
- c.alignment = { horizontal: 'center', vertical: 'top' };
324
- c.border = allBordersBlack;
325
- if (col === 'H')
326
- c.numFmt = '#,##0';
327
- }
328
- // No explicit height → Excel auto-fits.
329
- // C8 has no value in the template but still needs a border so the band
330
- // visually closes underneath "Total TCs".
331
- const c8 = ws.getCell('C8');
332
- c8.font = { size: 10, color: BLACK, name: ARIAL_FONT };
333
- c8.fill = { type: 'pattern', pattern: 'solid', fgColor: WHITE };
334
- c8.alignment = { horizontal: 'center', vertical: 'top' };
335
- c8.border = allBordersBlack;
336
- // -- Row 8: Percentages (cols D..H), formula = count / (Total − N/A) --
337
- const r8Values = {
338
- D: { formula: 'IFERROR(D7/(C7-G7),0)', result: summary.passed / Math.max(1, summary.total - summary.na) },
339
- E: { formula: 'IFERROR(E7/(C7-G7),0)', result: summary.failed / Math.max(1, summary.total - summary.na) },
340
- F: { formula: 'IFERROR(F7/(C7-G7),0)', result: summary.pending / Math.max(1, summary.total - summary.na) },
341
- G: { formula: 'IFERROR(G7/(C7-G7),0)', result: summary.na / Math.max(1, summary.total - summary.na) },
342
- H: { formula: 'IFERROR(H7/(C7-G7),0)', result: (summary.failed + summary.pending) / Math.max(1, summary.total - summary.na) },
343
- };
344
- for (const [col, val] of Object.entries(r8Values)) {
345
- const c = ws.getCell(`${col}8`);
346
- c.value = val;
347
- c.font = { size: 10, color: BLACK, name: ARIAL_FONT };
348
- c.fill = { type: 'pattern', pattern: 'solid', fgColor: WHITE };
349
- c.alignment = { horizontal: 'center', vertical: 'top' };
350
- c.border = allBordersBlack;
351
- c.numFmt = '0%';
352
- }
353
- // No explicit height → Excel auto-fits.
354
- // After rows 1-8 are populated, append a blank row 9 spacer.
355
- while (ws.rowCount < 9)
356
- ws.addRow([]);
357
- const specRow = ws.addRow(['Spec/Design link:', specLink]);
358
- specRow.getCell(1).font = { bold: true };
359
- specRow.getCell(2).font = { color: { argb: 'FF1F4E78' }, underline: true };
360
- ws.addRow([]); // spacer
361
- const legendRow = ws.addRow(['*: Mandatory']);
362
- legendRow.getCell(1).font = { italic: true, color: { argb: 'FF808080' } };
363
- // -- Column header row (bold, filled, wrapped) --
364
- const headerRow = ws.addRow([
365
- 'TC ID*',
366
- 'Screen/Function',
367
- 'Big item',
368
- 'Medium item',
369
- 'Test Object',
370
- 'Pre-condition',
371
- 'Test Data',
372
- 'Steps*',
373
- 'Expected results*',
374
- 'Priority',
375
- 'Testcase type',
376
- 'Test Result*',
377
- 'Executed Date*',
378
- 'Test Executor*',
379
- 'Test Environment',
380
- 'Note\n(Test evidence, DefectID, Actual result)',
381
- ]);
382
- headerRow.height = 38;
383
- headerRow.eachCell((cell) => {
384
- cell.font = { bold: true, color: { argb: HEADER_FONT } };
385
- cell.fill = { type: 'pattern', pattern: 'solid', fgColor: { argb: HEADER_FILL } };
386
- cell.alignment = { horizontal: 'center', vertical: 'middle', wrapText: true };
387
- applyBorder(cell);
388
- });
389
- // Freeze everything above and below the header row — reveal header when scrolling.
390
- ws.views = [{ state: 'frozen', ySplit: headerRow.number }];
391
- // -- Data rows grouped by category --
392
- const order = ['Accessing', 'GUI', 'Function'];
393
- const grouped = new Map();
394
- for (const r of rows) {
395
- const g = grouped.get(r.category2) || [];
396
- g.push(r);
397
- grouped.set(r.category2, g);
398
- }
399
- const emittedGroups = new Set();
400
- function emitGroup(groupName, groupRows) {
401
- // Column A (TC ID) must stay TRULY blank on a divider — never write '' here. COUNTA counts
402
- // empty-string cells, so an '' in A made the generated total (=COUNTA(A15:A…)) over-count by
403
- // one per group divider when recalculated (e.g. in Google Sheets). Set only the group name in B;
404
- // the lavender band still spans every column via the fill loop below (style only, no value).
405
- const divider = ws.addRow([]);
406
- divider.getCell(2).value = groupName;
407
- divider.getCell(2).font = { bold: true };
408
- divider.eachCell({ includeEmpty: false }, (cell) => {
409
- cell.fill = { type: 'pattern', pattern: 'solid', fgColor: { argb: CATEGORY_FILL } };
410
- });
411
- // Fill the full width so the band spans the whole table
412
- for (let i = 1; i <= COL_COUNT; i++) {
413
- const c = divider.getCell(i);
414
- c.fill = { type: 'pattern', pattern: 'solid', fgColor: { argb: CATEGORY_FILL } };
415
- applyBorder(c);
416
- }
417
- for (const r of groupRows) {
418
- const row = ws.addRow([
419
- r.tcId,
420
- '',
421
- '',
422
- '',
423
- r.category1,
424
- r.precondition,
425
- r.testData,
426
- r.steps,
427
- r.expectedResults,
428
- r.priority,
429
- r.testcaseType,
430
- r.testResult,
431
- r.executedDate,
432
- r.testExecutor,
433
- r.testEnvironment,
434
- r.note,
435
- ]);
436
- row.alignment = { vertical: 'top', wrapText: true };
437
- row.eachCell({ includeEmpty: true }, (cell, colNumber) => {
438
- applyBorder(cell);
439
- if (colNumber === 1) {
440
- cell.font = { bold: true };
441
- }
442
- if (colNumber === 12) {
443
- // Test Result — colour-code
444
- const val = String(cell.value || '');
445
- if (val === 'Passed') {
446
- cell.font = { color: { argb: 'FF107C41' }, bold: true };
447
- }
448
- else if (val === 'Failed') {
449
- cell.font = { color: { argb: 'FFC00000' }, bold: true };
450
- }
451
- else if (val === 'Pending') {
452
- cell.font = { color: { argb: 'FF996D00' }, bold: true };
453
- }
454
- else if (val === 'N/A') {
455
- cell.font = { color: { argb: 'FF808080' } };
456
- }
457
- }
458
- });
459
- }
460
- }
461
- for (const groupName of order) {
462
- const groupRows = grouped.get(groupName);
463
- if (!groupRows || groupRows.length === 0)
464
- continue;
465
- emittedGroups.add(groupName);
466
- emitGroup(groupName, groupRows);
467
- }
468
- for (const [groupName, groupRows] of grouped.entries()) {
469
- if (emittedGroups.has(groupName))
470
- continue;
471
- emitGroup(groupName, groupRows);
472
- }
473
- // Auto-filter on the header row so QA can filter by result / priority / category
474
- ws.autoFilter = {
475
- from: { row: headerRow.number, column: 1 },
476
- to: { row: ws.rowCount, column: COL_COUNT },
477
- };
478
- // Sheet protection lets the picLocks on the embedded logo take effect
479
- // (Excel honours image locks only when the sheet is protected). Empty
480
- // password — QA can run Review → Unprotect Sheet if they need to edit.
481
- // `objects: false` here is ExcelJS's inverted semantic that writes
482
- // `objects="1"` in XML (= objects ARE locked).
483
- ws.sheetProtection = {
484
- sheet: true,
485
- objects: false,
486
- scenarios: false,
487
- };
70
+ return (0, xlsx_report_builder_1.buildTestcaseWorkbook)(sheets, { sungenVersion: (0, package_info_1.getPackageVersion)() });
488
71
  }
489
- // ---------------------------------------------------------------------------
490
- // API detail sheet (api-kind units only)
491
- // Second worksheet appended after Testcases — never alters the Testcases sheet.
492
- // ---------------------------------------------------------------------------
493
- const API_DETAIL_HEADER_FILL = 'FF2E5984'; // dark blue header for differentiation
494
- const API_DETAIL_HEADER_FONT = 'FFFFFFFF'; // white text on dark header
495
72
  /**
496
73
  * Build ApiDetailRow[] from the apis.yaml catalog + feature-level annotations.
497
74
  * Called once per feature file for api-kind units in the delivery pipeline.
498
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
+ *
499
79
  * @param catalog Parsed apis.yaml keyed by endpoint name
500
80
  * @param scenarios Scenario-level tag arrays from parseFeatureMetadata().scenarios
501
81
  */
502
82
  function buildApiDetailRows(catalog, scenarios) {
503
- const rows = [];
504
- for (const [endpointName, entry] of Object.entries(catalog)) {
505
- const method = (entry.method ?? '').toUpperCase();
506
- const endpoint = entry.path ?? endpointName;
507
- const datasource = entry.datasource ?? '';
508
- // Auth: look for @auth: tag in any scenario that calls this endpoint.
509
- const authTags = scenarios.flatMap((s) => {
510
- const calls = (0, feature_parser_1.extractApiCallOrder)(s.tags);
511
- if (!calls.includes(endpointName))
512
- return [];
513
- return s.tags.filter((t) => t.startsWith('@auth:'));
514
- });
515
- const uniqueAuth = [...new Set(authTags.map((t) => t.slice('@auth:'.length)))];
516
- const authDatasource = [datasource, ...uniqueAuth].filter(Boolean).join('; ');
517
- // Request shape: compose from body + params + encoding.
518
- const bodyStr = entry.body
519
- ? `body: ${typeof entry.body === 'string' ? entry.body : JSON.stringify(entry.body)}`
520
- : '';
521
- const paramsArr = Array.isArray(entry.params) ? entry.params : [];
522
- const paramsStr = paramsArr.length > 0 ? `params: [${paramsArr.join(', ')}]` : '';
523
- const requestShape = [bodyStr, paramsStr].filter(Boolean).join('; ') || '—';
524
- // Expected-status matrix: aggregate @cases dataset labels + expected status
525
- // from scenarios that call this endpoint. Fall back to catalog expect.status.
526
- const statusEntries = [];
527
- for (const sc of scenarios) {
528
- const calls = (0, feature_parser_1.extractApiCallOrder)(sc.tags);
529
- if (!calls.includes(endpointName))
530
- continue;
531
- const dataset = (0, feature_parser_1.extractCasesDataset)(sc.tags);
532
- if (dataset) {
533
- // @cases dataset name as label — actual per-row statuses live in test-data.yaml
534
- statusEntries.push(`@cases:${dataset}`);
535
- }
536
- }
537
- // Show the catalog baseline status plus a pointer to any @cases matrix dataset (the per-row
538
- // statuses live in test-data; resolving them into this cell is a later enrichment).
539
- const catalogStatus = entry.expect?.status != null ? String(entry.expect.status) : '';
540
- const expectedStatusMatrix = [catalogStatus, ...new Set(statusEntries)].filter(Boolean).join('; ') || '—';
541
- // Flow steps: ordered @api names from flow-tagged scenarios referencing this endpoint.
542
- const flowStepsSet = new Set();
543
- for (const sc of scenarios) {
544
- const calls = (0, feature_parser_1.extractApiCallOrder)(sc.tags);
545
- if (!calls.includes(endpointName))
546
- continue;
547
- // All scenarios show their call order; flow scenarios show multi-step chains.
548
- if (calls.length > 1) {
549
- flowStepsSet.add(calls.join(' → '));
550
- }
551
- }
552
- const flowSteps = [...flowStepsSet].join('; ') || '—';
553
- // Concurrency invariant: from @concurrent scenarios calling this endpoint.
554
- const concurrencyParts = [];
555
- for (const sc of scenarios) {
556
- const calls = (0, feature_parser_1.extractApiCallOrder)(sc.tags);
557
- if (!calls.includes(endpointName))
558
- continue;
559
- const inv = (0, feature_parser_1.extractConcurrencyInvariant)(sc.tags);
560
- if (inv)
561
- concurrencyParts.push(inv);
562
- }
563
- const concurrencyInvariant = concurrencyParts.join('; ') || '—';
564
- rows.push({
565
- endpoint,
566
- method,
567
- authDatasource,
568
- requestShape,
569
- expectedStatusMatrix,
570
- flowSteps,
571
- concurrencyInvariant,
572
- });
573
- }
574
- return rows;
575
- }
576
- /**
577
- * Append a second "API detail" worksheet to the workbook.
578
- * Called only for api-kind units; no effect on the Testcases sheet or other sheets.
579
- *
580
- * Columns: Endpoint · Method · Auth/Datasource · Request shape ·
581
- * Expected-status matrix · Flow steps · Concurrency invariant
582
- */
583
- function addApiDetailSheet(wb, detailRows) {
584
- const ws = wb.addWorksheet('API detail');
585
- const ARIAL_FONT = 'Arial';
586
- ws.columns = [
587
- { header: 'Endpoint', width: 35 },
588
- { header: 'Method', width: 10 },
589
- { header: 'Auth / Datasource', width: 22 },
590
- { header: 'Request shape', width: 40 },
591
- { header: 'Expected-status matrix', width: 30 },
592
- { header: 'Flow steps', width: 40 },
593
- { header: 'Concurrency invariant', width: 35 },
594
- ];
595
- // Style the auto-generated header row (row 1).
596
- const headerRow = ws.getRow(1);
597
- headerRow.height = 30;
598
- headerRow.eachCell((cell) => {
599
- cell.font = { bold: true, color: { argb: API_DETAIL_HEADER_FONT }, name: ARIAL_FONT };
600
- cell.fill = { type: 'pattern', pattern: 'solid', fgColor: { argb: API_DETAIL_HEADER_FILL } };
601
- cell.alignment = { horizontal: 'center', vertical: 'middle', wrapText: true };
602
- 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,
603
87
  });
604
- ws.views = [{ state: 'frozen', ySplit: 1 }];
605
- for (const r of detailRows) {
606
- const row = ws.addRow([
607
- r.endpoint,
608
- r.method,
609
- r.authDatasource,
610
- r.requestShape,
611
- r.expectedStatusMatrix,
612
- r.flowSteps,
613
- r.concurrencyInvariant,
614
- ]);
615
- row.alignment = { vertical: 'top', wrapText: true };
616
- row.eachCell({ includeEmpty: true }, (cell) => {
617
- applyBorder(cell);
618
- cell.font = { name: ARIAL_FONT };
619
- });
620
- }
621
- ws.autoFilter = {
622
- from: { row: 1, column: 1 },
623
- to: { row: ws.rowCount, column: 7 },
624
- };
625
88
  }
626
89
  /**
627
90
  * Write the workbook to `qa/deliverables/<screen>-testcases[.env].xlsx`.
@@ -646,7 +109,8 @@ async function writeXlsx(cwd, screen, wb, locale) {
646
109
  /**
647
110
  * Post-process the workbook buffer: extend `<a:picLocks>` on every drawing
648
111
  * with `noMove`, `noResize`, `noSelect`. Combined with the sheet protection
649
- * 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.
650
114
  */
651
115
  async function lockEmbeddedImages(buffer) {
652
116
  const zip = await jszip_1.default.loadAsync(buffer);
@@ -668,6 +132,4 @@ async function lockEmbeddedImages(buffer) {
668
132
  }
669
133
  return zip.generateAsync({ type: 'nodebuffer', compression: 'DEFLATE' });
670
134
  }
671
- void applyBorder;
672
- void {};
673
135
  //# sourceMappingURL=xlsx-exporter.js.map