2020
2121import { cleanupSettings } from './dbMetaEpics'
2222import { ClientSettings } from './dbMetaDuck'
23+ import { SemVer } from 'semver'
2324
2425const defaultSettings : ClientSettings = {
2526 allowOutgoingConnections : true ,
@@ -30,7 +31,7 @@ const defaultSettings: ClientSettings = {
3031 retainEditorHistory : true ,
3132 allowTelemetry : true ,
3233 authEnabled : true ,
33- metricsNamespacesEnabled : false ,
34+ metricsNamespacesEnabled : true ,
3435 metricsPrefix : 'neo4j'
3536}
3637
@@ -58,60 +59,94 @@ describe('cleanupSettings', () => {
5859 retainEditorHistory : true ,
5960 allowTelemetry : true ,
6061 authEnabled : true ,
61- metricsNamespacesEnabled : false ,
62+ metricsNamespacesEnabled : true ,
6263 metricsPrefix : 'neo4j4j'
6364 }
6465
65- const newSettings = cleanupSettings ( rawSettings )
66+ const newSettings = cleanupSettings ( rawSettings , null )
6667
6768 expect ( newSettings ) . toEqual ( expectedSettings )
6869 } )
6970 test ( 'default values' , ( ) => {
70- const newSettings = cleanupSettings ( { } )
71+ const newSettings = cleanupSettings ( { } , null )
7172 expect ( newSettings ) . toEqual ( defaultSettings )
7273 } )
7374 test ( 'browser.allow_outgoing_connections="false"' , ( ) => {
74- const newSettings = cleanupSettings ( {
75- 'browser.allow_outgoing_connections' : 'false'
76- } )
75+ const newSettings = cleanupSettings (
76+ {
77+ 'browser.allow_outgoing_connections' : 'false'
78+ } ,
79+ null
80+ )
7781 const expectedSettings = {
7882 ...defaultSettings ,
7983 allowOutgoingConnections : false
8084 }
8185 expect ( newSettings ) . toEqual ( expectedSettings )
8286 } )
8387 test ( 'browser.allow_outgoing_connections="true"' , ( ) => {
84- const newSettings = cleanupSettings ( {
85- 'browser.allow_outgoing_connections' : 'true'
86- } )
88+ const newSettings = cleanupSettings (
89+ {
90+ 'browser.allow_outgoing_connections' : 'true'
91+ } ,
92+ null
93+ )
8794 const expectedSettings : ClientSettings = {
8895 ...defaultSettings ,
8996 allowOutgoingConnections : true
9097 }
9198 expect ( newSettings ) . toEqual ( expectedSettings )
9299 } )
93100 test ( 'clients.allow_telemetry="false"' , ( ) => {
94- const newSettings = cleanupSettings ( { 'clients.allow_telemetry' : 'false' } )
101+ const newSettings = cleanupSettings (
102+ { 'clients.allow_telemetry' : 'false' } ,
103+ null
104+ )
95105 const expectedSettings : ClientSettings = {
96106 ...defaultSettings ,
97107 allowTelemetry : false
98108 }
99109 expect ( newSettings ) . toEqual ( expectedSettings )
100110 } )
101111 test ( 'client.allow_telemetry="false"' , ( ) => {
102- const newSettings = cleanupSettings ( { 'client.allow_telemetry' : 'false' } )
112+ const newSettings = cleanupSettings (
113+ { 'client.allow_telemetry' : 'false' } ,
114+ null
115+ )
103116 const expectedSettings : ClientSettings = {
104117 ...defaultSettings ,
105118 allowTelemetry : false
106119 }
107120 expect ( newSettings ) . toEqual ( expectedSettings )
108121 } )
109122 test ( 'server.metrics.prefix=""' , ( ) => {
110- const newSettings = cleanupSettings ( { 'server.metrics.prefix' : '' } )
123+ const newSettings = cleanupSettings ( { 'server.metrics.prefix' : '' } , null )
111124 const expectedSettings : ClientSettings = {
112125 ...defaultSettings ,
113126 metricsPrefix : ''
114127 }
115128 expect ( newSettings ) . toEqual ( expectedSettings )
116129 } )
130+ test ( 'metricsNamespacesEnabled should be default false in 4.0' , ( ) => {
131+ const newSettings = cleanupSettings (
132+ { 'server.metrics.namespaces.enabled' : '' } ,
133+ new SemVer ( '4.0.0' )
134+ )
135+ const expectedSettings : ClientSettings = {
136+ ...defaultSettings ,
137+ metricsNamespacesEnabled : false
138+ }
139+ expect ( newSettings ) . toEqual ( expectedSettings )
140+ } )
141+ test ( 'metricsNamespacesEnabled should be default true in 5.0' , ( ) => {
142+ const newSettings = cleanupSettings (
143+ { 'server.metrics.namespaces.enabled' : '' } ,
144+ new SemVer ( '5.0.0' )
145+ )
146+ const expectedSettings : ClientSettings = {
147+ ...defaultSettings ,
148+ metricsNamespacesEnabled : true
149+ }
150+ expect ( newSettings ) . toEqual ( expectedSettings )
151+ } )
117152} )
0 commit comments