From 9336e40ebc877e411bb625d11667748ceba220b3 Mon Sep 17 00:00:00 2001 From: Aasim Khan Date: Wed, 23 Oct 2024 12:28:26 -0700 Subject: [PATCH] Adding some webview panel and user survey tests. (#18296) * adding more tests * Adding more tests * Fixing typo and adding a single command for test coverage * some survey tests * adding more tests * removing unused var * Adding tests for later and never --- package.json | 3 +- src/controllers/reactWebviewBaseController.ts | 25 +- src/nps/userSurvey.ts | 2 +- src/sharedInterfaces/telemetry.ts | 2 +- test/unit/reactWebviewBaseController.test.ts | 2 +- test/unit/reactWebviewPanelController.test.ts | 321 ++++++++++++++++++ test/unit/userSurvey.test.ts | 212 ++++++++++++ test/unit/utils.ts | 25 +- 8 files changed, 570 insertions(+), 22 deletions(-) create mode 100644 test/unit/reactWebviewPanelController.test.ts create mode 100644 test/unit/userSurvey.test.ts diff --git a/package.json b/package.json index 2cd3776e..011d1471 100644 --- a/package.json +++ b/package.json @@ -61,7 +61,8 @@ "prepare": "husky", "lint-staged": "lint-staged --quiet", "precommit": "run-p lint-staged localization", - "clean-package": "git clean -xfd && yarn install && yarn build && yarn gulp package:online" + "clean-package": "git clean -xfd && yarn install && yarn build && yarn gulp package:online", + "testWithCoverage": "yarn test && yarn gulp cover" }, "lint-staged": { "*.ts": "eslint --quiet --cache", diff --git a/src/controllers/reactWebviewBaseController.ts b/src/controllers/reactWebviewBaseController.ts index 9cdf1ee5..1ba1a1f6 100644 --- a/src/controllers/reactWebviewBaseController.ts +++ b/src/controllers/reactWebviewBaseController.ts @@ -105,18 +105,17 @@ export abstract class ReactWebviewBaseController protected _getHtmlTemplate() { const nonce = getNonce(); - const baseUrl = - this._getWebview() - .asWebviewUri( - vscode.Uri.joinPath( - this._context.extensionUri, - "out", - "src", - "reactviews", - "assets", - ), - ) - .toString() + "/"; + + const baseUrl = this._getWebview().asWebviewUri( + vscode.Uri.joinPath( + this._context.extensionUri, + "out", + "src", + "reactviews", + "assets", + ), + ); + const baseUrlString = baseUrl.toString() + "/"; return ` @@ -125,7 +124,7 @@ export abstract class ReactWebviewBaseController mssqlwebview - +