@@ -10,16 +10,19 @@ import {
1010 deleteDataConnector ,
1111} from "../../support/utils/dataConnectors" ;
1212import { login } from "../../support/utils/general" ;
13+ import { verifySearchIndexing } from "../../support/utils/search" ;
1314
1415const sessionId = [ "dataConnectors" , getRandomString ( ) ] ;
16+ const searchDataConnectorType = "type:DataConnector" ;
17+ const searchDataConnectorSlug = "slug:" ;
1518
1619describe ( "Data Connectors" , ( ) => {
1720 const randomString = getRandomString ( ) ;
1821 const projectName = `Project for data connector tests ${ randomString } ` ;
1922 const projectSlug = `project-for-data-connector-tests-${ randomString } ` ;
2023 let userNamespace : string ;
2124 let dataConnectorName : string ;
22- let projectId : string ;
25+ let projectId : string | undefined ;
2326 let groupName : string ;
2427 let groupSlug : string ;
2528
@@ -43,7 +46,7 @@ describe("Data Connectors", () => {
4346 } ) ;
4447
4548 after ( ( ) => {
46- deleteProject ( projectId ) ;
49+ if ( projectId ) deleteProject ( projectId ) ;
4750 } ) ;
4851
4952 beforeEach ( ( ) => {
@@ -121,8 +124,6 @@ describe("Data Connectors", () => {
121124 cy . getDataCy ( "data-connector-menu-dropdown" ) . click ( ) ;
122125 cy . getDataCy ( "data-connector-delete" ) . click ( ) ;
123126 } ) ;
124-
125- // Confirm deletion by typing the slug
126127 cy . getDataCy ( "delete-confirmation-input" ) . type ( dataConnectorName ) ;
127128 cy . getDataCy ( "delete-data-connector-modal-button" ) . click ( ) ;
128129
@@ -248,7 +249,6 @@ describe("Data Connectors", () => {
248249 projectId ,
249250 ) ;
250251
251- // ? Currently, data connectors newly linked might not appear immediately
252252 visitCurrentProject ( ) ;
253253 cy . getDataCy ( "data-connector-box" )
254254 . find ( `[data-cy=data-connector-name]` )
@@ -279,70 +279,54 @@ describe("Data Connectors", () => {
279279 cy . getDataCy ( "data-connector-edit-close-button" ) . click ( ) ;
280280
281281 // Verify the data connector is present with the edited name
282- visitCurrentProject ( ) ;
283282 cy . getDataCy ( "data-connector-box" )
284283 . find ( `[data-cy=data-connector-name]` )
285284 . contains ( newName ) ;
286285 } ) ;
287286
288- it ( "Link an existing data connector to a project" , ( ) => {
289- // Create a data connector not linked to a project
287+ it ( "Link and unlink an existing data connector to a project" , ( ) => {
288+ // Create a data connector not linked to a project and check it has been indexed
290289 const dataConnectorIdentifier = `${ userNamespace } /${ dataConnectorName } ` ;
291290 createDataConnector ( dataConnectorIdentifier ) ;
291+ verifySearchIndexing (
292+ `${ searchDataConnectorType } ${ searchDataConnectorSlug } ${ dataConnectorName } ` ,
293+ 1 ,
294+ ) ;
292295
293- // Now link the data connector to the project
296+ // Link the data connector to the project
294297 visitCurrentProject ( ) ;
295298 cy . getDataCy ( "add-data-connector" ) . click ( ) ;
296- cy . getDataCy ( "project-data-controller-mode-link" ) . click ( ) ;
297-
298- // Enter the data connector identifier
299- cy . get ( "#data-connector-identifier" )
299+ cy . getDataCy ( "data-connector-search-input" )
300300 . should ( "be.empty" )
301301 . type ( dataConnectorIdentifier ) ;
302- cy . getDataCy ( "link-data-connector-button" ) . click ( ) ;
302+ cy . getDataCy ( "data-connector-search-body" )
303+ . contains ( "[data-cy=link-data-connector-list-item]" , dataConnectorName )
304+ . find ( `[data-cy=data-connector-link-button]` )
305+ . click ( ) ;
303306
304307 // Verify the data connector is linked to the project
305- visitCurrentProject ( ) ;
308+ cy . getDataCy ( "project-data-connector-connect-header" )
309+ . find ( 'button[data-bs-dismiss="modal"]' )
310+ . click ( ) ;
306311 cy . getDataCy ( "data-connector-box" )
307312 . find ( `[data-cy=data-connector-name]` )
308313 . contains ( dataConnectorName ) ;
309- } ) ;
310314
311- it ( "Unlink a data connector from a project" , ( ) => {
312- // Create a data connector not linked to a project
313- const dataConnectorIdentifier = `${ userNamespace } /${ dataConnectorName } ` ;
314- createDataConnector ( dataConnectorIdentifier ) ;
315-
316- // Now link the data connector to the project
317- visitCurrentProject ( ) ;
318- cy . getDataCy ( "add-data-connector" ) . click ( ) ;
319- cy . getDataCy ( "project-data-controller-mode-link" ) . click ( ) ;
320-
321- // Enter the data connector identifier
322- cy . get ( "#data-connector-identifier" )
323- . should ( "be.empty" )
324- . type ( dataConnectorIdentifier ) ;
325- cy . getDataCy ( "link-data-connector-button" ) . click ( ) ;
326-
327- // ? Currently, data connectors newly linked might not appear immediately
328- visitCurrentProject ( ) ;
315+ // Unlink the data connector from the project
329316 cy . getDataCy ( "data-connector-box" )
330317 . find ( `[data-cy=data-connector-name]` )
331318 . contains ( dataConnectorName )
332319 . click ( ) ;
333-
334320 cy . getDataCy ( "data-connector-view" ) . within ( ( ) => {
335321 cy . getDataCy ( "data-connector-title" )
336322 . should ( "be.visible" )
337323 . contains ( dataConnectorName ) ;
338324 cy . getDataCy ( "data-connector-menu-dropdown" ) . click ( ) ;
339- cy . getDataCy ( "data-connector-unlink" ) . should ( "be.visible" ) . click ( ) ;
325+ cy . getDataCy ( "data-connector-unlink" ) . click ( ) ;
340326 } ) ;
341-
342327 cy . getDataCy ( "delete-data-connector-modal-button" ) . click ( ) ;
343328
344329 // Verify the data connector is no longer linked to the project
345- visitCurrentProject ( ) ;
346330 cy . getDataCy ( "data-connector-box" )
347331 . contains ( `[data-cy=data-connector-name]` , dataConnectorName )
348332 . should ( "not.exist" ) ;
@@ -359,31 +343,38 @@ describe("Data Connectors", () => {
359343 slug : otherProjectName ,
360344 visibility : "private" ,
361345 } ) . then ( ( response ) => {
362- const otherProjectId = response . body . id ;
346+ const otherProjectId = response . body . id ?? "" ;
363347
364348 // Defer-delete the other project (which will also delete the data connector)
365349 cy . defer ( ( ) => {
366- deleteProject ( otherProjectId ) ;
350+ if ( otherProjectId ) deleteProject ( otherProjectId ) ;
367351 } ) ;
368352
369- // Create a data connector in the other project
353+ // Create a data connector in the other project and check it has been indexed
370354 const dataConnectorIdentifier = `${ userNamespace } /${ otherProjectName } /${ dataConnectorName } ` ;
371355 createDataConnector ( dataConnectorIdentifier , otherProjectId ) ;
356+ verifySearchIndexing (
357+ `${ searchDataConnectorType } ${ searchDataConnectorSlug } ${ dataConnectorName } ` ,
358+ 1 ,
359+ ) ;
372360
373361 // Navigate to the main project
374362 visitCurrentProject ( ) ;
375363
376364 // Link the data connector from the other project to the main project
377365 cy . getDataCy ( "add-data-connector" ) . click ( ) ;
378- cy . getDataCy ( "project-data-controller-mode-link" ) . click ( ) ;
379-
380- cy . get ( "#data-connector-identifier" )
366+ cy . getDataCy ( "data-connector-search-input" )
381367 . should ( "be.empty" )
382368 . type ( dataConnectorIdentifier ) ;
383- cy . getDataCy ( "link-data-connector-button" ) . click ( ) ;
369+ cy . getDataCy ( "data-connector-search-body" )
370+ . contains ( "[data-cy=link-data-connector-list-item]" , dataConnectorName )
371+ . find ( `[data-cy=data-connector-link-button]` )
372+ . click ( ) ;
384373
385374 // Verify the data connector is linked to the main project
386- visitCurrentProject ( ) ;
375+ cy . getDataCy ( "project-data-connector-connect-header" )
376+ . find ( 'button[data-bs-dismiss="modal"]' )
377+ . click ( ) ;
387378 cy . getDataCy ( "data-connector-box" )
388379 . find ( `[data-cy=data-connector-name]` )
389380 . contains ( dataConnectorName )
@@ -395,12 +386,11 @@ describe("Data Connectors", () => {
395386 . should ( "be.visible" )
396387 . contains ( dataConnectorName ) ;
397388 cy . getDataCy ( "data-connector-menu-dropdown" ) . click ( ) ;
398- cy . getDataCy ( "data-connector-unlink" ) . should ( "be.visible" ) . click ( ) ;
389+ cy . getDataCy ( "data-connector-unlink" ) . click ( ) ;
399390 } ) ;
400391 cy . getDataCy ( "delete-data-connector-modal-button" ) . click ( ) ;
401392
402393 // Verify the data connector is no longer linked to the main project
403- visitCurrentProject ( ) ;
404394 cy . getDataCy ( "data-connector-box" )
405395 . contains ( `[data-cy=data-connector-name]` , dataConnectorName )
406396 . should ( "not.exist" ) ;
@@ -468,21 +458,28 @@ describe("Data Connectors", () => {
468458 // Create a data connector owned by the group
469459 const dataConnectorIdentifier = `${ groupSlug } /${ dataConnectorName } ` ;
470460 createDataConnector ( dataConnectorIdentifier ) ;
461+ verifySearchIndexing (
462+ `${ searchDataConnectorType } ${ searchDataConnectorSlug } ${ dataConnectorName } ` ,
463+ 1 ,
464+ ) ;
471465
472466 // Navigate to the user's project
473467 visitCurrentProject ( ) ;
474468
475469 // Link the group data connector to the user's project
476470 cy . getDataCy ( "add-data-connector" ) . click ( ) ;
477- cy . getDataCy ( "project-data-controller-mode-link" ) . click ( ) ;
478-
479- // Enter the data connector identifier
480- cy . get ( "#data-connector-identifier" )
471+ cy . getDataCy ( "data-connector-search-input" )
481472 . should ( "be.empty" )
482473 . type ( dataConnectorIdentifier ) ;
483- cy . getDataCy ( "link-data-connector-button" ) . click ( ) ;
474+ cy . getDataCy ( "data-connector-search-body" )
475+ . contains ( "[data-cy=link-data-connector-list-item]" , dataConnectorName )
476+ . find ( `[data-cy=data-connector-link-button]` )
477+ . click ( ) ;
484478
485479 // Verify the data connector is linked to the project
480+ cy . getDataCy ( "project-data-connector-connect-header" )
481+ . find ( 'button[data-bs-dismiss="modal"]' )
482+ . click ( ) ;
486483 cy . getDataCy ( "data-connector-box" )
487484 . find ( `[data-cy=data-connector-name]` )
488485 . contains ( dataConnectorName )
@@ -493,8 +490,8 @@ describe("Data Connectors", () => {
493490 cy . getDataCy ( "data-connector-title" )
494491 . should ( "be.visible" )
495492 . contains ( dataConnectorName ) ;
496- cy . getDataCy ( "data-connector-menu-dropdown" ) . should ( "be.visible" ) . click ( ) ;
497- cy . getDataCy ( "data-connector-unlink" ) . should ( "be.visible" ) . click ( ) ;
493+ cy . getDataCy ( "data-connector-menu-dropdown" ) . click ( ) ;
494+ cy . getDataCy ( "data-connector-unlink" ) . click ( ) ;
498495 } ) ;
499496 cy . getDataCy ( "delete-data-connector-modal-button" ) . click ( ) ;
500497
0 commit comments