From fb6173d075d0eb0d24a9ebcd13c17b326186916f Mon Sep 17 00:00:00 2001 From: Matthew Fisher <40250218+MicroFish91@users.noreply.github.com> Date: Wed, 30 Oct 2024 10:15:42 -0700 Subject: [PATCH] utils & dev: Add fix for tests that fail due to having `showLoadingPrompt` set to `true` (#1807) --- dev/index.d.ts | 6 ++++++ dev/package-lock.json | 4 ++-- dev/package.json | 2 +- dev/src/TestUserInput.ts | 2 ++ utils/package-lock.json | 4 ++-- utils/package.json | 2 +- utils/src/userInput/IInternalActionContext.ts | 2 +- utils/src/wizard/AzureWizard.ts | 3 ++- 8 files changed, 17 insertions(+), 8 deletions(-) diff --git a/dev/index.d.ts b/dev/index.d.ts index 6e89668f68..85b41c5269 100644 --- a/dev/index.d.ts +++ b/dev/index.d.ts @@ -223,6 +223,12 @@ export declare class TestUserInput { public constructor(vscode: typeof import('vscode')); + /** + * Boolean set to indicate whether the UI is being used for test inputs. For`TestUserInput`, this will always default to true. + * See: https://github.com/microsoft/vscode-azuretools/pull/1807 + */ + readonly isTesting: boolean; + /** * An ordered array of inputs that will be used instead of interactively prompting in VS Code. RegExp is only applicable for QuickPicks and will pick the first input that matches the RegExp. */ diff --git a/dev/package-lock.json b/dev/package-lock.json index ee3c972fdd..8862127ae1 100644 --- a/dev/package-lock.json +++ b/dev/package-lock.json @@ -1,12 +1,12 @@ { "name": "@microsoft/vscode-azext-dev", - "version": "2.0.4", + "version": "2.0.5", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@microsoft/vscode-azext-dev", - "version": "2.0.4", + "version": "2.0.5", "license": "MIT", "dependencies": { "assert": "^2.0.0", diff --git a/dev/package.json b/dev/package.json index 23018d7252..13c5033e80 100644 --- a/dev/package.json +++ b/dev/package.json @@ -1,7 +1,7 @@ { "name": "@microsoft/vscode-azext-dev", "author": "Microsoft Corporation", - "version": "2.0.4", + "version": "2.0.5", "description": "Common dev dependency tools for developing Azure extensions for VS Code", "tags": [ "azure", diff --git a/dev/src/TestUserInput.ts b/dev/src/TestUserInput.ts index f75b8a42df..a66439e5d7 100644 --- a/dev/src/TestUserInput.ts +++ b/dev/src/TestUserInput.ts @@ -23,6 +23,8 @@ export class TestUserInput implements types.TestUserInput { private readonly _vscode: typeof vscodeTypes; private _inputs: (string | RegExp | TestInput)[] = []; + readonly isTesting: boolean = true; + constructor(vscode: typeof vscodeTypes) { this._vscode = vscode; this._onDidFinishPromptEmitter = new this._vscode.EventEmitter(); diff --git a/utils/package-lock.json b/utils/package-lock.json index 31d48b0ae2..4ffbc1faa0 100644 --- a/utils/package-lock.json +++ b/utils/package-lock.json @@ -1,12 +1,12 @@ { "name": "@microsoft/vscode-azext-utils", - "version": "2.5.10", + "version": "2.5.11", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@microsoft/vscode-azext-utils", - "version": "2.5.10", + "version": "2.5.11", "license": "MIT", "dependencies": { "@microsoft/vscode-azureresources-api": "^2.3.1", diff --git a/utils/package.json b/utils/package.json index 067b933a92..f92997f0de 100644 --- a/utils/package.json +++ b/utils/package.json @@ -1,7 +1,7 @@ { "name": "@microsoft/vscode-azext-utils", "author": "Microsoft Corporation", - "version": "2.5.10", + "version": "2.5.11", "description": "Common UI tools for developing Azure extensions for VS Code", "tags": [ "azure", diff --git a/utils/src/userInput/IInternalActionContext.ts b/utils/src/userInput/IInternalActionContext.ts index 50bc184ed8..45395194f7 100644 --- a/utils/src/userInput/IInternalActionContext.ts +++ b/utils/src/userInput/IInternalActionContext.ts @@ -7,7 +7,7 @@ import { CancellationToken } from 'vscode'; import * as types from '../../index'; export interface IInternalActionContext extends types.IActionContext { - ui: types.IAzureUserInput & { wizard?: IInternalAzureWizard, isPrompting?: boolean } + ui: types.IAzureUserInput & { wizard?: IInternalAzureWizard, isPrompting?: boolean, isTesting?: boolean }; } export interface IInternalAzureWizard { diff --git a/utils/src/wizard/AzureWizard.ts b/utils/src/wizard/AzureWizard.ts index efeeaa7856..0922a154e5 100644 --- a/utils/src/wizard/AzureWizard.ts +++ b/utils/src/wizard/AzureWizard.ts @@ -114,7 +114,8 @@ export class AzureWizard { - if (!this._context.ui.isPrompting) { + // Avoid issuing cancels during tests - see: https://github.com/microsoft/vscode-azuretools/pull/1807 + if (!this._context.ui.isPrompting && !this._context.ui.isTesting) { this._cancellationTokenSource.cancel(); } }));