@@ -183,6 +183,83 @@ suite('DeepnoteNotebookManager', () => {
183183 } ) ;
184184 } ) ;
185185
186+ suite ( 'updateProjectIntegrations' , ( ) => {
187+ test ( 'should update integrations list for existing project' , ( ) => {
188+ manager . storeOriginalProject ( 'project-123' , mockProject , 'notebook-456' ) ;
189+
190+ const integrations = [
191+ { id : 'int-1' , name : 'PostgreSQL' , type : 'pgsql' } ,
192+ { id : 'int-2' , name : 'BigQuery' , type : 'big-query' }
193+ ] ;
194+
195+ manager . updateProjectIntegrations ( 'project-123' , integrations ) ;
196+
197+ const updatedProject = manager . getOriginalProject ( 'project-123' ) ;
198+ assert . deepStrictEqual ( updatedProject ?. project . integrations , integrations ) ;
199+ } ) ;
200+
201+ test ( 'should replace existing integrations list' , ( ) => {
202+ const projectWithIntegrations : DeepnoteProject = {
203+ ...mockProject ,
204+ project : {
205+ ...mockProject . project ,
206+ integrations : [ { id : 'old-int' , name : 'Old Integration' , type : 'pgsql' } ]
207+ }
208+ } ;
209+
210+ manager . storeOriginalProject ( 'project-123' , projectWithIntegrations , 'notebook-456' ) ;
211+
212+ const newIntegrations = [
213+ { id : 'new-int-1' , name : 'New Integration 1' , type : 'pgsql' } ,
214+ { id : 'new-int-2' , name : 'New Integration 2' , type : 'big-query' }
215+ ] ;
216+
217+ manager . updateProjectIntegrations ( 'project-123' , newIntegrations ) ;
218+
219+ const updatedProject = manager . getOriginalProject ( 'project-123' ) ;
220+ assert . deepStrictEqual ( updatedProject ?. project . integrations , newIntegrations ) ;
221+ } ) ;
222+
223+ test ( 'should handle empty integrations array' , ( ) => {
224+ const projectWithIntegrations : DeepnoteProject = {
225+ ...mockProject ,
226+ project : {
227+ ...mockProject . project ,
228+ integrations : [ { id : 'int-1' , name : 'Integration 1' , type : 'pgsql' } ]
229+ }
230+ } ;
231+
232+ manager . storeOriginalProject ( 'project-123' , projectWithIntegrations , 'notebook-456' ) ;
233+
234+ manager . updateProjectIntegrations ( 'project-123' , [ ] ) ;
235+
236+ const updatedProject = manager . getOriginalProject ( 'project-123' ) ;
237+ assert . deepStrictEqual ( updatedProject ?. project . integrations , [ ] ) ;
238+ } ) ;
239+
240+ test ( 'should do nothing for unknown project' , ( ) => {
241+ // Should not throw an error
242+ manager . updateProjectIntegrations ( 'unknown-project' , [ { id : 'int-1' , name : 'Integration' , type : 'pgsql' } ] ) ;
243+
244+ const project = manager . getOriginalProject ( 'unknown-project' ) ;
245+ assert . strictEqual ( project , undefined ) ;
246+ } ) ;
247+
248+ test ( 'should preserve other project properties' , ( ) => {
249+ manager . storeOriginalProject ( 'project-123' , mockProject , 'notebook-456' ) ;
250+
251+ const integrations = [ { id : 'int-1' , name : 'PostgreSQL' , type : 'pgsql' } ] ;
252+
253+ manager . updateProjectIntegrations ( 'project-123' , integrations ) ;
254+
255+ const updatedProject = manager . getOriginalProject ( 'project-123' ) ;
256+ assert . strictEqual ( updatedProject ?. project . id , mockProject . project . id ) ;
257+ assert . strictEqual ( updatedProject ?. project . name , mockProject . project . name ) ;
258+ assert . strictEqual ( updatedProject ?. version , mockProject . version ) ;
259+ assert . deepStrictEqual ( updatedProject ?. metadata , mockProject . metadata ) ;
260+ } ) ;
261+ } ) ;
262+
186263 suite ( 'integration scenarios' , ( ) => {
187264 test ( 'should handle complete workflow for multiple projects' , ( ) => {
188265 manager . storeOriginalProject ( 'project-1' , mockProject , 'notebook-1' ) ;
0 commit comments