Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

utils & dev: Add fix for tests that fail due to having showLoadingPrompt set to true #1807

Merged
merged 4 commits into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading