-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
[vscode] Support TestMessage#contextValue #13176
Conversation
854f0e0
to
d975a01
Compare
@tsmaeder, as you worked on the test API, could you have a look to this one? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just two remarks.
@@ -131,3 +132,23 @@ export namespace TestItemReference { | |||
} | |||
} | |||
|
|||
export interface TestMessageArg { | |||
typeTag: '$type_test_message_arg', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we really need this or can we just send an array of [TestItemReference, TestMessageDTO]?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That was easier to detect the kind of message, as we send an array of 2 elements with one optional and the other with almost everything optional except 1 property. But this is definitely not mandatory.
That can be removed and we can have the following code for TestMessageArg.is():
typeTag: '$type_test_message_arg', | |
export interface TestMessageArg { | |
testItemReference: TestItemReference | undefined, | |
testMessage: TestMessageDTO | |
} | |
export namespace TestMessageArg { | |
export function is(arg: unknown): arg is TestMessageArg { | |
return isObject<TestMessageArg>(arg) | |
&& isObject<TestMessageDTO>(arg.testMessage) | |
&& typeof arg.testMessage.message === 'string'; | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was more thinking of making the argument transformer method recursive: we are already detecting if it's an array, but the assumption is that the contents can only be TestItemReferences
@@ -216,6 +218,12 @@ export class TestRunTreeWidget extends TreeWidget { | |||
onDidAddTestOutput: Event.map(node.parent.run.onDidChangeTestOutput, evt => evt.filter(item => item[0] === node.item).map(item => item[1])) | |||
}; | |||
this.uiModel.selectedTestState = node.parent.run.getTestState(node.item); | |||
if (this.uiModel.selectedTestState && TestFailure.is(this.uiModel.selectedTestState.state)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this code live in the uiModel
as it's the owner of the selectedTestState
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for noticing! Indeed, that should happen in the uiModel. I will update the code and move this part of the code on the selectedTestState mutator.
When testing, I never get anything in the info popup for the message context except:
This happened when doing this:
Not sure whether that is due to the test plugin or the PR code. |
packages/plugin-ext/src/main/browser/menus/plugin-menu-command-adapter.ts
Show resolved
Hide resolved
I tried again, using the extension provided in the PR and with latest version, I do not get these stack error messages on sample-child1. I tested on both browser and electron version. I see the difference with your message information text, I will push a new version of the extension with pretty printed objects. I can see however a call stack error while right clicking on the Test Run root object. I will fix that. |
I updated the PR with more checks on arguments processing. Element tree in Test Run widget can also be Here is the version of the test extension with stringified argument: |
With the latest plugin, I always get "Message Context with args: undefined" when I click the context menu. What gives? |
Sorry for that, @tsmaeder! I am pretty sure I had check thoroughly the changes :/ In certain cases, TestMessage.is() was returning false despite the element passed being one. I updated the PR so this should not happen anymore. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think your original code was correct as far as the typing goes: the "location" field in TestMessage should probably be optional. But that's another problem. Lgtm now.
Thanks a lot, @tsmaeder! I will rebase and resolve conflicts then. |
Also adds the menu mapping for testing/message/context vscode menu extension. contributed on behalf of STMicroelectronics Signed-off-by: Remi Schnekenburger <[email protected]> review comments review comments - avoid passing TestRun in the plugin menu command adapter review comments TestMessage location can be undefined, so the TestMessage.is() was returning false despite being one.
91fb671
to
17b9b39
Compare
@tsmaeder Is this approved? |
What it does
Provides support for 1.84 vscode API
TestMessage#contextValue
optional property. This also adds one introduced menu using this API (testing/message/context
). See https://code.visualstudio.com/updates/v1_84#_finalized-testmessagecontextvalue-apiThe other menu is not relevant currently, as the test API implementation is not as advanced as the vscode one (no diff editor with actual and expected compared for example).
Fixes #13144
Contributed on behalf of STMicroelectronics
How to test
The test can be done installing the following extension:
test-extension-sample-0.0.1.zip
test-extension-sample-0.0.1-src.zip
This adds a test controller that required the creation of a test run profile before being used (Command palette > Create Test Run Profile). Once the test has run, the results are shown. On the test results, there is a new context menu action that displays a message information with the arguments passed to this command. The expected arguments are described in the comment of TestMessage#contextValue (see theia.d.ts - line to be added once commited)
Note that since the
testing/message/content
extension menu is not yet implemented, the extension will show a warning at startup.Follow-ups
Support of the
testing/message/content
extension menu. This is tracked under #13145Review checklist
Reminder for reviewers