-
Notifications
You must be signed in to change notification settings - Fork 407
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
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
d3856bc
update labels based on text status and go to first error in ApexGroup…
brpowell e2b4d32
label updates and added tests
brpowell 317c35b
label updates and added tests
brpowell 31f3399
Merge branch 'bpowell/testRightClickLabel' of github.com:forcedotcom/…
brpowell 91382d0
label updates and added tests
brpowell ccefd64
Merge branch 'bpowell/testRightClickLabel' of github.com:forcedotcom/…
brpowell e55b623
fix merge conflict
brpowell 1b79541
Merge branch 'develop' into bpowell/testRightClickLabel
brpowell File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,7 @@ import * as vscode from 'vscode'; | |
import { nls } from '../messages'; | ||
import { ReadableApexTestRunExecutor } from './readableApexTestRunExecutor'; | ||
import { | ||
ApexTestGroupNode, | ||
ApexTestNode, | ||
ApexTestOutlineProvider, | ||
TestNode | ||
|
@@ -27,18 +28,33 @@ const SfdxWorkspaceChecker = sfdxCoreExports.SfdxWorkspaceChecker; | |
const channelService = sfdxCoreExports.channelService; | ||
export class ApexTestRunner { | ||
private testOutline: ApexTestOutlineProvider; | ||
private eventsEmitter = new events.EventEmitter(); | ||
constructor(testOutline: ApexTestOutlineProvider) { | ||
private eventsEmitter: events.EventEmitter; | ||
constructor( | ||
testOutline: ApexTestOutlineProvider, | ||
eventsEmitter?: events.EventEmitter | ||
) { | ||
this.testOutline = testOutline; | ||
this.eventsEmitter = eventsEmitter || new events.EventEmitter(); | ||
this.eventsEmitter.on('sfdx:update_selection', this.updateSelection); | ||
} | ||
|
||
public async showErrorMessage(test: TestNode) { | ||
public showErrorMessage(test: TestNode) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Very cool to get rid of the |
||
let testNode = test; | ||
let position: vscode.Range | number = test.location!.range; | ||
if (test instanceof ApexTestNode) { | ||
const errorMessage = test.errorMessage; | ||
if (testNode instanceof ApexTestGroupNode) { | ||
if (test.contextValue === 'apexTestGroup_Fail') { | ||
const failedTest = test.children.find( | ||
testCase => testCase.contextValue === 'apexTest_Fail' | ||
); | ||
if (failedTest) { | ||
testNode = failedTest; | ||
} | ||
} | ||
} | ||
if (testNode instanceof ApexTestNode) { | ||
const errorMessage = testNode.errorMessage; | ||
if (errorMessage && errorMessage !== '') { | ||
const stackTrace = test.stackTrace; | ||
const stackTrace = testNode.stackTrace; | ||
position = | ||
parseInt( | ||
stackTrace.substring( | ||
|
@@ -54,8 +70,9 @@ export class ApexTestRunner { | |
channelService.showChannelOutput(); | ||
} | ||
} | ||
if (test.location) { | ||
vscode.window.showTextDocument(test.location.uri).then(() => { | ||
|
||
if (testNode.location) { | ||
vscode.window.showTextDocument(testNode.location.uri).then(() => { | ||
this.eventsEmitter.emit('sfdx:update_selection', position); | ||
}); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
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.
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.
goToDefinition
. I think you're really going to the definition more than showing it in-line.