@@ -772,6 +772,7 @@ describe("db panel", () => {
772772 expect ( item . tooltip ) . toBe ( `Top ${ n } repositories of a language` ) ;
773773 expect ( item . iconPath ) . toEqual ( new ThemeIcon ( "github" ) ) ;
774774 expect ( item . collapsibleState ) . toBe ( TreeItemCollapsibleState . None ) ;
775+ checkDbItemActions ( item , [ "canBeSelected" ] ) ;
775776 }
776777
777778 function checkUserDefinedListItem (
@@ -783,6 +784,7 @@ describe("db panel", () => {
783784 expect ( item . tooltip ) . toBeUndefined ( ) ;
784785 expect ( item . iconPath ) . toBeUndefined ( ) ;
785786 expect ( item . collapsibleState ) . toBe ( TreeItemCollapsibleState . Collapsed ) ;
787+ checkDbItemActions ( item , [ "canBeSelected" , "canBeRenamed" , "canBeRemoved" ] ) ;
786788 expect ( item . children ) . toBeTruthy ( ) ;
787789 expect ( item . children . length ) . toBe ( repos . length ) ;
788790
@@ -796,6 +798,11 @@ describe("db panel", () => {
796798 expect ( item . tooltip ) . toBeUndefined ( ) ;
797799 expect ( item . iconPath ) . toEqual ( new ThemeIcon ( "organization" ) ) ;
798800 expect ( item . collapsibleState ) . toBe ( TreeItemCollapsibleState . None ) ;
801+ checkDbItemActions ( item , [
802+ "canBeSelected" ,
803+ "canBeRemoved" ,
804+ "canBeOpenedOnGitHub" ,
805+ ] ) ;
799806 expect ( item . children ) . toBeTruthy ( ) ;
800807 expect ( item . children . length ) . toBe ( 0 ) ;
801808 }
@@ -805,6 +812,11 @@ describe("db panel", () => {
805812 expect ( item . tooltip ) . toBeUndefined ( ) ;
806813 expect ( item . iconPath ) . toEqual ( new ThemeIcon ( "database" ) ) ;
807814 expect ( item . collapsibleState ) . toBe ( TreeItemCollapsibleState . None ) ;
815+ checkDbItemActions ( item , [
816+ "canBeSelected" ,
817+ "canBeRemoved" ,
818+ "canBeOpenedOnGitHub" ,
819+ ] ) ;
808820 }
809821
810822 function checkLocalListItem (
@@ -816,6 +828,7 @@ describe("db panel", () => {
816828 expect ( item . tooltip ) . toBeUndefined ( ) ;
817829 expect ( item . iconPath ) . toBeUndefined ( ) ;
818830 expect ( item . collapsibleState ) . toBe ( TreeItemCollapsibleState . Collapsed ) ;
831+ checkDbItemActions ( item , [ "canBeSelected" , "canBeRemoved" , "canBeRenamed" ] ) ;
819832 expect ( item . children ) . toBeTruthy ( ) ;
820833 expect ( item . children . length ) . toBe ( databases . length ) ;
821834
@@ -832,6 +845,16 @@ describe("db panel", () => {
832845 expect ( item . tooltip ) . toBe ( `Language: ${ database . language } ` ) ;
833846 expect ( item . iconPath ) . toEqual ( new ThemeIcon ( "database" ) ) ;
834847 expect ( item . collapsibleState ) . toBe ( TreeItemCollapsibleState . None ) ;
848+ checkDbItemActions ( item , [ "canBeSelected" , "canBeRemoved" , "canBeRenamed" ] ) ;
849+ }
850+
851+ function checkDbItemActions ( item : DbTreeViewItem , actions : string [ ] ) : void {
852+ const itemActions = item . contextValue ?. split ( "," ) ;
853+ expect ( itemActions ) . toBeDefined ( ) ;
854+ expect ( itemActions ! . length ) . toBe ( actions . length ) ;
855+ for ( const action of actions ) {
856+ expect ( itemActions ) . toContain ( action ) ;
857+ }
835858 }
836859
837860 function checkErrorItem (
@@ -852,14 +875,16 @@ describe("db panel", () => {
852875 function isTreeViewItemSelectable ( treeViewItem : DbTreeViewItem ) {
853876 return (
854877 treeViewItem . resourceUri === undefined &&
855- treeViewItem . contextValue === "canBeSelected"
878+ treeViewItem . contextValue ?. includes ( "canBeSelected" )
856879 ) ;
857880 }
858881
859882 function isTreeViewItemSelected ( treeViewItem : DbTreeViewItem ) {
860883 return (
861884 treeViewItem . resourceUri ?. toString ( true ) ===
862- SELECTED_DB_ITEM_RESOURCE_URI && treeViewItem . contextValue === undefined
885+ SELECTED_DB_ITEM_RESOURCE_URI &&
886+ ( treeViewItem . contextValue === undefined ||
887+ ! treeViewItem . contextValue . includes ( "canBeSelected" ) )
863888 ) ;
864889 }
865890
0 commit comments