@@ -27,10 +27,14 @@ describe('Multi database', () => {
2727 cy . get ( '[data-testid="dbs-command-list"] li' , {
2828 timeout : 5000
2929 } )
30- const databaseOptionList = ( ) =>
30+ const databaseOptionListOptions = ( ) =>
3131 cy . get ( '[data-testid="database-selection-list"] option' , {
3232 timeout : 5000
3333 } )
34+ const databaseOptionList = ( ) =>
35+ cy . get ( '[data-testid="database-selection-list"]' , {
36+ timeout : 5000
37+ } )
3438
3539 before ( ( ) => {
3640 cy . visit ( Cypress . config ( 'url' ) )
@@ -83,19 +87,48 @@ describe('Multi database', () => {
8387 it ( 'lists databases in sidebar' , ( ) => {
8488 cy . executeCommand ( ':clear' )
8589 cy . get ( '[data-testid="drawerDBMS"]' ) . click ( )
86- databaseOptionList ( ) . should ( 'have.length' , 2 )
90+ databaseOptionListOptions ( ) . should ( 'have.length' , 2 )
91+ cy . get ( '[data-testid="drawerDBMS"]' ) . click ( )
8792 } )
8893 if ( isEnterpriseEdition ( ) ) {
89- it ( 'lists new databases in sidebar' , ( ) => {
94+ it ( 'adds databases to the sidebar and adds backticks to special db names' , ( ) => {
95+ // Add db
9096 cy . executeCommand ( ':use system' )
91- cy . executeCommand ( 'CREATE DATABASE sidebartest' )
92- databaseOptionList ( ) . should ( 'have.length' , 3 )
93- databaseOptionList ( ) . contains ( 'system' )
94- databaseOptionList ( ) . contains ( 'neo4j' )
95- databaseOptionList ( ) . contains ( 'sidebartest' )
97+ cy . executeCommand ( 'CREATE DATABASE `name-with-dash`' )
98+ cy . resultContains ( '1 system update' )
99+ cy . executeCommand ( ':clear' )
96100
97- cy . executeCommand ( 'DROP DATABASE sidebartest' )
98- databaseOptionList ( ) . should ( 'have.length' , 2 )
101+ // Count items in list
102+ cy . get ( '[data-testid="drawerDBMS"]' ) . click ( )
103+ databaseOptionListOptions ( ) . should ( 'have.length' , 3 )
104+ databaseOptionListOptions ( ) . contains ( 'system' )
105+ databaseOptionListOptions ( ) . contains ( 'neo4j' )
106+ databaseOptionListOptions ( ) . contains ( 'name-with-dash' )
107+
108+ // Select to use db, make sure backticked
109+ databaseOptionList ( ) . select ( 'name-with-dash' )
110+ cy . get ( '[data-testid="frameCommand"]' , { timeout : 10000 } )
111+ . first ( )
112+ . should ( 'contain' , ':use `name-with-dash`' )
113+ cy . resultContains (
114+ 'Queries from this point and forward are using the database'
115+ )
116+
117+ // Try without backticks
118+ cy . executeCommand ( ':use system' )
119+ cy . resultContains (
120+ 'Queries from this point and forward are using the database'
121+ )
122+ cy . executeCommand ( ':clear' )
123+ cy . executeCommand ( ':use name-with-dash' )
124+ cy . resultContains (
125+ 'Queries from this point and forward are using the database'
126+ )
127+
128+ // Cleanup
129+ cy . executeCommand ( ':use system' )
130+ cy . executeCommand ( 'DROP DATABASE `name-with-dash`' )
131+ databaseOptionListOptions ( ) . should ( 'have.length' , 2 )
99132 cy . get ( '[data-testid="drawerDBMS"]' ) . click ( )
100133 } )
101134 }
0 commit comments