@@ -38,25 +38,45 @@ suite('SqlCellStatusBarProvider', () => {
3838 assert . isUndefined ( result ) ;
3939 } ) ;
4040
41- test ( 'returns undefined for SQL cells without integration ID' , async ( ) => {
41+ test ( 'returns only variable status bar item for SQL cells without integration ID' , async ( ) => {
4242 const cell = createMockCell ( 'sql' , { } ) ;
4343
4444 const result = await provider . provideCellStatusBarItems ( cell , cancellationToken ) ;
4545
46- assert . isUndefined ( result ) ;
46+ assert . isDefined ( result ) ;
47+ assert . isArray ( result ) ;
48+ const items = result as any [ ] ;
49+ assert . strictEqual ( items . length , 1 ) ;
50+
51+ // Check variable status bar item
52+ const variableItem = items [ 0 ] ;
53+ assert . strictEqual ( variableItem . text , 'Variable: df' ) ;
54+ assert . strictEqual ( variableItem . alignment , 1 ) ;
55+ assert . isDefined ( variableItem . command ) ;
56+ assert . strictEqual ( variableItem . command . command , 'deepnote.updateSqlVariableName' ) ;
4757 } ) ;
4858
49- test ( 'returns undefined for SQL cells with dataframe integration ID' , async ( ) => {
59+ test ( 'returns only variable status bar item for SQL cells with dataframe integration ID' , async ( ) => {
5060 const cell = createMockCell ( 'sql' , {
5161 sql_integration_id : DATAFRAME_SQL_INTEGRATION_ID
5262 } ) ;
5363
5464 const result = await provider . provideCellStatusBarItems ( cell , cancellationToken ) ;
5565
56- assert . isUndefined ( result ) ;
66+ assert . isDefined ( result ) ;
67+ assert . isArray ( result ) ;
68+ const items = result as any [ ] ;
69+ assert . strictEqual ( items . length , 1 ) ;
70+
71+ // Check variable status bar item
72+ const variableItem = items [ 0 ] ;
73+ assert . strictEqual ( variableItem . text , 'Variable: df' ) ;
74+ assert . strictEqual ( variableItem . alignment , 1 ) ;
75+ assert . isDefined ( variableItem . command ) ;
76+ assert . strictEqual ( variableItem . command . command , 'deepnote.updateSqlVariableName' ) ;
5777 } ) ;
5878
59- test ( 'returns status bar item for SQL cell with integration ID' , async ( ) => {
79+ test ( 'returns status bar items for SQL cell with integration ID' , async ( ) => {
6080 const integrationId = 'postgres-123' ;
6181 const cell = createMockCell (
6282 'sql' ,
@@ -82,11 +102,24 @@ suite('SqlCellStatusBarProvider', () => {
82102 const result = await provider . provideCellStatusBarItems ( cell , cancellationToken ) ;
83103
84104 assert . isDefined ( result ) ;
85- assert . strictEqual ( ( result as any ) . text , '$(database) My Postgres DB' ) ;
86- assert . strictEqual ( ( result as any ) . alignment , 1 ) ; // NotebookCellStatusBarAlignment.Left
87- assert . isDefined ( ( result as any ) . command ) ;
88- assert . strictEqual ( ( result as any ) . command . command , 'deepnote.manageIntegrations' ) ;
89- assert . deepStrictEqual ( ( result as any ) . command . arguments , [ integrationId ] ) ;
105+ assert . isArray ( result ) ;
106+ const items = result as any [ ] ;
107+ assert . strictEqual ( items . length , 2 ) ;
108+
109+ // Check integration status bar item
110+ const integrationItem = items [ 0 ] ;
111+ assert . strictEqual ( integrationItem . text , '$(database) My Postgres DB' ) ;
112+ assert . strictEqual ( integrationItem . alignment , 1 ) ;
113+ assert . isDefined ( integrationItem . command ) ;
114+ assert . strictEqual ( integrationItem . command . command , 'deepnote.manageIntegrations' ) ;
115+ assert . deepStrictEqual ( integrationItem . command . arguments , [ integrationId ] ) ;
116+
117+ // Check variable status bar item
118+ const variableItem = items [ 1 ] ;
119+ assert . strictEqual ( variableItem . text , 'Variable: df' ) ;
120+ assert . strictEqual ( variableItem . alignment , 1 ) ;
121+ assert . isDefined ( variableItem . command ) ;
122+ assert . strictEqual ( variableItem . command . command , 'deepnote.updateSqlVariableName' ) ;
90123 } ) ;
91124
92125 test ( 'shows "Unknown integration (configure)" when config not found' , async ( ) => {
@@ -106,18 +139,65 @@ suite('SqlCellStatusBarProvider', () => {
106139 const result = await provider . provideCellStatusBarItems ( cell , cancellationToken ) ;
107140
108141 assert . isDefined ( result ) ;
109- assert . strictEqual ( ( result as any ) . text , '$(database) Unknown integration (configure)' ) ;
142+ assert . isArray ( result ) ;
143+ const items = result as any [ ] ;
144+ assert . strictEqual ( items . length , 2 ) ;
145+ assert . strictEqual ( items [ 0 ] . text , '$(database) Unknown integration (configure)' ) ;
146+ assert . strictEqual ( items [ 1 ] . text , 'Variable: df' ) ;
110147 } ) ;
111148
112- test ( 'returns undefined when notebook has no project ID' , async ( ) => {
149+ test ( 'returns only variable item when notebook has no project ID' , async ( ) => {
113150 const integrationId = 'postgres-123' ;
114151 const cell = createMockCell ( 'sql' , {
115152 sql_integration_id : integrationId
116153 } ) ;
117154
118155 const result = await provider . provideCellStatusBarItems ( cell , cancellationToken ) ;
119156
120- assert . isUndefined ( result ) ;
157+ assert . isDefined ( result ) ;
158+ assert . isArray ( result ) ;
159+ const items = result as any [ ] ;
160+ assert . strictEqual ( items . length , 1 ) ;
161+
162+ // Check variable status bar item is still shown
163+ const variableItem = items [ 0 ] ;
164+ assert . strictEqual ( variableItem . text , 'Variable: df' ) ;
165+ } ) ;
166+
167+ test ( 'shows custom variable name when set in metadata' , async ( ) => {
168+ const integrationId = 'postgres-123' ;
169+ const cell = createMockCell (
170+ 'sql' ,
171+ {
172+ sql_integration_id : integrationId ,
173+ deepnote_variable_name : 'my_results'
174+ } ,
175+ {
176+ deepnoteProjectId : 'project-1'
177+ }
178+ ) ;
179+
180+ when ( integrationStorage . getProjectIntegrationConfig ( anything ( ) , anything ( ) ) ) . thenResolve ( {
181+ id : integrationId ,
182+ name : 'My Postgres DB' ,
183+ type : IntegrationType . Postgres ,
184+ host : 'localhost' ,
185+ port : 5432 ,
186+ database : 'test' ,
187+ username : 'user' ,
188+ password : 'pass'
189+ } ) ;
190+
191+ const result = await provider . provideCellStatusBarItems ( cell , cancellationToken ) ;
192+
193+ assert . isDefined ( result ) ;
194+ assert . isArray ( result ) ;
195+ const items = result as any [ ] ;
196+ assert . strictEqual ( items . length , 2 ) ;
197+
198+ // Check variable status bar item shows custom name
199+ const variableItem = items [ 1 ] ;
200+ assert . strictEqual ( variableItem . text , 'Variable: my_results' ) ;
121201 } ) ;
122202
123203 function createMockCell (
0 commit comments