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

Update right click menu label based on test status #811

Merged
merged 8 commits into from
Dec 13, 2018

Conversation

brpowell
Copy link
Contributor

Looking for some feedback on how I went about this. Also noticed there aren't any tests for the functionality of going to the error/definition, I'll work on that as well.

What does this PR do?

When right clicking on a test that hasn't run, passed, or is skipped, the menu option now says "Go to Definition" instead of "Display Error", the latter which is shown only when the test has failed.

What issues does this PR fix or reference?

W-5368845

@brpowell brpowell changed the title Update right click menu label based on test status [WIP] Update right click menu label based on test status Dec 11, 2018
{
"command": "sfdx.force.test.view.showDefinition",
"when":
"view == sfdx.force.test.view && viewItem =~ /(apexTest|apexTestGroup)(_Pass|_Skip|\\b)/"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VSCode doesn't exactly have a way of dynamically updating the labels for the same command in a context menu. I created another command that runs the same method, but has the "Go to Definition" label. Then conditionally render one command or the other based on the where clause.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Yeah, there isn't a way to dynamically update the labels.
  2. Does this mean that you won't be able to see the "Go to Definition" menu if you are on a failing node?
  3. What about calling it goToDefinition. I think you're really going to the definition more than showing it in-line.

@@ -246,6 +246,9 @@ export abstract class TestNode extends vscode.TreeItem {
dark: DARK_ORANGE_BUTTON
};
}

const contextValue = this.contextValue.split('_');
this.contextValue = `${contextValue}_${outcome}`;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed the name of this method to highlight it's doing more than updating an icon now. I'm appending the outcome of a test to the contextValue of the test node so i can access this in the commands' where clauses as defined in the package.json.

@@ -34,11 +35,22 @@ export class ApexTestRunner {
}

public async showErrorMessage(test: TestNode) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When a test class is marked as failed, the "Display Error" option will still show up upon right clicking it. It seemed confusing to have Display Error bring you to the top of the class file, so I changed it to go to the first failed test case.

{
"command": "sfdx.force.test.view.showDefinition",
"when":
"view == sfdx.force.test.view && viewItem =~ /(apexTest|apexTestGroup)(_Pass|_Skip|\\b)/"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Yeah, there isn't a way to dynamically update the labels.
  2. Does this mean that you won't be able to see the "Go to Definition" menu if you are on a failing node?
  3. What about calling it goToDefinition. I think you're really going to the definition more than showing it in-line.

@@ -6,6 +6,7 @@
"refresh_test_title": "Refresh Tests",
"run_single_test_title": "Run Single Test",
"show_error_title": "Display Error",
"show_definition_title": "Go to Definition",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"show_definition_title" -> "go_to_definition_title"?

Copy link
Contributor Author

@brpowell brpowell Dec 12, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Right, you'll only ever see "Go to Definition" or "Display Error". Do you think we should have both options for a failing node?
  2. Yeah I should be consistent, I'll update that.

@codecov
Copy link

codecov bot commented Dec 12, 2018

Codecov Report

Merging #811 into develop will increase coverage by 0.5%.
The diff coverage is 76.19%.

Impacted file tree graph

@@            Coverage Diff             @@
##           develop     #811     +/-   ##
==========================================
+ Coverage    72.76%   73.27%   +0.5%     
==========================================
  Files          167      167             
  Lines         6790     6799      +9     
  Branches      1069     1073      +4     
==========================================
+ Hits          4941     4982     +41     
+ Misses        1582     1546     -36     
- Partials       267      271      +4
Impacted Files Coverage Δ
...rcedx-vscode-apex/src/views/testOutlineProvider.ts 67.97% <100%> (+0.42%) ⬆️
...s/salesforcedx-vscode-apex/src/views/testRunner.ts 52.38% <61.53%> (+52.38%) ⬆️
...forcedx-vscode-core/src/channels/channelService.ts 85.71% <0%> (+2.38%) ⬆️
...code-apex/src/views/readableApexTestRunExecutor.ts 27.77% <0%> (+27.77%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 11b018a...1b79541. Read the comment docs.

@brpowell brpowell changed the title [WIP] Update right click menu label based on test status Update right click menu label based on test status Dec 12, 2018
parseJSONStub.restore();
});

it('Go to definition if a test does not have an error message', () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets update the test titles to start with 'Should' and keep them consistent with the rest, e.g. Should go to definition if a test ....

@@ -33,12 +34,23 @@ export class ApexTestRunner {
this.eventsEmitter.on('sfdx:update_selection', this.updateSelection);
}

public async showErrorMessage(test: TestNode) {
public showErrorMessage(test: TestNode) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very cool to get rid of the async here.

Copy link
Contributor

@lcampos lcampos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just update the test names and get it merged.

@lcampos lcampos merged commit 53cd348 into develop Dec 13, 2018
@lcampos lcampos deleted the bpowell/testRightClickLabel branch December 13, 2018 23:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants