@sun-asterisk/sungen 2.6.8 → 2.6.10

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 (84) hide show
  1. package/dist/cli/commands/dashboard.d.ts +2 -1
  2. package/dist/cli/commands/dashboard.d.ts.map +1 -1
  3. package/dist/cli/commands/dashboard.js +9 -9
  4. package/dist/cli/commands/dashboard.js.map +1 -1
  5. package/dist/cli/commands/delivery.d.ts.map +1 -1
  6. package/dist/cli/commands/delivery.js +33 -0
  7. package/dist/cli/commands/delivery.js.map +1 -1
  8. package/dist/cli/index.js +1 -1
  9. package/dist/cli/index.js.map +1 -1
  10. package/dist/dashboard/history-store.d.ts +13 -9
  11. package/dist/dashboard/history-store.d.ts.map +1 -1
  12. package/dist/dashboard/history-store.js +19 -28
  13. package/dist/dashboard/history-store.js.map +1 -1
  14. package/dist/dashboard/html-renderer.d.ts +1 -1
  15. package/dist/dashboard/html-renderer.d.ts.map +1 -1
  16. package/dist/dashboard/html-renderer.js +2 -2
  17. package/dist/dashboard/html-renderer.js.map +1 -1
  18. package/dist/dashboard/snapshot-builder.d.ts.map +1 -1
  19. package/dist/dashboard/snapshot-builder.js +38 -2
  20. package/dist/dashboard/snapshot-builder.js.map +1 -1
  21. package/dist/dashboard/templates/index.html +142 -221
  22. package/dist/exporters/csv-exporter.d.ts +4 -0
  23. package/dist/exporters/csv-exporter.d.ts.map +1 -1
  24. package/dist/exporters/csv-exporter.js +35 -26
  25. package/dist/exporters/csv-exporter.js.map +1 -1
  26. package/dist/exporters/feature-parser.d.ts.map +1 -1
  27. package/dist/exporters/feature-parser.js +16 -4
  28. package/dist/exporters/feature-parser.js.map +1 -1
  29. package/dist/exporters/json-exporter.d.ts.map +1 -1
  30. package/dist/exporters/json-exporter.js +28 -20
  31. package/dist/exporters/json-exporter.js.map +1 -1
  32. package/dist/exporters/playwright-report-parser.d.ts.map +1 -1
  33. package/dist/exporters/playwright-report-parser.js +22 -5
  34. package/dist/exporters/playwright-report-parser.js.map +1 -1
  35. package/dist/exporters/scenario-merger.d.ts +23 -1
  36. package/dist/exporters/scenario-merger.d.ts.map +1 -1
  37. package/dist/exporters/scenario-merger.js +39 -0
  38. package/dist/exporters/scenario-merger.js.map +1 -1
  39. package/dist/exporters/step-formatter.d.ts +31 -3
  40. package/dist/exporters/step-formatter.d.ts.map +1 -1
  41. package/dist/exporters/step-formatter.js +52 -19
  42. package/dist/exporters/step-formatter.js.map +1 -1
  43. package/dist/exporters/sun-logo.d.ts +10 -0
  44. package/dist/exporters/sun-logo.d.ts.map +1 -0
  45. package/dist/exporters/sun-logo.js +13 -0
  46. package/dist/exporters/sun-logo.js.map +1 -0
  47. package/dist/exporters/test-data-resolver.d.ts +13 -5
  48. package/dist/exporters/test-data-resolver.d.ts.map +1 -1
  49. package/dist/exporters/test-data-resolver.js +36 -14
  50. package/dist/exporters/test-data-resolver.js.map +1 -1
  51. package/dist/exporters/types.d.ts +16 -0
  52. package/dist/exporters/types.d.ts.map +1 -1
  53. package/dist/exporters/xlsx-exporter.d.ts.map +1 -1
  54. package/dist/exporters/xlsx-exporter.js +169 -99
  55. package/dist/exporters/xlsx-exporter.js.map +1 -1
  56. package/dist/orchestrator/templates/playwright.config.d.ts.map +1 -1
  57. package/dist/orchestrator/templates/playwright.config.js +2 -0
  58. package/dist/orchestrator/templates/playwright.config.js.map +1 -1
  59. package/dist/orchestrator/templates/playwright.config.ts +2 -0
  60. package/dist/orchestrator/templates/specs-base.d.ts.map +1 -1
  61. package/dist/orchestrator/templates/specs-base.js +1 -5
  62. package/dist/orchestrator/templates/specs-base.js.map +1 -1
  63. package/dist/orchestrator/templates/specs-base.ts +1 -5
  64. package/package.json +1 -1
  65. package/src/cli/commands/dashboard.ts +9 -9
  66. package/src/cli/commands/delivery.ts +30 -0
  67. package/src/cli/index.ts +1 -1
  68. package/src/dashboard/history-store.ts +22 -28
  69. package/src/dashboard/html-renderer.ts +6 -2
  70. package/src/dashboard/snapshot-builder.ts +36 -2
  71. package/src/dashboard/templates/index.html +142 -221
  72. package/src/dashboard/types.ts +1 -1
  73. package/src/exporters/csv-exporter.ts +44 -27
  74. package/src/exporters/feature-parser.ts +27 -8
  75. package/src/exporters/json-exporter.ts +31 -21
  76. package/src/exporters/playwright-report-parser.ts +23 -5
  77. package/src/exporters/scenario-merger.ts +65 -1
  78. package/src/exporters/step-formatter.ts +48 -23
  79. package/src/exporters/sun-logo.ts +10 -0
  80. package/src/exporters/test-data-resolver.ts +37 -13
  81. package/src/exporters/types.ts +18 -1
  82. package/src/exporters/xlsx-exporter.ts +176 -101
  83. package/src/orchestrator/templates/playwright.config.ts +2 -0
  84. package/src/orchestrator/templates/specs-base.ts +1 -5
@@ -1,7 +1,8 @@
1
1
  /**
2
- * Persist dashboard snapshots under qa/dashboard/history/ and prune to a fixed
3
- * max count (oldest by mtime are deleted). Used by `sungen dashboard` to
4
- * accumulate runs for Trends / Compare views.
2
+ * Persist dashboard snapshots under qa/dashboard/history/. Files are never
3
+ * deleted — `max` only controls how many are *included* in dashboard stats /
4
+ * payload. Older files beyond `max` are retained on disk as `archived` so
5
+ * trends / compare data is recoverable.
5
6
  */
6
7
 
7
8
  import * as fs from 'fs';
@@ -12,8 +13,9 @@ export const DEFAULT_MAX_HISTORY = 20;
12
13
 
13
14
  export interface HistoryWriteResult {
14
15
  written: string; // absolute path written
15
- pruned: string[]; // absolute paths removed
16
- retained: string[]; // absolute paths still on disk (newest → oldest)
16
+ total: number; // total files on disk (after write)
17
+ included: string[]; // newest oldest, capped at max
18
+ archived: string[]; // files beyond max, still on disk
17
19
  }
18
20
 
19
21
  export function historyDir(cwd: string): string {
@@ -21,8 +23,8 @@ export function historyDir(cwd: string): string {
21
23
  }
22
24
 
23
25
  /**
24
- * Write `snapshot` as <runId>.json and prune older files until at most `max`
25
- * files remain. Files are sorted by mtime so manual edits (rare) still work.
26
+ * Write `snapshot` as <runId>.json. Never deletes existing files; `max` only
27
+ * partitions the on-disk list into `included` (newest N) vs `archived`.
26
28
  */
27
29
  export function writeSnapshotToHistory(
28
30
  cwd: string,
@@ -36,10 +38,10 @@ export function writeSnapshotToHistory(
36
38
  const target = path.join(dir, filename);
37
39
  fs.writeFileSync(target, JSON.stringify(snapshot, null, 2), 'utf-8');
38
40
 
39
- const pruned = pruneHistory(dir, max);
40
-
41
- const retained = listHistoryFiles(dir);
42
- return { written: target, pruned, retained };
41
+ const all = listHistoryFiles(dir); // newest first
42
+ const included = all.slice(0, max);
43
+ const archived = all.slice(max);
44
+ return { written: target, total: all.length, included, archived };
43
45
  }
44
46
 
45
47
  /**
@@ -54,11 +56,17 @@ export function listHistoryFiles(dir: string): string[] {
54
56
  }
55
57
 
56
58
  /**
57
- * Read every history JSON, oldest → newest. Skips files that fail to parse.
59
+ * Read history JSONs, oldest → newest. When `limit` is provided, only the
60
+ * newest `limit` files are loaded (older ones stay on disk but are skipped).
61
+ * Skips files that fail to parse.
58
62
  */
59
- export function readHistory(cwd: string): DashboardSnapshot[] {
63
+ export function readHistory(cwd: string, limit?: number): DashboardSnapshot[] {
60
64
  const dir = historyDir(cwd);
61
- const files = listHistoryFiles(dir).reverse(); // oldest → newest
65
+ let files = listHistoryFiles(dir); // newest first
66
+ if (typeof limit === 'number' && limit >= 0) {
67
+ files = files.slice(0, limit);
68
+ }
69
+ files = files.reverse(); // oldest → newest
62
70
  const out: DashboardSnapshot[] = [];
63
71
  for (const f of files) {
64
72
  try {
@@ -70,17 +78,3 @@ export function readHistory(cwd: string): DashboardSnapshot[] {
70
78
  }
71
79
  return out;
72
80
  }
73
-
74
- /**
75
- * Delete oldest files in `dir` until at most `max` remain.
76
- * Returns the absolute paths removed.
77
- */
78
- function pruneHistory(dir: string, max: number): string[] {
79
- const files = listHistoryFiles(dir); // newest first
80
- if (files.length <= max) return [];
81
- const toRemove = files.slice(max);
82
- for (const f of toRemove) {
83
- try { fs.unlinkSync(f); } catch { /* ignore */ }
84
- }
85
- return toRemove;
86
- }
@@ -42,8 +42,12 @@ export function resolveTemplatePath(): string {
42
42
  );
43
43
  }
44
44
 
45
- export function buildPayload(cwd: string, current: DashboardSnapshot): DashboardPayload {
46
- const all = readHistory(cwd);
45
+ export function buildPayload(
46
+ cwd: string,
47
+ current: DashboardSnapshot,
48
+ historyLimit?: number,
49
+ ): DashboardPayload {
50
+ const all = readHistory(cwd, historyLimit);
47
51
  // Exclude `current` from history if it's been written there already.
48
52
  const history = all.filter((s) => s.runId !== current.runId);
49
53
  return { current, history };
@@ -14,6 +14,7 @@
14
14
  import * as fs from 'fs';
15
15
  import * as path from 'path';
16
16
  import { execSync } from 'child_process';
17
+ import { parse as parseYaml } from 'yaml';
17
18
  import { parseFeatureMetadata } from '../exporters/feature-parser';
18
19
  import { parseSpecFile } from '../exporters/spec-parser';
19
20
  import { loadTestData } from '../exporters/test-data-resolver';
@@ -99,11 +100,20 @@ function buildOneScreen(
99
100
  const label = target.isFlow ? `flow/${target.name}` : target.name;
100
101
  const specLink = fs.existsSync(specMdFile) ? path.relative(cwd, specMdFile) : undefined;
101
102
 
103
+ // Screens declare their URL inline in the .feature ("Path: /awards"). Flows
104
+ // don't have one there, so fall back to the first `type: 'page'` entry in
105
+ // the flow's selectors YAML — that's where the entry point is recorded.
106
+ let featurePath = feature.featurePath;
107
+ if (!featurePath && target.isFlow) {
108
+ const selectorsFile = path.join(base, 'selectors', `${target.name}.yaml`);
109
+ featurePath = readPagePathFromSelectors(selectorsFile);
110
+ }
111
+
102
112
  return buildScreenSnapshot({
103
113
  screen: label,
104
114
  isFlow: target.isFlow,
105
115
  featureName: feature.featureName,
106
- featurePath: feature.featurePath,
116
+ featurePath,
107
117
  specLink,
108
118
  merged,
109
119
  testData,
@@ -125,7 +135,7 @@ function aggregateSummary(screens: ScreenSnapshot[]): AggregateSummary {
125
135
  na: 0,
126
136
  notCompiled: 0,
127
137
  passRate: 0,
128
- byPriority: { Critical: 0, High: 0, Normal: 0, Low: 0 },
138
+ byPriority: { High: 0, Normal: 0, Low: 0 },
129
139
  byCategory: { Accessing: 0, GUI: 0, Function: 0 },
130
140
  byType: { Auto: 0, Manual: 0, 'Not compiled': 0 },
131
141
  };
@@ -269,5 +279,29 @@ function collectEnvironment(cwd: string, env: EnvironmentInfo) {
269
279
  };
270
280
  }
271
281
 
282
+ /**
283
+ * Read the entry-point path for a flow from its selectors YAML. We pick the
284
+ * first selector whose `type` is `page` — that's the convention sungen uses
285
+ * for the page-selector block in flow YAML files. Returns undefined when the
286
+ * file is missing or has no page entry.
287
+ */
288
+ function readPagePathFromSelectors(selectorsFile: string): string | undefined {
289
+ if (!fs.existsSync(selectorsFile)) return undefined;
290
+ try {
291
+ const raw = fs.readFileSync(selectorsFile, 'utf-8');
292
+ const parsed = parseYaml(raw);
293
+ if (!parsed || typeof parsed !== 'object') return undefined;
294
+ for (const value of Object.values(parsed as Record<string, unknown>)) {
295
+ if (value && typeof value === 'object' && (value as { type?: string }).type === 'page') {
296
+ const v = (value as { value?: unknown }).value;
297
+ if (typeof v === 'string' && v.length > 0) return v;
298
+ }
299
+ }
300
+ } catch {
301
+ // Malformed YAML — fall through to undefined.
302
+ }
303
+ return undefined;
304
+ }
305
+
272
306
  // Helper for ScenarioSnapshot tree filters in UI (re-exported for callers)
273
307
  export type { ScenarioSnapshot };