From 02ee0e48c449a3a576f55c84dc3946d7de989ee3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nidhi=20Tyagi=20=F0=9F=8C=9F=F0=9F=90=87=F0=9F=8C=B4?= =?UTF-8?q?=E2=9D=84=EF=B8=8F?= Date: Thu, 9 Nov 2023 14:41:46 +0530 Subject: [PATCH 1/5] Fix ErrorHandler test cases --- .../test/integration/errorHandler.test.ts | 39 +++++++++++-------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/src/web/client/test/integration/errorHandler.test.ts b/src/web/client/test/integration/errorHandler.test.ts index 02c275d3..42e83631 100644 --- a/src/web/client/test/integration/errorHandler.test.ts +++ b/src/web/client/test/integration/errorHandler.test.ts @@ -358,8 +358,10 @@ describe("errorHandler", () => { ); assert.calledOnceWithExactly( _mockSendErrorTelemetry, - 'triggeredMethod', - telemetryEventNames.WEB_EXTENSION_MANDATORY_PATH_PARAMETERS_MISSING + telemetryEventNames.WEB_EXTENSION_MANDATORY_PATH_PARAMETERS_MISSING, + checkMandatoryPathParameters.name, + `entity:, entityId:512e50bd-a9d1-44c0-ba3f-5dc7f46e7216`, + ); }); @@ -386,8 +388,9 @@ describe("errorHandler", () => { ); assert.calledOnceWithExactly( _mockSendErrorTelemetry, - 'triggeredMethod', - telemetryEventNames.WEB_EXTENSION_MANDATORY_PATH_PARAMETERS_MISSING + telemetryEventNames.WEB_EXTENSION_MANDATORY_PATH_PARAMETERS_MISSING, + checkMandatoryPathParameters.name, + `entity:entity, entityId:` ); }); @@ -425,7 +428,7 @@ describe("errorHandler", () => { expect(result).true; }); - it("checkMandatoryQueryParameters_whenORGURLIsBlank_shouldReturnFalse", () => { + it("checkMandatoryQueryParameters_whenOrgUrlIsBlank_shouldReturnFalse", () => { //Act const _mockShowErrorMessage = spy(vscode.window, "showErrorMessage"); const _mockSendErrorTelemetry = spy( @@ -459,12 +462,13 @@ describe("errorHandler", () => { ); assert.calledOnceWithExactly( _mockSendErrorTelemetry, - 'triggeredMethod', - telemetryEventNames.WEB_EXTENSION_MANDATORY_QUERY_PARAMETERS_MISSING + telemetryEventNames.WEB_EXTENSION_MANDATORY_QUERY_PARAMETERS_MISSING, + checkMandatoryQueryParameters.name, + `orgURL:, dataSource:SQL, schemaName:1.0.0.0 ,websiteId:ed9a6c19-5ab6-4f67-8c35-2423cff958c4` ); }); - it("checkMandatoryQueryParameters_whenDATASOURCEIsBlank_shouldReturnFalse", () => { + it("checkMandatoryQueryParameters_whenDataSourceIsBlank_shouldReturnFalse", () => { //Act const _mockShowErrorMessage = spy(vscode.window, "showErrorMessage"); const _mockSendErrorTelemetry = spy( @@ -497,12 +501,13 @@ describe("errorHandler", () => { ); assert.calledOnceWithExactly( _mockSendErrorTelemetry, - 'triggeredMethod', - telemetryEventNames.WEB_EXTENSION_MANDATORY_QUERY_PARAMETERS_MISSING + telemetryEventNames.WEB_EXTENSION_MANDATORY_QUERY_PARAMETERS_MISSING, + checkMandatoryQueryParameters.name, + `orgURL:ORG_URL, dataSource:, schemaName:1.0.0.0 ,websiteId:ed9a6c19-5ab6-4f67-8c35-2423cff958c4` ); }); - it("checkMandatoryQueryParameters_whenSCHEMAVERSIONIsBlank_shouldReturnFalse", () => { + it("checkMandatoryQueryParameters_whenSchemaVersionIsBlank_shouldReturnFalse", () => { //Act const _mockShowErrorMessage = spy(vscode.window, "showErrorMessage"); const _mockSendErrorTelemetry = spy( @@ -535,12 +540,13 @@ describe("errorHandler", () => { ); assert.calledOnceWithExactly( _mockSendErrorTelemetry, - 'triggeredMethod', - telemetryEventNames.WEB_EXTENSION_MANDATORY_QUERY_PARAMETERS_MISSING + telemetryEventNames.WEB_EXTENSION_MANDATORY_QUERY_PARAMETERS_MISSING, + checkMandatoryQueryParameters.name, + `orgURL:ORG_URL, dataSource:SQL, schemaName: ,websiteId:ed9a6c19-5ab6-4f67-8c35-2423cff958c4` ); }); - it("checkMandatoryQueryParameters_whenWEBSITEIDIsBlank_shouldReturnFalse", () => { + it("checkMandatoryQueryParameters_whenWebsiteIdIsBlank_shouldReturnFalse", () => { //Act const _mockShowErrorMessage = spy(vscode.window, "showErrorMessage"); const _mockSendErrorTelemetry = spy( @@ -570,8 +576,9 @@ describe("errorHandler", () => { ); assert.calledOnceWithExactly( _mockSendErrorTelemetry, - 'triggeredMethod', - telemetryEventNames.WEB_EXTENSION_MANDATORY_QUERY_PARAMETERS_MISSING + telemetryEventNames.WEB_EXTENSION_MANDATORY_QUERY_PARAMETERS_MISSING, + checkMandatoryQueryParameters.name, + `orgURL:ORG_URL, dataSource:SQL, schemaName:1.0.0.0 ,websiteId:` ); }); From f14a7e44e25ddf627c6a5abf01ea410a88f1531b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nidhi=20Tyagi=20=F0=9F=8C=9F=F0=9F=90=87=F0=9F=8C=B4?= =?UTF-8?q?=E2=9D=84=EF=B8=8F?= Date: Thu, 9 Nov 2023 14:59:32 +0530 Subject: [PATCH 2/5] Fix fileSystemProvider writeFile test case failure --- src/web/client/utilities/commonUtil.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/web/client/utilities/commonUtil.ts b/src/web/client/utilities/commonUtil.ts index 062a1e39..5e23d78f 100644 --- a/src/web/client/utilities/commonUtil.ts +++ b/src/web/client/utilities/commonUtil.ts @@ -172,7 +172,7 @@ export function getSanitizedFileName(fileName: string): string { // Get the file's extension export function getFileExtension(fileName: string): string | undefined { - return fileName.split('.').pop(); + return fileName.toString().split('.').pop(); } export function getFileExtensionForPreload() { From 6649e48de9e9ad0f7195e44f23fb03f7aed23540 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nidhi=20Tyagi=20=F0=9F=8C=9F=F0=9F=90=87=F0=9F=8C=B4?= =?UTF-8?q?=E2=9D=84=EF=B8=8F?= Date: Mon, 13 Nov 2023 11:32:09 +0530 Subject: [PATCH 3/5] Fix web extension telemetry test cases --- .../client/telemetry/webExtensionTelemetry.ts | 7 ++- .../integration/webExtensionTelemetry.test.ts | 57 ++++++++++++++----- 2 files changed, 48 insertions(+), 16 deletions(-) diff --git a/src/web/client/telemetry/webExtensionTelemetry.ts b/src/web/client/telemetry/webExtensionTelemetry.ts index 9f71d4d9..6846f68a 100644 --- a/src/web/client/telemetry/webExtensionTelemetry.ts +++ b/src/web/client/telemetry/webExtensionTelemetry.ts @@ -113,6 +113,7 @@ export class WebExtensionTelemetry { const error: Error = new Error(errorMessage); this._telemetry?.sendTelemetryException(error, { ...telemetryData.properties, eventName: eventName }, telemetryData.measurements); } else { + console.log("Might be a test run: ", telemetryData); this._telemetry?.sendTelemetryEvent(telemetryData.eventName, telemetryData.properties, telemetryData.measurements); } } @@ -124,7 +125,8 @@ export class WebExtensionTelemetry { duration: number, methodName: string, eventName?: string, - entityFileExtensionType?: string + entityFileExtensionType?: string, + status?: string ) { this.sendAPITelemetry( URL, @@ -135,7 +137,8 @@ export class WebExtensionTelemetry { true, duration, undefined, - !isNullOrUndefined(eventName) ? eventName : telemetryEventNames.WEB_EXTENSION_API_REQUEST_SUCCESS); + !isNullOrUndefined(eventName) ? eventName : telemetryEventNames.WEB_EXTENSION_API_REQUEST_SUCCESS, + status); } public sendAPIFailureTelemetry( diff --git a/src/web/client/test/integration/webExtensionTelemetry.test.ts b/src/web/client/test/integration/webExtensionTelemetry.test.ts index fed1f7ea..10d86562 100644 --- a/src/web/client/test/integration/webExtensionTelemetry.test.ts +++ b/src/web/client/test/integration/webExtensionTelemetry.test.ts @@ -97,6 +97,9 @@ describe("webExtensionTelemetry", () => { ], [queryParameters.REFERRER, "yes"], [queryParameters.SITE_VISIBILITY, "false"], + [queryParameters.REGION, "NAM"], + [queryParameters.GEO, "US"], + [queryParameters.ENV_ID, "c4dc3686-1e6b-e428-b886-16cd0b9f4918"] ]); const sendTelemetryEvent = stub(telemetry, "sendTelemetryEvent"); @@ -112,6 +115,9 @@ describe("webExtensionTelemetry", () => { ), referrer: queryParamsMap.get(queryParameters.REFERRER), siteVisibility: queryParamsMap.get(queryParameters.SITE_VISIBILITY), + region: queryParamsMap.get(queryParameters.REGION), + geo: queryParamsMap.get(queryParameters.GEO), + envId: queryParamsMap.get(queryParameters.ENV_ID), // eslint-disable-next-line @typescript-eslint/no-explicit-any } as any; @@ -145,6 +151,9 @@ describe("webExtensionTelemetry", () => { ), referrer: queryParamsMap.get(queryParameters.REFERRER), siteVisibility: queryParamsMap.get(queryParameters.SITE_VISIBILITY), + region: queryParamsMap.get(queryParameters.REGION), + geo: queryParamsMap.get(queryParameters.GEO), + envId: queryParamsMap.get(queryParameters.ENV_ID), // eslint-disable-next-line @typescript-eslint/no-explicit-any } as any; @@ -177,7 +186,7 @@ describe("webExtensionTelemetry", () => { }; //Act - webExtensionTelemetry.sendErrorTelemetry(eventName, errorMessage); + webExtensionTelemetry.sendErrorTelemetry(eventName, methodName, errorMessage); //Assert const error: Error = new Error(errorMessage); @@ -204,7 +213,7 @@ describe("webExtensionTelemetry", () => { methodName: methodName }; //Act - webExtensionTelemetry.sendErrorTelemetry(eventName,methodName); + webExtensionTelemetry.sendErrorTelemetry(eventName, methodName); //Assert assert.calledOnce(sendTelemetryException); @@ -246,7 +255,7 @@ describe("webExtensionTelemetry", () => { assert.calledOnceWithExactly(sendTelemetryEvent, eventName, properties); }); - it("sendAPITelemetry_whenErrorMessageIsPassed_shouldCallsendTelemetryException", () => { + it("sendAPITelemetry_whenErrorMessageIsPassed_shouldCallSendTelemetryException", () => { //Act const URL = "powerPages.com"; const entity = "webPages"; @@ -267,8 +276,10 @@ describe("webExtensionTelemetry", () => { entity: entity, httpMethod: httpMethod, entityFileExtensionType: entityFileExtensionType, - eventName: "update", + methodName: "sendAPITelemetry_whenErrorMessageIsPassed_shouldCallSendTelemetryException", isSuccessful: "true", + status: "200", + eventName: eventName }; //Action @@ -277,12 +288,13 @@ describe("webExtensionTelemetry", () => { URL, entity, httpMethod, - "sendAPITelemetry_whenErrorMessageIsPassed_shouldCallsendTelemetryException", + "sendAPITelemetry_whenErrorMessageIsPassed_shouldCallSendTelemetryException", entityFileExtensionType, // TODO: Pass these as function properties parameters isSuccessful, duration, errorMessage, - eventName + eventName, + "200" ); const measurements = { @@ -300,7 +312,7 @@ describe("webExtensionTelemetry", () => { expect(sendTelemetryExceptionCalls.args[2]).deep.eq(measurements); }); - it("sendAPITelemetry_whenErrorMessageNotPassed_shouldCallsendTelemetryException", () => { + it("sendAPITelemetry_whenErrorMessageNotPassed_shouldCallSendTelemetryException", () => { //Act const URL = "powerPages.com"; const entity = "webPages"; @@ -319,6 +331,8 @@ describe("webExtensionTelemetry", () => { httpMethod: httpMethod, entityFileExtensionType: entityFileExtensionType, isSuccessful: "true", + status: "200", + methodName: "sendAPITelemetry_whenErrorMessageNotPassed_shouldCallSendTelemetryException" }; //Action @@ -327,12 +341,13 @@ describe("webExtensionTelemetry", () => { URL, entity, httpMethod, - "sendAPITelemetry_whenErrorMessageNotPassed_shouldCallsendTelemetryException", + "sendAPITelemetry_whenErrorMessageNotPassed_shouldCallSendTelemetryException", entityFileExtensionType, // TODO: Pass these as function properties parameters isSuccessful, duration, errorMessage, - eventName + eventName, + "200" ); const measurements = { @@ -366,6 +381,8 @@ describe("webExtensionTelemetry", () => { httpMethod: httpMethod, entityFileExtensionType: entityFileExtensionType, isSuccessful: "", + status: "200", + methodName: "sendAPITelemetry_whenIsSuccessfulAndDurationIsUndefined_shouldSetDurationInMillisAs0orIsSuccessfulAsBlankString" }; //Action @@ -379,7 +396,8 @@ describe("webExtensionTelemetry", () => { isSuccessful, duration, errorMessage, - eventName + eventName, + "200" ); const measurements = { @@ -413,6 +431,8 @@ describe("webExtensionTelemetry", () => { httpMethod: httpMethod, entityFileExtensionType: entityFileExtensionType, isSuccessful: "false", + status: "200", + methodName: "sendAPITelemetry_whenIsSuccessfulIsFalse_shouldSetIsSuccessfulAsFalse" }; //Action @@ -425,7 +445,8 @@ describe("webExtensionTelemetry", () => { isSuccessful, duration, errorMessage, - eventName + eventName, + "200" ); const measurements = { @@ -454,19 +475,24 @@ describe("webExtensionTelemetry", () => { httpMethod: httpMethod, entityFileExtensionType: entityFileExtensionType, isSuccessful: "true", + methodName: "sendAPISuccessTelemetry_whenCall_shouldCallSendAPITelemetryWithoutErrorMessage", + status: "200" }; const measurements = { durationInMillis: duration, }; - + console.log("sendAPISuccessTelemetry_whenCall_shouldCallSendAPITelemetryWithoutErrorMessage", sanitizeURL(URL)); //Action webExtensionTelemetry.sendAPISuccessTelemetry( URL, entity, httpMethod, duration, - entityFileExtensionType + "sendAPISuccessTelemetry_whenCall_shouldCallSendAPITelemetryWithoutErrorMessage", + "WebExtensionApiRequestSuccess", + entityFileExtensionType, + "200" ); //Assert @@ -497,6 +523,8 @@ describe("webExtensionTelemetry", () => { entityFileExtensionType: entityFileExtensionType, eventName: telemetryEventNames.WEB_EXTENSION_API_REQUEST_FAILURE, isSuccessful: "false", + status: "200", + methodName: "sendAPIFailureTelemetry_withErrorMessage_shouldCallSendTelemetryException" }; const measurements = { @@ -511,7 +539,8 @@ describe("webExtensionTelemetry", () => { duration, "sendAPIFailureTelemetry_withErrorMessage_shouldCallSendTelemetryException", errorMessage, - entityFileExtensionType + entityFileExtensionType, + "200" ); //Assert From 02c5c9fcfd2cf6b50f03603c72378e4fae3d231a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nidhi=20Tyagi=20=F0=9F=8C=9F=F0=9F=90=87=F0=9F=8C=B4?= =?UTF-8?q?=E2=9D=84=EF=B8=8F?= Date: Mon, 13 Nov 2023 11:32:45 +0530 Subject: [PATCH 4/5] remove console command --- src/web/client/telemetry/webExtensionTelemetry.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/web/client/telemetry/webExtensionTelemetry.ts b/src/web/client/telemetry/webExtensionTelemetry.ts index 6846f68a..954b615f 100644 --- a/src/web/client/telemetry/webExtensionTelemetry.ts +++ b/src/web/client/telemetry/webExtensionTelemetry.ts @@ -113,7 +113,6 @@ export class WebExtensionTelemetry { const error: Error = new Error(errorMessage); this._telemetry?.sendTelemetryException(error, { ...telemetryData.properties, eventName: eventName }, telemetryData.measurements); } else { - console.log("Might be a test run: ", telemetryData); this._telemetry?.sendTelemetryEvent(telemetryData.eventName, telemetryData.properties, telemetryData.measurements); } } From 225d390166c225e673fda61b0a651757b7ea1898 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nidhi=20Tyagi=20=F0=9F=8C=9F=F0=9F=90=87=F0=9F=8C=B4?= =?UTF-8?q?=E2=9D=84=EF=B8=8F?= Date: Mon, 13 Nov 2023 11:36:59 +0530 Subject: [PATCH 5/5] remove console command --- src/web/client/test/integration/webExtensionTelemetry.test.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/web/client/test/integration/webExtensionTelemetry.test.ts b/src/web/client/test/integration/webExtensionTelemetry.test.ts index 10d86562..338194d2 100644 --- a/src/web/client/test/integration/webExtensionTelemetry.test.ts +++ b/src/web/client/test/integration/webExtensionTelemetry.test.ts @@ -482,7 +482,6 @@ describe("webExtensionTelemetry", () => { const measurements = { durationInMillis: duration, }; - console.log("sendAPISuccessTelemetry_whenCall_shouldCallSendAPITelemetryWithoutErrorMessage", sanitizeURL(URL)); //Action webExtensionTelemetry.sendAPISuccessTelemetry( URL,