1
+ import { CxWrapper } from '../main/wrapper/CxWrapper' ;
2
+ import { CxCommandOutput } from "../main/wrapper/CxCommandOutput" ;
3
+ import { BaseTest } from "./BaseTest" ;
4
+
5
+ describe ( "Telemetry cases" , ( ) => {
6
+ const cxScanConfig = new BaseTest ( ) ;
7
+
8
+ it ( 'TelemetryAIEvent Successful case with minimal parameters' , async ( ) => {
9
+ const wrapper = new CxWrapper ( cxScanConfig ) ;
10
+ const timestamp = new Date ( ) ;
11
+ const cxCommandOutput : CxCommandOutput = await wrapper . telemetryAIEvent (
12
+ "Cursor" ,
13
+ "Cursos" ,
14
+ timestamp ,
15
+ "click" ,
16
+ "ast-results.viewPackageDetails" ,
17
+ "secrets" ,
18
+ "high"
19
+ ) ;
20
+ console . log ( "Json object from telemetryAIEvent successful case: " + JSON . stringify ( cxCommandOutput ) ) ;
21
+ expect ( cxCommandOutput . exitCode ) . toBe ( 0 ) ;
22
+ } ) ;
23
+
24
+ it ( 'TelemetryAIEvent Successful case with past timestamp' , async ( ) => {
25
+ const wrapper = new CxWrapper ( cxScanConfig ) ;
26
+ const pastTimestamp = new Date ( Date . now ( ) - 3600000 ) ; // 1 hour ago
27
+ const cxCommandOutput : CxCommandOutput = await wrapper . telemetryAIEvent (
28
+ "openai" ,
29
+ "vscode" ,
30
+ pastTimestamp ,
31
+ "click" ,
32
+ "ast-results.viewPackageDetails" ,
33
+ "oss" ,
34
+ "high"
35
+ ) ;
36
+ console . log ( "Json object from telemetryAIEvent with past timestamp: " + JSON . stringify ( cxCommandOutput ) ) ;
37
+ expect ( cxCommandOutput . exitCode ) . toBe ( 0 ) ;
38
+ } ) ;
39
+
40
+ it ( 'TelemetryAIEvent Successful case with edge case parameters' , async ( ) => {
41
+ const wrapper = new CxWrapper ( cxScanConfig ) ;
42
+ const timestamp = new Date ( ) ;
43
+ const cxCommandOutput : CxCommandOutput = await wrapper . telemetryAIEvent (
44
+ "" ,
45
+ "" ,
46
+ timestamp ,
47
+ "" ,
48
+ "" ,
49
+ "" ,
50
+ ""
51
+ ) ;
52
+ console . log ( "Json object from telemetryAIEvent with empty parameters: " + JSON . stringify ( cxCommandOutput ) ) ;
53
+ expect ( typeof cxCommandOutput . exitCode ) . toBe ( 0 ) ;
54
+ } ) ;
55
+
56
+ it ( 'TelemetryAIEvent Successful case without timestamp' , async ( ) => {
57
+ const wrapper = new CxWrapper ( cxScanConfig ) ;
58
+ const cxCommandOutput : CxCommandOutput = await wrapper . telemetryAIEvent (
59
+ "Copilot" ,
60
+ "VS Code" ,
61
+ undefined ,
62
+ "click" ,
63
+ "ast-results.viewPackageDetails" ,
64
+ "oss" ,
65
+ "medium"
66
+ ) ;
67
+ console . log ( "Json object from telemetryAIEvent without timestamp: " + JSON . stringify ( cxCommandOutput ) ) ;
68
+ expect ( typeof cxCommandOutput . exitCode ) . toBe ( 0 ) ;
69
+ } ) ;
70
+ } ) ;
0 commit comments