ff-automationv2 2.1.2 → 2.1.3-beta.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.
package/package.json
CHANGED
|
@@ -14,12 +14,64 @@ import { DomProcessingEngine } from "../../domAnalysis/getRelaventElements.js"
|
|
|
14
14
|
import { getAnnotatedDOM } from "../../utils/DomExtraction/jsForAttributeInjection.js"
|
|
15
15
|
import { logger } from "../../utils/logger/logData.js"
|
|
16
16
|
export class AutomationRunner implements IAutomationRunner {
|
|
17
|
+
static sessionTerminationDetails: Record<string, boolean> = {};
|
|
17
18
|
constructor(
|
|
18
19
|
private readonly request: AutomationRequest,
|
|
19
20
|
private pageLoad: number = 20000,
|
|
20
21
|
private implicit: number = 15000,
|
|
21
22
|
private tokensConsumed: number = 0
|
|
22
|
-
|
|
23
|
+
|
|
24
|
+
) { AutomationRunner.sessionTerminationDetails[request.testCaseId] = false }
|
|
25
|
+
|
|
26
|
+
static getSessionTerminationInfo(testCaseId: string): boolean {
|
|
27
|
+
return AutomationRunner.sessionTerminationDetails[testCaseId]
|
|
28
|
+
}
|
|
29
|
+
static updateSessionTerminationInfo(testCaseId: string): void {
|
|
30
|
+
AutomationRunner.sessionTerminationDetails[testCaseId] = true
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
private async cleanup(
|
|
34
|
+
context: ExecutionContext,
|
|
35
|
+
domInfo: any,
|
|
36
|
+
extractedRelevantDom: any,
|
|
37
|
+
stepProcessor: StepProcessor,
|
|
38
|
+
scriptRunner: ScriptRunner
|
|
39
|
+
) {
|
|
40
|
+
try {
|
|
41
|
+
logger.info("Starting cleanup process...");
|
|
42
|
+
if (context?.session) {
|
|
43
|
+
try {
|
|
44
|
+
const browser = await context.session.getCurrentBrowser();
|
|
45
|
+
if (browser) {
|
|
46
|
+
await browser.deleteSession?.();
|
|
47
|
+
}
|
|
48
|
+
} catch (e) {
|
|
49
|
+
logger.error("Browser cleanup failed:", e);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
domInfo = null;
|
|
54
|
+
extractedRelevantDom = null;
|
|
55
|
+
|
|
56
|
+
if (stepProcessor) {
|
|
57
|
+
(stepProcessor as any).llm = null;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
scriptRunner = null as any;
|
|
61
|
+
|
|
62
|
+
delete AutomationRunner.sessionTerminationDetails[this.request.testCaseId];
|
|
63
|
+
|
|
64
|
+
if (global.gc) {
|
|
65
|
+
global.gc();
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
logger.info("Cleanup completed successfully.");
|
|
69
|
+
}
|
|
70
|
+
catch (error) {
|
|
71
|
+
logger.error("Cleanup error:", error);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
23
75
|
|
|
24
76
|
async run(): Promise<void> {
|
|
25
77
|
const apiService = new FireFlinkApiService();
|
|
@@ -47,6 +99,8 @@ export class AutomationRunner implements IAutomationRunner {
|
|
|
47
99
|
}
|
|
48
100
|
for (const step of listOfSteps) {
|
|
49
101
|
try {
|
|
102
|
+
if (AutomationRunner.getSessionTerminationInfo(this.request.testCaseId)) { break; }
|
|
103
|
+
|
|
50
104
|
const start = Math.max(0, stepCount - 3);
|
|
51
105
|
const end = Math.min(listOfSteps.length, stepCount + 3);
|
|
52
106
|
const priorAndNextSteps = listOfSteps.slice(start, end);
|
|
@@ -184,5 +238,14 @@ export class AutomationRunner implements IAutomationRunner {
|
|
|
184
238
|
"Failed to send payload to FireFlink API:", { cause: error }
|
|
185
239
|
);
|
|
186
240
|
}
|
|
241
|
+
finally {
|
|
242
|
+
await this.cleanup(
|
|
243
|
+
context,
|
|
244
|
+
domInfo,
|
|
245
|
+
extractedRelevantDom,
|
|
246
|
+
stepProcessor,
|
|
247
|
+
scriptRunner
|
|
248
|
+
);
|
|
249
|
+
}
|
|
187
250
|
}
|
|
188
251
|
}
|