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

[Testing]: Get selected default Run/Debug TestProfile(s) #193160

Closed
mxschmitt opened this issue Sep 15, 2023 · 11 comments · Fixed by #202878
Closed

[Testing]: Get selected default Run/Debug TestProfile(s) #193160

mxschmitt opened this issue Sep 15, 2023 · 11 comments · Fixed by #202878
Assignees
Labels
api-finalization feature-request Request for new features or functionality insiders-released Patch has been released in VS Code Insiders on-testplan testing Built-in testing support

Comments

@mxschmitt
Copy link
Member

Is it possible to get the currently selected default run profile(s)? In this case the first and last.

We tried RunProfile.isDefault, but thats not getting the needed updates from the user when he selects/de-selects.

image

Thanks!

@connor4312
Copy link
Member

I propose the following additional APIs:

	export namespace tests {
		/**
		 * The list of {@link TestRunProfile} the user has selected as their default
		 * profiles when running tests.
		 */
		// implementors's note: for a given extension, this shows only the
		// TestRunProfiles that extension has created
		export let activeTestRunProfiles: readonly TestRunProfile[];

		/**
		 * Fired when a user has changed their default test run profiles. The
		 * new value is also reflected in {@link activeTestRunProfiles}.
		 */
		export const onDidChangeActiveTestRunProfiles: Event<readonly TestRunProfile[]>;
	}

@connor4312 connor4312 added api-proposal testing Built-in testing support labels Nov 1, 2023
@connor4312 connor4312 added this to the November 2023 milestone Nov 1, 2023
@jrieken
Copy link
Member

jrieken commented Nov 7, 2023

Sync-Feedback

  • have TestRunProfile.isSelected
  • have TestRunProfile#onDidSelect

@connor4312
Copy link
Member

connor4312 commented Nov 7, 2023

Updated API, will be available to try out in the next Insiders:

declare module 'vscode' {
	export interface TestRunProfile {
		/**
		 * Whether this profile is currently selected as a default by the user
		 */
		readonly isSelected: boolean;

		/**
		 * Fired when a user has changed whether this is a selected profile. The
		 * event contains the new value of {@link isSelected}
		 */
		onDidChangeSelected: Event<boolean>;
	}
}

@mxschmitt please try it out and let us know if it works for you!

connor4312 added a commit that referenced this issue Nov 7, 2023
testing: implement proposed active profiles api

For #193160
@mxschmitt
Copy link
Member Author

I tried it out and it works for us!

(We just check then if isSelected is true rather than attaching to the event listener.)

@jrieken
Copy link
Member

jrieken commented Dec 18, 2023

@connor4312 is this only about the default run profile or generally when selecting a profile w/o running it?

@connor4312
Copy link
Member

This is about the profile the user has selected as their chosen profile to be used when clicking the "run" or "debug" buttons.

@connor4312
Copy link
Member

Also, got in-person confirmation last week from @mxschmitt that this API is good for playwright :)

@jrieken
Copy link
Member

jrieken commented Dec 19, 2023

So, I need to go through "Select Default", right? I am confident this API is working but I wonder if the name and/or commend should be refined to express that this is only about the default

Screenshot 2023-12-19 at 09 25 54

@connor4312
Copy link
Member

Yea, that's right. The confusing thing is that we already has an extension-definable isDefault property on the profile to control whether, if a user has not manually selected profiles before, that one is the default.

One kind of clever thing we could do, though it's questionably breaking, is to have isDefault start being a managed property, set it when the user selection updates, and update the selection when it's updated, rather than introducing a new property...

@jrieken
Copy link
Member

jrieken commented Dec 20, 2023

I like that

@connor4312
Copy link
Member

So in that case I would revise this proposal with only the additional property in the .d.ts, along with docs changes:

declare module 'vscode' {
	export interface TestRunProfile {
		/**
		 * Fired when a user has changed whether this is a default profile. The
		 * event contains the new value of {@link isDefault}
		 */
		onDidChangeDefault: Event<boolean>;
	}
}

connor4312 added a commit that referenced this issue Jan 19, 2024
@connor4312 connor4312 added the feature-request Request for new features or functionality label Jan 19, 2024
connor4312 added a commit that referenced this issue Jan 19, 2024
@vscodenpa vscodenpa added unreleased Patch has not yet been released in VS Code Insiders insiders-released Patch has been released in VS Code Insiders and removed unreleased Patch has not yet been released in VS Code Insiders labels Jan 19, 2024
@aiday-mar aiday-mar added this to the December / January 2024 milestone Feb 6, 2024
@microsoft microsoft locked and limited conversation to collaborators Jun 11, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
api-finalization feature-request Request for new features or functionality insiders-released Patch has been released in VS Code Insiders on-testplan testing Built-in testing support
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants