eclipse-theia / theia

Eclipse Theia is a cloud & desktop IDE framework implemented in TypeScript.
http://theia-ide.org
Eclipse Public License 2.0
19.29k stars 2.45k forks source link

[vscode] Support TestRunRequest.preserveFocus #13839

Closed rschnekenbu closed 1 week ago

rschnekenbu commented 1 week ago

What it does

Add a progress service for tests to support activation of views Support vscode API to listen for test run request preserveFocus:

fixes #13759

contributed on behalf of STMicroelectronics

How to test

  1. Start the theia browser example on master and install the following extension (derived from vscode sample extension test-provider-sample):

  2. When starting extensions from Test UI, nothing should happen (as preserveFocus is always true in this case)

  3. With the PR and the extensions, 2 additional commands are available with the markdown tests: Test Sample: Trigger Tests (preserveFocus: true/false). With the one with true, nothing shall happen also. The Test Result view shall activate when using the command with the false preserve Focus.

Follow-ups

The current implementation may be extended later based on preferences and test results status. In VS Code, when tests are started or failing, the Test Result view or the Test Explorer view can be activated based on user preferences (see https://github.com/microsoft/vscode/blob/f9238dd94a8b54dc3adb274927c7871e7c215300/src/vs/workbench/contrib/testing/browser/testingProgressUiService.ts#L49)

Review checklist

Reminder for reviewers

tsmaeder commented 1 week ago

@rschnekenbu I have a couple of remarks from testing:

  1. The preferences are in the "Extensions/Testing" section, but IMO should be in "Features/Testing".
  2. When I close the test explorer view, it is not opened when I run the tests with "preserveFocus: false".
  3. Not sure what the distinction is between "openOnStart" and "openExplorerOnStart" :shrug:
rschnekenbu commented 1 week ago

I moved the preferences to right place. That is now under Features section. I removed the openWithTestExplorer, as the option (copied from vs code) is not really obvious given the comment on the d.ts file and in the description of the preference. Now, the 2 options are 'do nothing' or 'open Test Results View'. I kept however the enum choice if we want to expand later the choices to other views. I also removed unused code left from previous implementation.

rschnekenbu commented 1 week ago

A small detail about the test of this feature: Running the tests from the UI should preserve the focus in any case, and not open any views. Only triggering from the extension, with the 'preserveFocus:false' version should open the view if the preference is set for this.

tsmaeder commented 1 week ago

@rschnekenbu for me revealing the test explorer does not work in this scenario:

  1. Set the preference to openOnTestStart.
  2. Make sure the file explorer view is visible
  3. Invoke `Trigger Test (preserveFocus: false)
  4. Observe: the test explorer view is not revealed.

🤷

rschnekenbu commented 1 week ago

@rschnekenbu for me revealing the test explorer does not work in this scenario:

  1. Set the preference to openOnTestStart.
  2. Make sure the file explorer view is visible
  3. Invoke `Trigger Test (preserveFocus: false)
  4. Observe: the test explorer view is not revealed.

🤷

The Test Results View shall open, not the Test Explorer. Is that not the case?

tsmaeder commented 1 week ago

The Test Results View shall open, not the Test Explorer. Is that not the case?

No, the file explorer still is visible.

tsmaeder commented 1 week ago

Cleared this up: The "Test Result View" is the one that shows up in the lower right corner where the terminals, etc. are.