testchimp-runner-core 0.0.19 → 0.0.21
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.
- package/dist/script-utils.d.ts +6 -0
- package/dist/script-utils.d.ts.map +1 -1
- package/dist/script-utils.js +32 -3
- package/dist/script-utils.js.map +1 -1
- package/package.json +1 -1
- package/src/script-utils.ts +36 -3
package/dist/script-utils.d.ts
CHANGED
|
@@ -15,6 +15,12 @@ export declare const TESTCHIMP_SMART_COMMENT = "/*\n\nThis is a TestChimp Smart
|
|
|
15
15
|
* @returns The complete comment block
|
|
16
16
|
*/
|
|
17
17
|
export declare function generateTestChimpComment(repairAdvice?: string, hashtags?: string[]): string;
|
|
18
|
+
/**
|
|
19
|
+
* Extracts hashtags from an existing TestChimp comment
|
|
20
|
+
* @param script The script content containing the comment
|
|
21
|
+
* @returns Array of hashtags found in the comment
|
|
22
|
+
*/
|
|
23
|
+
export declare function extractHashtagsFromComment(script: string): string[];
|
|
18
24
|
/**
|
|
19
25
|
* Adds the TestChimp smart test comment to the beginning of a script
|
|
20
26
|
* @param script The original script content
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"script-utils.d.ts","sourceRoot":"","sources":["../src/script-utils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;GAEG;AACH,eAAO,MAAM,uBAAuB,8DAKjC,CAAC;AAEJ;;;;;GAKG;AACH,wBAAgB,wBAAwB,CAAC,YAAY,CAAC,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,EAAE,GAAG,MAAM,CAwB3F;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,EAAE,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"script-utils.d.ts","sourceRoot":"","sources":["../src/script-utils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;GAEG;AACH,eAAO,MAAM,uBAAuB,8DAKjC,CAAC;AAEJ;;;;;GAKG;AACH,wBAAgB,wBAAwB,CAAC,YAAY,CAAC,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,EAAE,GAAG,MAAM,CAwB3F;AAED;;;;GAIG;AACH,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAqBnE;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,EAAE,GAAG,MAAM,CAqBtG;AAED;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,KAAK,CAAC;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAC;IAAC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC,EACxG,YAAY,CAAC,EAAE,MAAM,EACrB,QAAQ,CAAC,EAAE,MAAM,EAAE,GAClB,MAAM,CA0BR;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAG9D"}
|
package/dist/script-utils.js
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.TESTCHIMP_SMART_COMMENT = void 0;
|
|
10
10
|
exports.generateTestChimpComment = generateTestChimpComment;
|
|
11
|
+
exports.extractHashtagsFromComment = extractHashtagsFromComment;
|
|
11
12
|
exports.addTestChimpComment = addTestChimpComment;
|
|
12
13
|
exports.generateTestScript = generateTestScript;
|
|
13
14
|
exports.isTestChimpManagedTest = isTestChimpManagedTest;
|
|
@@ -50,6 +51,30 @@ ${hashtagString}
|
|
|
50
51
|
|
|
51
52
|
*/`;
|
|
52
53
|
}
|
|
54
|
+
/**
|
|
55
|
+
* Extracts hashtags from an existing TestChimp comment
|
|
56
|
+
* @param script The script content containing the comment
|
|
57
|
+
* @returns Array of hashtags found in the comment
|
|
58
|
+
*/
|
|
59
|
+
function extractHashtagsFromComment(script) {
|
|
60
|
+
const commentMatch = script.match(/\/\*[\s\S]*?This is a TestChimp (Managed|Smart) Test\.[\s\S]*?\*\//);
|
|
61
|
+
if (!commentMatch) {
|
|
62
|
+
return [];
|
|
63
|
+
}
|
|
64
|
+
const comment = commentMatch[0];
|
|
65
|
+
// Look for any line in the comment that starts with #
|
|
66
|
+
const hashtags = [];
|
|
67
|
+
const lines = comment.split('\n');
|
|
68
|
+
for (const line of lines) {
|
|
69
|
+
const trimmedLine = line.trim();
|
|
70
|
+
if (trimmedLine.startsWith('#')) {
|
|
71
|
+
// Extract hashtags from this line
|
|
72
|
+
const lineHashtags = trimmedLine.match(/#\w+/g) || [];
|
|
73
|
+
hashtags.push(...lineHashtags);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return hashtags;
|
|
77
|
+
}
|
|
53
78
|
/**
|
|
54
79
|
* Adds the TestChimp smart test comment to the beginning of a script
|
|
55
80
|
* @param script The original script content
|
|
@@ -62,9 +87,13 @@ function addTestChimpComment(script, repairAdvice, hashtags) {
|
|
|
62
87
|
// Prioritize Smart Test detection, fallback to Managed Test for backward compatibility
|
|
63
88
|
if (script.includes('This is a TestChimp Smart Test') || script.includes('This is a TestChimp Managed Test')) {
|
|
64
89
|
if (repairAdvice) {
|
|
65
|
-
//
|
|
90
|
+
// Extract existing hashtags from the current comment
|
|
91
|
+
const existingHashtags = extractHashtagsFromComment(script);
|
|
92
|
+
// Use existing hashtags if no new ones provided, otherwise use new ones
|
|
93
|
+
const finalHashtags = hashtags && hashtags.length > 0 ? hashtags : existingHashtags;
|
|
94
|
+
// Replace existing comment with new one that includes repair advice and preserved hashtags
|
|
66
95
|
const commentRegex = /\/\*[\s\S]*?This is a TestChimp (Managed|Smart) Test\.[\s\S]*?\*\//;
|
|
67
|
-
const newComment = generateTestChimpComment(repairAdvice,
|
|
96
|
+
const newComment = generateTestChimpComment(repairAdvice, finalHashtags);
|
|
68
97
|
return script.replace(commentRegex, newComment);
|
|
69
98
|
}
|
|
70
99
|
return script;
|
|
@@ -94,7 +123,7 @@ function generateTestScript(testName, steps, repairAdvice, hashtags) {
|
|
|
94
123
|
// Add steps
|
|
95
124
|
for (const step of steps) {
|
|
96
125
|
const status = step.success === false ? ' [FAILED]' : '';
|
|
97
|
-
scriptLines.push(` //
|
|
126
|
+
scriptLines.push(` // ${step.description}${status}`);
|
|
98
127
|
if (step.playwrightCommand && step.success !== false) {
|
|
99
128
|
scriptLines.push(` ${step.playwrightCommand}`);
|
|
100
129
|
}
|
package/dist/script-utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"script-utils.js","sourceRoot":"","sources":["../src/script-utils.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAkBH,4DAwBC;AASD,
|
|
1
|
+
{"version":3,"file":"script-utils.js","sourceRoot":"","sources":["../src/script-utils.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAkBH,4DAwBC;AAOD,gEAqBC;AASD,kDAqBC;AAUD,gDA+BC;AAQD,wDAGC;AAtJD;;GAEG;AACU,QAAA,uBAAuB,GAAG;;;;;GAKpC,CAAC;AAEJ;;;;;GAKG;AACH,SAAgB,wBAAwB,CAAC,YAAqB,EAAE,QAAmB;IACjF,MAAM,aAAa,GAAG,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,GAAG,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IAE3G,IAAI,YAAY,EAAE,CAAC;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AC,iBAAiB,IAAI,IAAI,CAAC,OAAO,KAAK,KAAK,EAAE,CAAC;YACrD,WAAW,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC,iBAAiB,EAAE,CAAC,CAAC;QAClD,CAAC;IACH,CAAC;IAED,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAExB,OAAO,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAChC,CAAC;AAED;;;;;GAKG;AACH,SAAgB,sBAAsB,CAAC,MAAc;IACnD,uFAAuF;IACvF,OAAO,MAAM,CAAC,QAAQ,CAAC,gCAAgC,CAAC,IAAI,MAAM,CAAC,QAAQ,CAAC,kCAAkC,CAAC,CAAC;AAClH,CAAC"}
|
package/package.json
CHANGED
package/src/script-utils.ts
CHANGED
|
@@ -47,6 +47,34 @@ ${hashtagString}
|
|
|
47
47
|
*/`;
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
+
/**
|
|
51
|
+
* Extracts hashtags from an existing TestChimp comment
|
|
52
|
+
* @param script The script content containing the comment
|
|
53
|
+
* @returns Array of hashtags found in the comment
|
|
54
|
+
*/
|
|
55
|
+
export function extractHashtagsFromComment(script: string): string[] {
|
|
56
|
+
const commentMatch = script.match(/\/\*[\s\S]*?This is a TestChimp (Managed|Smart) Test\.[\s\S]*?\*\//);
|
|
57
|
+
if (!commentMatch) {
|
|
58
|
+
return [];
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const comment = commentMatch[0];
|
|
62
|
+
// Look for any line in the comment that starts with #
|
|
63
|
+
const hashtags: string[] = [];
|
|
64
|
+
const lines = comment.split('\n');
|
|
65
|
+
|
|
66
|
+
for (const line of lines) {
|
|
67
|
+
const trimmedLine = line.trim();
|
|
68
|
+
if (trimmedLine.startsWith('#')) {
|
|
69
|
+
// Extract hashtags from this line
|
|
70
|
+
const lineHashtags = trimmedLine.match(/#\w+/g) || [];
|
|
71
|
+
hashtags.push(...lineHashtags);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return hashtags;
|
|
76
|
+
}
|
|
77
|
+
|
|
50
78
|
/**
|
|
51
79
|
* Adds the TestChimp smart test comment to the beginning of a script
|
|
52
80
|
* @param script The original script content
|
|
@@ -59,9 +87,14 @@ export function addTestChimpComment(script: string, repairAdvice?: string, hasht
|
|
|
59
87
|
// Prioritize Smart Test detection, fallback to Managed Test for backward compatibility
|
|
60
88
|
if (script.includes('This is a TestChimp Smart Test') || script.includes('This is a TestChimp Managed Test')) {
|
|
61
89
|
if (repairAdvice) {
|
|
62
|
-
//
|
|
90
|
+
// Extract existing hashtags from the current comment
|
|
91
|
+
const existingHashtags = extractHashtagsFromComment(script);
|
|
92
|
+
// Use existing hashtags if no new ones provided, otherwise use new ones
|
|
93
|
+
const finalHashtags = hashtags && hashtags.length > 0 ? hashtags : existingHashtags;
|
|
94
|
+
|
|
95
|
+
// Replace existing comment with new one that includes repair advice and preserved hashtags
|
|
63
96
|
const commentRegex = /\/\*[\s\S]*?This is a TestChimp (Managed|Smart) Test\.[\s\S]*?\*\//;
|
|
64
|
-
const newComment = generateTestChimpComment(repairAdvice,
|
|
97
|
+
const newComment = generateTestChimpComment(repairAdvice, finalHashtags);
|
|
65
98
|
return script.replace(commentRegex, newComment);
|
|
66
99
|
}
|
|
67
100
|
return script;
|
|
@@ -102,7 +135,7 @@ export function generateTestScript(
|
|
|
102
135
|
// Add steps
|
|
103
136
|
for (const step of steps) {
|
|
104
137
|
const status = step.success === false ? ' [FAILED]' : '';
|
|
105
|
-
scriptLines.push(` //
|
|
138
|
+
scriptLines.push(` // ${step.description}${status}`);
|
|
106
139
|
if (step.playwrightCommand && step.success !== false) {
|
|
107
140
|
scriptLines.push(` ${step.playwrightCommand}`);
|
|
108
141
|
}
|