@@ -23,10 +23,13 @@ import { ScmRepository } from '@theia/scm/lib/browser/scm-repository';
2323import { ScmService } from '@theia/scm/lib/browser/scm-service' ;
2424import { TimelineItem } from '@theia/timeline/lib/common/timeline-model' ;
2525import { ScmCommandArg , TimelineCommandArg , TreeViewItemReference } from '../../../common' ;
26+ import { TestItemReference , TestMessageArg } from '../../../common/test-types' ;
2627import { PluginScmProvider , PluginScmResource , PluginScmResourceGroup } from '../scm-main' ;
2728import { TreeViewWidget } from '../view/tree-view-widget' ;
2829import { CodeEditorWidgetUtil , codeToTheiaMappings , ContributionPoint } from './vscode-theia-menu-mappings' ;
2930import { TAB_BAR_TOOLBAR_CONTEXT_MENU } from '@theia/core/lib/browser/shell/tab-bar-toolbar' ;
31+ import { TestItem , TestMessage } from '@theia/test/lib/browser/test-service' ;
32+ import { fromLocation } from '../hierarchy/hierarchy-types-converters' ;
3033
3134export type ArgumentAdapter = ( ...args : unknown [ ] ) => unknown [ ] ;
3235
@@ -79,6 +82,7 @@ export class PluginMenuCommandAdapter implements MenuCommandAdapter {
7982 @postConstruct ( )
8083 protected init ( ) : void {
8184 const toCommentArgs : ArgumentAdapter = ( ...args ) => this . toCommentArgs ( ...args ) ;
85+ const toTestMessageArgs : ArgumentAdapter = ( ...args ) => this . toTestMessageArgs ( ...args ) ;
8286 const firstArgOnly : ArgumentAdapter = ( ...args ) => [ args [ 0 ] ] ;
8387 const noArgs : ArgumentAdapter = ( ) => [ ] ;
8488 const toScmArgs : ArgumentAdapter = ( ...args ) => this . toScmArgs ( ...args ) ;
@@ -100,6 +104,7 @@ export class PluginMenuCommandAdapter implements MenuCommandAdapter {
100104 [ 'scm/resourceGroup/context' , toScmArgs ] ,
101105 [ 'scm/resourceState/context' , toScmArgs ] ,
102106 [ 'scm/title' , ( ) => [ this . toScmArg ( this . scmService . selectedRepository ) ] ] ,
107+ [ 'testing/message/context' , toTestMessageArgs ] ,
103108 [ 'timeline/item/context' , ( ...args ) => this . toTimelineArgs ( ...args ) ] ,
104109 [ 'view/item/context' , ( ...args ) => this . toTreeArgs ( ...args ) ] ,
105110 [ 'view/title' , noArgs ] ,
@@ -230,6 +235,30 @@ export class PluginMenuCommandAdapter implements MenuCommandAdapter {
230235 return timelineArgs ;
231236 }
232237
238+ protected toTestMessageArgs ( ...args : any [ ] ) : any [ ] {
239+ let testItem : TestItem | undefined ;
240+ let testMessage : TestMessage | undefined ;
241+ for ( const arg of args ) {
242+ if ( TestItem . is ( arg ) ) {
243+ testItem = arg ;
244+ } else if ( Array . isArray ( arg ) ) {
245+ testMessage = arg [ 0 ] ;
246+ }
247+ }
248+ if ( testMessage ) {
249+ const testItemReference = ( testItem && testItem . controller ) ? TestItemReference . create ( testItem . controller . id , testItem . path ) : undefined ;
250+ const testMessageDTO = {
251+ message : testMessage . message ,
252+ actual : testMessage . actual ,
253+ expected : testMessage . expected ,
254+ contextValue : testMessage . contextValue ,
255+ location : testMessage . location ? fromLocation ( testMessage . location ) : undefined
256+ } ;
257+ return [ TestMessageArg . create ( testItemReference , testMessageDTO ) ] ;
258+ }
259+ return args ;
260+ }
261+
233262 protected toTimelineArg ( arg : TimelineItem ) : TimelineCommandArg {
234263 return {
235264 timelineHandle : arg . handle ,
0 commit comments