@testivai/witness-cdp 1.0.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 (75) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +405 -0
  3. package/dist/__tests__/setup.d.ts +4 -0
  4. package/dist/__tests__/setup.d.ts.map +1 -0
  5. package/dist/__tests__/setup.js +24 -0
  6. package/dist/__tests__/setup.js.map +1 -0
  7. package/dist/bin/testivai.d.ts +3 -0
  8. package/dist/bin/testivai.d.ts.map +1 -0
  9. package/dist/bin/testivai.js +48 -0
  10. package/dist/bin/testivai.js.map +1 -0
  11. package/dist/cdp/binding.d.ts +56 -0
  12. package/dist/cdp/binding.d.ts.map +1 -0
  13. package/dist/cdp/binding.js +364 -0
  14. package/dist/cdp/binding.js.map +1 -0
  15. package/dist/cdp/capture.d.ts +61 -0
  16. package/dist/cdp/capture.d.ts.map +1 -0
  17. package/dist/cdp/capture.js +422 -0
  18. package/dist/cdp/capture.js.map +1 -0
  19. package/dist/cdp/client.d.ts +63 -0
  20. package/dist/cdp/client.d.ts.map +1 -0
  21. package/dist/cdp/client.js +279 -0
  22. package/dist/cdp/client.js.map +1 -0
  23. package/dist/cdp/discovery.d.ts +33 -0
  24. package/dist/cdp/discovery.d.ts.map +1 -0
  25. package/dist/cdp/discovery.js +157 -0
  26. package/dist/cdp/discovery.js.map +1 -0
  27. package/dist/ci.d.ts +31 -0
  28. package/dist/ci.d.ts.map +1 -0
  29. package/dist/ci.js +118 -0
  30. package/dist/ci.js.map +1 -0
  31. package/dist/commands/auth.d.ts +3 -0
  32. package/dist/commands/auth.d.ts.map +1 -0
  33. package/dist/commands/auth.js +122 -0
  34. package/dist/commands/auth.js.map +1 -0
  35. package/dist/commands/capture.d.ts +3 -0
  36. package/dist/commands/capture.d.ts.map +1 -0
  37. package/dist/commands/capture.js +143 -0
  38. package/dist/commands/capture.js.map +1 -0
  39. package/dist/commands/init.d.ts +3 -0
  40. package/dist/commands/init.d.ts.map +1 -0
  41. package/dist/commands/init.js +255 -0
  42. package/dist/commands/init.js.map +1 -0
  43. package/dist/commands/run.d.ts +3 -0
  44. package/dist/commands/run.d.ts.map +1 -0
  45. package/dist/commands/run.js +438 -0
  46. package/dist/commands/run.js.map +1 -0
  47. package/dist/index.d.ts +20 -0
  48. package/dist/index.d.ts.map +1 -0
  49. package/dist/index.js +77 -0
  50. package/dist/index.js.map +1 -0
  51. package/dist/types.d.ts +329 -0
  52. package/dist/types.d.ts.map +1 -0
  53. package/dist/types.js +7 -0
  54. package/dist/types.js.map +1 -0
  55. package/dist/utils/file-naming.d.ts +31 -0
  56. package/dist/utils/file-naming.d.ts.map +1 -0
  57. package/dist/utils/file-naming.js +137 -0
  58. package/dist/utils/file-naming.js.map +1 -0
  59. package/dist/utils/framework-detect.d.ts +31 -0
  60. package/dist/utils/framework-detect.d.ts.map +1 -0
  61. package/dist/utils/framework-detect.js +379 -0
  62. package/dist/utils/framework-detect.js.map +1 -0
  63. package/dist/utils/logger.d.ts +29 -0
  64. package/dist/utils/logger.d.ts.map +1 -0
  65. package/dist/utils/logger.js +114 -0
  66. package/dist/utils/logger.js.map +1 -0
  67. package/dist/utils/process.d.ts +61 -0
  68. package/dist/utils/process.d.ts.map +1 -0
  69. package/dist/utils/process.js +208 -0
  70. package/dist/utils/process.js.map +1 -0
  71. package/dist/utils/template-generator.d.ts +36 -0
  72. package/dist/utils/template-generator.d.ts.map +1 -0
  73. package/dist/utils/template-generator.js +255 -0
  74. package/dist/utils/template-generator.js.map +1 -0
  75. package/package.json +66 -0
@@ -0,0 +1,329 @@
1
+ /**
2
+ * Types for TestivAI CDP SDK
3
+ * Extends types from @testivai/common with CDP-specific additions
4
+ */
5
+ import { TestivaiConfig } from '@testivai/common';
6
+ /**
7
+ * CDP-specific configuration extending the base TestivaiConfig
8
+ */
9
+ export interface CdpConfig extends TestivaiConfig {
10
+ /** Chrome DevTools Protocol port */
11
+ cdpPort?: number;
12
+ /** Project ID from TestivAI dashboard */
13
+ projectId?: string;
14
+ /** Auto-launch Chrome if not running */
15
+ autoLaunch?: boolean;
16
+ /** Chrome executable path (for auto-launch) */
17
+ chromePath?: string;
18
+ /** Additional Chrome launch arguments */
19
+ chromeArgs?: string[];
20
+ /** Timeout for CDP connections (ms) */
21
+ connectionTimeout?: number;
22
+ /** Retry attempts for CDP connection */
23
+ connectionRetries?: number;
24
+ /** Enable debug logging */
25
+ debug?: boolean;
26
+ }
27
+ /**
28
+ * Git information for batch context
29
+ */
30
+ export interface GitInfo {
31
+ /** Current branch name */
32
+ branch: string;
33
+ /** Current commit hash */
34
+ commit: string;
35
+ /** Repository URL (optional) */
36
+ repository?: string;
37
+ /** Commit message (optional) */
38
+ message?: string;
39
+ /** Author name (optional) */
40
+ author?: string;
41
+ }
42
+ /**
43
+ * Browser context information
44
+ */
45
+ export interface BrowserInfo {
46
+ /** Browser name (chromium, firefox, webkit) */
47
+ name: string;
48
+ /** Browser version */
49
+ version: string;
50
+ /** Viewport width */
51
+ viewportWidth: number;
52
+ /** Viewport height */
53
+ viewportHeight: number;
54
+ /** User agent string */
55
+ userAgent: string;
56
+ /** Operating system */
57
+ os?: string;
58
+ /** Device type (desktop, mobile, tablet) */
59
+ device?: string;
60
+ }
61
+ /**
62
+ * Page structure snapshot data (HTML content)
63
+ * @renamed Was `DOMData` — renamed to conceal internal layer terminology (IP protection)
64
+ */
65
+ export interface StructureData {
66
+ /** Serialized HTML of the element */
67
+ html: string;
68
+ /** Computed styles (optional) */
69
+ styles?: Record<string, string>;
70
+ }
71
+ /**
72
+ * Layout/Bounding box data for an element
73
+ */
74
+ export interface LayoutData {
75
+ /** X coordinate */
76
+ x: number;
77
+ /** Y coordinate */
78
+ y: number;
79
+ /** Width */
80
+ width: number;
81
+ /** Height */
82
+ height: number;
83
+ /** Top position */
84
+ top: number;
85
+ /** Left position */
86
+ left: number;
87
+ /** Right position */
88
+ right: number;
89
+ /** Bottom position */
90
+ bottom: number;
91
+ }
92
+ /**
93
+ * Unified Performance metrics for both Playwright and CDP SDKs
94
+ */
95
+ export interface CDPerformanceMetrics {
96
+ /** CDP runtime metrics */
97
+ cdp?: {
98
+ Timestamp?: number;
99
+ Documents?: number;
100
+ Frames?: number;
101
+ JSEventListeners?: number;
102
+ Nodes?: number;
103
+ LayoutCount?: number;
104
+ RecalcStyleCount?: number;
105
+ LayoutDuration?: number;
106
+ RecalcStyleDuration?: number;
107
+ ScriptDuration?: number;
108
+ TaskDuration?: number;
109
+ JSHeapUsedSize?: number;
110
+ JSHeapTotalSize?: number;
111
+ };
112
+ /** Navigation timing and Web Vitals */
113
+ timing?: {
114
+ navigation?: {
115
+ type: number;
116
+ redirectCount: number;
117
+ };
118
+ timing?: {
119
+ navigationStart: number;
120
+ unloadEventStart: number;
121
+ unloadEventEnd: number;
122
+ redirectStart: number;
123
+ redirectEnd: number;
124
+ fetchStart: number;
125
+ domainLookupStart: number;
126
+ domainLookupEnd: number;
127
+ connectStart: number;
128
+ connectEnd: number;
129
+ secureConnectionStart: number;
130
+ requestStart: number;
131
+ responseStart: number;
132
+ responseEnd: number;
133
+ domLoading: number;
134
+ domInteractive: number;
135
+ domContentLoadedEventStart: number;
136
+ domContentLoadedEventEnd: number;
137
+ domComplete: number;
138
+ loadEventStart: number;
139
+ loadEventEnd: number;
140
+ };
141
+ webVitals?: {
142
+ firstContentfulPaint?: number;
143
+ largestContentfulPaint?: number;
144
+ cumulativeLayoutShift?: number;
145
+ firstInputDelay?: number;
146
+ };
147
+ };
148
+ /** Timestamp when metrics were captured */
149
+ timestamp?: number;
150
+ }
151
+ /**
152
+ * Performance timing metrics
153
+ * @deprecated Use CDPerformanceMetrics instead
154
+ */
155
+ export interface PerformanceTimings {
156
+ /** Navigation start time */
157
+ navigationStart?: number;
158
+ /** DOM content loaded time */
159
+ domContentLoaded?: number;
160
+ /** Page load complete time */
161
+ loadComplete?: number;
162
+ /** First contentful paint */
163
+ firstContentfulPaint?: number;
164
+ /** Largest contentful paint */
165
+ largestContentfulPaint?: number;
166
+ /** Time to interactive */
167
+ timeToInteractive?: number;
168
+ /** Total blocking time */
169
+ totalBlockingTime?: number;
170
+ /** Cumulative layout shift */
171
+ cumulativeLayoutShift?: number;
172
+ }
173
+ /**
174
+ * Lighthouse performance results
175
+ */
176
+ export interface LighthouseResults {
177
+ /** Performance score (0-100) */
178
+ performance?: number;
179
+ /** Accessibility score (0-100) */
180
+ accessibility?: number;
181
+ /** Best practices score (0-100) */
182
+ bestPractices?: number;
183
+ /** SEO score (0-100) */
184
+ seo?: number;
185
+ /** Core Web Vitals */
186
+ coreWebVitals?: {
187
+ lcp?: number;
188
+ fid?: number;
189
+ cls?: number;
190
+ };
191
+ }
192
+ /**
193
+ * Snapshot payload for a single evidence capture
194
+ */
195
+ export interface SnapshotPayload {
196
+ /**
197
+ * Page structure data (HTML content)
198
+ * @renamed Was `dom` — renamed to conceal internal layer terminology (IP protection)
199
+ */
200
+ structure: StructureData;
201
+ /**
202
+ * Computed styles data (optional)
203
+ * @renamed Was `css` — renamed to conceal internal layer terminology (IP protection)
204
+ */
205
+ styles?: {
206
+ computed_styles: Record<string, Record<string, string>>;
207
+ };
208
+ /** Layout/bounding box data */
209
+ layout: LayoutData;
210
+ /** Timestamp when snapshot was taken */
211
+ timestamp: number;
212
+ /** Test name or identifier */
213
+ testName: string;
214
+ /** Snapshot name or identifier */
215
+ snapshotName: string;
216
+ /** URL of the page when snapshot was taken */
217
+ url?: string;
218
+ /** Viewport dimensions */
219
+ viewport?: {
220
+ width: number;
221
+ height: number;
222
+ };
223
+ /** Screenshot data (base64) */
224
+ screenshotData?: string;
225
+ /** Performance metrics */
226
+ performanceMetrics?: CDPerformanceMetrics;
227
+ }
228
+ /**
229
+ * CI environment information for integration feedback (e.g., GitHub commit statuses, PR comments).
230
+ * Mirrors CiInfo from ci.ts for payload serialization.
231
+ */
232
+ export interface CiInfoPayload {
233
+ /** CI provider name (e.g., 'github_actions', 'gitlab_ci', 'circleci') */
234
+ provider: string;
235
+ /** Pull/Merge request number (if available) */
236
+ prNumber?: number;
237
+ /** URL to the CI run (if available) */
238
+ runUrl?: string;
239
+ /** CI build/run identifier */
240
+ buildId?: string;
241
+ }
242
+ /**
243
+ * Batch payload containing all evidence for a test run
244
+ */
245
+ export interface BatchPayload {
246
+ /** Git information */
247
+ git: GitInfo;
248
+ /** Browser context information */
249
+ browser: BrowserInfo;
250
+ /** Collection of snapshots */
251
+ snapshots: SnapshotPayload[];
252
+ /** Timestamp when batch was created */
253
+ timestamp: number;
254
+ /** Unique identifier for a CI/CD run, to group sharded jobs */
255
+ runId?: string | null;
256
+ /** CI environment information for integration feedback (optional) */
257
+ ci?: CiInfoPayload | null;
258
+ /** Additional metadata */
259
+ metadata?: Record<string, unknown>;
260
+ }
261
+ /**
262
+ * CDP connection information
263
+ */
264
+ export interface CdpConnectionInfo {
265
+ /** WebSocket URL for CDP connection */
266
+ webSocketDebuggerUrl: string;
267
+ /** Chrome devtools URL */
268
+ devtoolsFrontendUrl: string;
269
+ /** Browser ID */
270
+ id: string;
271
+ /** Browser title */
272
+ title?: string;
273
+ /** Browser URL */
274
+ url?: string;
275
+ /** Browser version */
276
+ browserVersion?: string;
277
+ /** Protocol version */
278
+ protocolVersion?: string;
279
+ /** User agent */
280
+ userAgent?: string;
281
+ /** V8 version */
282
+ v8Version?: string;
283
+ /** WebKit version */
284
+ webKitVersion?: string;
285
+ }
286
+ /**
287
+ * Framework detection result
288
+ */
289
+ export interface FrameworkDetection {
290
+ /** Detected framework */
291
+ framework: 'cypress' | 'webdriverio' | 'selenium-js' | 'selenium-python' | 'unknown';
292
+ /** Confidence level (0-1) */
293
+ confidence: number;
294
+ /** Evidence for detection */
295
+ evidence: string[];
296
+ /** Configuration files found */
297
+ configFiles: string[];
298
+ /** Instructions for setup */
299
+ instructions: string[];
300
+ }
301
+ /**
302
+ * Command execution result
303
+ */
304
+ export interface CommandResult {
305
+ /** Exit code */
306
+ exitCode: number;
307
+ /** Signal that terminated the process */
308
+ signal: string | null;
309
+ /** Standard output */
310
+ stdout: string;
311
+ /** Standard error */
312
+ stderr: string;
313
+ /** Duration in milliseconds */
314
+ duration: number;
315
+ }
316
+ /**
317
+ * Batch upload result
318
+ */
319
+ export interface BatchResult {
320
+ /** Batch ID */
321
+ batchId: string;
322
+ /** Number of snapshots uploaded */
323
+ snapshotCount: number;
324
+ /** Upload duration in milliseconds */
325
+ duration: number;
326
+ /** Dashboard URL */
327
+ dashboardUrl?: string;
328
+ }
329
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD;;GAEG;AACH,MAAM,WAAW,SAAU,SAAQ,cAAc;IAC/C,oCAAoC;IACpC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,yCAAyC;IACzC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,wCAAwC;IACxC,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,+CAA+C;IAC/C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,yCAAyC;IACzC,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,uCAAuC;IACvC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,wCAAwC;IACxC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,2BAA2B;IAC3B,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,OAAO;IACtB,0BAA0B;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,0BAA0B;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,gCAAgC;IAChC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,gCAAgC;IAChC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,6BAA6B;IAC7B,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED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vB"}
package/dist/types.js ADDED
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ /**
3
+ * Types for TestivAI CDP SDK
4
+ * Extends types from @testivai/common with CDP-specific additions
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";AAAA;;;GAGG"}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * File naming utilities for TestivAI CDP SDK
3
+ * Converts snapshot names to safe filenames
4
+ */
5
+ /**
6
+ * Convert a snapshot name to a safe filename
7
+ * - Replace spaces with hyphens
8
+ * - Remove or replace special characters
9
+ * - Limit length
10
+ * - Ensure it's not empty
11
+ */
12
+ export declare function toSafeFilename(name: string): string;
13
+ /**
14
+ * Generate a unique filename with timestamp
15
+ */
16
+ export declare function generateUniqueFilename(name: string, extension?: string): string;
17
+ /**
18
+ * Extract snapshot name from a URL
19
+ * Useful for auto-generating names from page URLs
20
+ */
21
+ export declare function extractNameFromUrl(url: string): string;
22
+ /**
23
+ * Sanitize a name for use in test names
24
+ * Less restrictive than filename sanitization
25
+ */
26
+ export declare function sanitizeTestName(name: string): string;
27
+ /**
28
+ * Check if a filename is safe
29
+ */
30
+ export declare function isSafeFilename(filename: string): boolean;
31
+ //# sourceMappingURL=file-naming.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file-naming.d.ts","sourceRoot":"","sources":["../../src/utils/file-naming.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAwCnD;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,GAAE,MAAW,GAAG,MAAM,CAMnF;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CA6BtD;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAoBrD;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CA4BxD"}
@@ -0,0 +1,137 @@
1
+ "use strict";
2
+ /**
3
+ * File naming utilities for TestivAI CDP SDK
4
+ * Converts snapshot names to safe filenames
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.toSafeFilename = toSafeFilename;
8
+ exports.generateUniqueFilename = generateUniqueFilename;
9
+ exports.extractNameFromUrl = extractNameFromUrl;
10
+ exports.sanitizeTestName = sanitizeTestName;
11
+ exports.isSafeFilename = isSafeFilename;
12
+ /**
13
+ * Convert a snapshot name to a safe filename
14
+ * - Replace spaces with hyphens
15
+ * - Remove or replace special characters
16
+ * - Limit length
17
+ * - Ensure it's not empty
18
+ */
19
+ function toSafeFilename(name) {
20
+ if (!name || typeof name !== 'string') {
21
+ return 'snapshot';
22
+ }
23
+ // Remove leading/trailing whitespace
24
+ let filename = name.trim();
25
+ // If empty after trimming, use default
26
+ if (!filename) {
27
+ return 'snapshot';
28
+ }
29
+ // Replace spaces and common separators with hyphens
30
+ filename = filename.replace(/[\s_\/\\]+/g, '-');
31
+ // Remove invalid filename characters (Windows-safe)
32
+ // Keep: letters, numbers, hyphens, dots, underscores, parentheses
33
+ filename = filename.replace(/[<>:"|?*]/g, '');
34
+ // Replace multiple consecutive hyphens with single hyphen
35
+ filename = filename.replace(/-+/g, '-');
36
+ // Remove leading/trailing hyphens and dots
37
+ filename = filename.replace(/^[-\.]+|[-\.]+$/g, '');
38
+ // Limit length (255 is max for most filesystems, leave room for extension)
39
+ if (filename.length > 200) {
40
+ filename = filename.substring(0, 200);
41
+ // Remove trailing hyphen if we cut in the middle
42
+ filename = filename.replace(/-$/, '');
43
+ }
44
+ // If still empty after cleaning, use default
45
+ if (!filename) {
46
+ return 'snapshot';
47
+ }
48
+ // Convert to lowercase for consistency
49
+ return filename.toLowerCase();
50
+ }
51
+ /**
52
+ * Generate a unique filename with timestamp
53
+ */
54
+ function generateUniqueFilename(name, extension = '') {
55
+ const safeName = toSafeFilename(name);
56
+ const timestamp = new Date().toISOString().replace(/[:.]/g, '-');
57
+ const uniqueName = `${safeName}-${timestamp}`;
58
+ return extension ? `${uniqueName}.${extension.replace(/^\./, '')}` : uniqueName;
59
+ }
60
+ /**
61
+ * Extract snapshot name from a URL
62
+ * Useful for auto-generating names from page URLs
63
+ */
64
+ function extractNameFromUrl(url) {
65
+ try {
66
+ const urlObj = new URL(url);
67
+ const pathname = urlObj.pathname;
68
+ // Remove leading/trailing slashes
69
+ const cleanPath = pathname.replace(/^\/|\/$/g, '');
70
+ // If path is empty or just '/', use hostname
71
+ if (!cleanPath) {
72
+ return urlObj.hostname.replace(/\./g, '-');
73
+ }
74
+ // Convert path segments to name
75
+ const segments = cleanPath.split('/');
76
+ const lastSegment = segments[segments.length - 1];
77
+ // If last segment looks like an ID, use the parent
78
+ if (/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/i.test(lastSegment) ||
79
+ /^\d+$/.test(lastSegment)) {
80
+ return segments[segments.length - 2] || 'page';
81
+ }
82
+ return lastSegment || 'page';
83
+ }
84
+ catch {
85
+ // If URL parsing fails, extract from string
86
+ const matches = url.match(/\/([^\/]+)\/?$/);
87
+ return matches ? matches[1] : 'page';
88
+ }
89
+ }
90
+ /**
91
+ * Sanitize a name for use in test names
92
+ * Less restrictive than filename sanitization
93
+ */
94
+ function sanitizeTestName(name) {
95
+ if (!name || typeof name !== 'string') {
96
+ return 'test';
97
+ }
98
+ // Remove leading/trailing whitespace
99
+ let testName = name.trim();
100
+ // Replace multiple spaces with single space
101
+ testName = testName.replace(/\s+/g, ' ');
102
+ // Remove control characters
103
+ testName = testName.replace(/[\x00-\x1F\x7F]/g, '');
104
+ // Limit length
105
+ if (testName.length > 100) {
106
+ testName = testName.substring(0, 100);
107
+ }
108
+ return testName || 'test';
109
+ }
110
+ /**
111
+ * Check if a filename is safe
112
+ */
113
+ function isSafeFilename(filename) {
114
+ if (!filename || typeof filename !== 'string') {
115
+ return false;
116
+ }
117
+ // Check for invalid characters
118
+ if (/[<>:"|?*]/.test(filename)) {
119
+ return false;
120
+ }
121
+ // Check reserved names (Windows)
122
+ const reservedNames = [
123
+ 'CON', 'PRN', 'AUX', 'NUL',
124
+ 'COM1', 'COM2', 'COM3', 'COM4', 'COM5', 'COM6', 'COM7', 'COM8', 'COM9',
125
+ 'LPT1', 'LPT2', 'LPT3', 'LPT4', 'LPT5', 'LPT6', 'LPT7', 'LPT8', 'LPT9'
126
+ ];
127
+ const nameWithoutExt = filename.split('.')[0].toUpperCase();
128
+ if (reservedNames.includes(nameWithoutExt)) {
129
+ return false;
130
+ }
131
+ // Check length
132
+ if (filename.length > 255) {
133
+ return false;
134
+ }
135
+ return true;
136
+ }
137
+ //# sourceMappingURL=file-naming.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file-naming.js","sourceRoot":"","sources":["../../src/utils/file-naming.ts"],"names":[],"mappings":";AAAA;;;GAGG;;AASH,wCAwCC;AAKD,wDAMC;AAMD,gDA6BC;AAMD,4CAoBC;AAKD,wCA4BC;AAxJD;;;;;;GAMG;AACH,SAAgB,cAAc,CAAC,IAAY;IACzC,IAAI,CAAC,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;QACtC,OAAO,UAAU,CAAC;IACpB,CAAC;IAED,qCAAqC;IACrC,IAAI,QAAQ,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;IAE3B,uCAAuC;IACvC,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,OAAO,UAAU,CAAC;IACpB,CAAC;IAED,oDAAoD;IACpD,QAAQ,GAAG,QAAQ,CAAC,OAAO,CAAC,aAAa,EAAE,GAAG,CAAC,CAAC;IAEhD,oDAAoD;IACpD,kEAAkE;IAClE,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
+ import { FrameworkDetection } from '../types';
2
+ /**
3
+ * Framework detection utility
4
+ */
5
+ export declare class FrameworkDetector {
6
+ /**
7
+ * Detect the testing framework in use
8
+ */
9
+ static detect(): FrameworkDetection;
10
+ /**
11
+ * Detect Cypress
12
+ */
13
+ private static detectCypress;
14
+ /**
15
+ * Detect WebdriverIO
16
+ */
17
+ private static detectWebdriverIO;
18
+ /**
19
+ * Detect Selenium JS
20
+ */
21
+ private static detectSeleniumJS;
22
+ /**
23
+ * Detect Selenium Python
24
+ */
25
+ private static detectSeleniumPython;
26
+ /**
27
+ * Generate setup instructions for the detected framework
28
+ */
29
+ private static generateInstructions;
30
+ }
31
+ //# sourceMappingURL=framework-detect.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"framework-detect.d.ts","sourceRoot":"","sources":["../../src/utils/framework-detect.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAE9C;;GAEG;AACH,qBAAa,iBAAiB;IAC5B;;OAEG;IACH,MAAM,CAAC,MAAM,IAAI,kBAAkB;IA4DnC;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,aAAa;IAuC5B;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,iBAAiB;IAiChC;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,gBAAgB;IA8C/B;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,oBAAoB;IA4CnC;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,oBAAoB;CAuHpC"}