@@ -3,12 +3,17 @@ import { commands, extensions, window } from "vscode";
33import { CodeQLExtensionInterface } from "../../../../src/extension" ;
44import { readJson } from "fs-extra" ;
55import * as path from "path" ;
6- import { DbConfig } from "../../../../src/databases/config/db-config" ;
6+ import {
7+ DbConfig ,
8+ SelectedDbItemKind ,
9+ } from "../../../../src/databases/config/db-config" ;
710import {
811 AddListQuickPickItem ,
912 RemoteDatabaseQuickPickItem ,
1013} from "../../../../src/databases/ui/db-panel" ;
1114import { DbListKind } from "../../../../src/databases/db-item" ;
15+ import { createDbTreeViewItemSystemDefinedList } from "../../../../src/databases/ui/db-tree-view-item" ;
16+ import { createRemoteSystemDefinedListDbItem } from "../../../factories/db-item-factories" ;
1217
1318jest . setTimeout ( 60_000 ) ;
1419
@@ -88,4 +93,27 @@ describe("Db panel UI commands", () => {
8893 expect ( dbConfig . databases . remote . owners ) . toHaveLength ( 1 ) ;
8994 expect ( dbConfig . databases . remote . owners [ 0 ] ) . toBe ( "owner1" ) ;
9095 } ) ;
96+
97+ it ( "should select db item" , async ( ) => {
98+ const listName = "top n repos" ;
99+ const treeViewItem = createDbTreeViewItemSystemDefinedList (
100+ createRemoteSystemDefinedListDbItem ( { listName } ) ,
101+ "label" ,
102+ "tooltip" ,
103+ ) ;
104+
105+ await commands . executeCommand (
106+ "codeQLDatabasesExperimental.setSelectedItemContextMenu" ,
107+ treeViewItem ,
108+ ) ;
109+
110+ // Check db config
111+ const dbConfigFilePath = path . join ( storagePath , "workspace-databases.json" ) ;
112+ const dbConfig : DbConfig = await readJson ( dbConfigFilePath ) ;
113+ expect ( dbConfig . selected ) . toBeDefined ( ) ;
114+ expect ( dbConfig . selected ) . toEqual ( {
115+ kind : SelectedDbItemKind . RemoteSystemDefinedList ,
116+ listName,
117+ } ) ;
118+ } ) ;
91119} ) ;
0 commit comments