Skip to content

Commit

Permalink
utils & dev: Add fix for tests that fail due to having `showLoadingPr…
Browse files Browse the repository at this point in the history
…ompt` set to `true` (#1807)
  • Loading branch information
MicroFish91 authored Oct 30, 2024
1 parent 9bc93be commit fb6173d
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 8 deletions.
6 changes: 6 additions & 0 deletions dev/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
4 changes: 2 additions & 2 deletions dev/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dev/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 2 additions & 0 deletions dev/src/TestUserInput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<types.PromptResult>();
Expand Down
4 changes: 2 additions & 2 deletions utils/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion utils/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 1 addition & 1 deletion utils/src/userInput/IInternalActionContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
3 changes: 2 additions & 1 deletion utils/src/wizard/AzureWizard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ export class AzureWizard<T extends (IInternalActionContext & Partial<types.Execu

if (loadingQuickPick) {
disposables.push(loadingQuickPick?.onDidHide(() => {
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();
}
}));
Expand Down

0 comments on commit fb6173d

Please sign in to comment.