@@ -15,7 +15,6 @@ const mockConfigData = {
1515 canInstallPlugins : false ,
1616 canActivatePlugins : true ,
1717 hasFeedback : true ,
18- hasAI : false ,
1918 formsResponsesUrl : 'https://example.com/wp-admin/edit.php?post_type=feedback' ,
2019 blogId : 12345 ,
2120 gdriveConnectSupportURL : 'https://example.com/support' ,
@@ -43,7 +42,7 @@ describe( 'useConfigValue', () => {
4342 } ) ;
4443
4544 it ( 'returns undefined when config is not loaded' , ( ) => {
46- const { result } = renderHook ( ( ) => useConfigValue ( 'hasAI ' ) , { wrapper } ) ;
45+ const { result } = renderHook ( ( ) => useConfigValue ( 'isIntegrationsEnabled ' ) , { wrapper } ) ;
4746
4847 expect ( result . current ) . toBeUndefined ( ) ;
4948 } ) ;
@@ -52,9 +51,9 @@ describe( 'useConfigValue', () => {
5251 // Populate the store with config data
5352 registry . dispatch ( CONFIG_STORE ) . receiveConfig ( mockConfigData ) ;
5453
55- const { result } = renderHook ( ( ) => useConfigValue ( 'hasAI ' ) , { wrapper } ) ;
54+ const { result } = renderHook ( ( ) => useConfigValue ( 'isIntegrationsEnabled ' ) , { wrapper } ) ;
5655
57- expect ( result . current ) . toBe ( false ) ;
56+ expect ( result . current ) . toBe ( true ) ;
5857 } ) ;
5958
6059 it ( 'returns boolean values correctly' , ( ) => {
@@ -63,14 +62,12 @@ describe( 'useConfigValue', () => {
6362 const { result : mailpoetResult } = renderHook ( ( ) => useConfigValue ( 'isMailPoetEnabled' ) , {
6463 wrapper,
6564 } ) ;
66- const { result : aiResult } = renderHook ( ( ) => useConfigValue ( 'hasAI' ) , { wrapper } ) ;
6765 const { result : integrationsResult } = renderHook (
6866 ( ) => useConfigValue ( 'isIntegrationsEnabled' ) ,
6967 { wrapper }
7068 ) ;
7169
7270 expect ( mailpoetResult . current ) . toBe ( true ) ;
73- expect ( aiResult . current ) . toBe ( false ) ;
7471 expect ( integrationsResult . current ) . toBe ( true ) ;
7572 } ) ;
7673
@@ -101,21 +98,23 @@ describe( 'useConfigValue', () => {
10198 it ( 'returns undefined for non-existent keys' , ( ) => {
10299 registry . dispatch ( CONFIG_STORE ) . receiveConfig ( { isMailPoetEnabled : true } ) ;
103100
104- const { result } = renderHook ( ( ) => useConfigValue ( 'hasAI ' ) , { wrapper } ) ;
101+ const { result } = renderHook ( ( ) => useConfigValue ( 'isIntegrationsEnabled ' ) , { wrapper } ) ;
105102
106103 expect ( result . current ) . toBeUndefined ( ) ;
107104 } ) ;
108105
109106 it ( 'updates when config value changes' , ( ) => {
110- registry . dispatch ( CONFIG_STORE ) . receiveConfig ( { hasAI : false } ) ;
107+ registry . dispatch ( CONFIG_STORE ) . receiveConfig ( { isIntegrationsEnabled : false } ) ;
111108
112- const { result, rerender } = renderHook ( ( ) => useConfigValue ( 'hasAI' ) , { wrapper } ) ;
109+ const { result, rerender } = renderHook ( ( ) => useConfigValue ( 'isIntegrationsEnabled' ) , {
110+ wrapper,
111+ } ) ;
113112
114113 expect ( result . current ) . toBe ( false ) ;
115114
116115 // Update the config
117116 act ( ( ) => {
118- registry . dispatch ( CONFIG_STORE ) . receiveConfigValue ( 'hasAI ' , true ) ;
117+ registry . dispatch ( CONFIG_STORE ) . receiveConfigValue ( 'isIntegrationsEnabled ' , true ) ;
119118 } ) ;
120119 rerender ( ) ;
121120
@@ -125,23 +124,28 @@ describe( 'useConfigValue', () => {
125124 it ( 'multiple hooks can read different config values' , ( ) => {
126125 registry . dispatch ( CONFIG_STORE ) . receiveConfig ( mockConfigData ) ;
127126
128- const { result : hasAI } = renderHook ( ( ) => useConfigValue ( 'hasAI' ) , { wrapper } ) ;
127+ const { result : isIntegrations } = renderHook (
128+ ( ) => useConfigValue ( 'isIntegrationsEnabled' ) ,
129+ { wrapper }
130+ ) ;
129131 const { result : blogId } = renderHook ( ( ) => useConfigValue ( 'blogId' ) , { wrapper } ) ;
130132 const { result : isMailPoet } = renderHook ( ( ) => useConfigValue ( 'isMailPoetEnabled' ) , {
131133 wrapper,
132134 } ) ;
133135
134- expect ( hasAI . current ) . toBe ( false ) ;
136+ expect ( isIntegrations . current ) . toBe ( true ) ;
135137 expect ( blogId . current ) . toBe ( 12345 ) ;
136138 expect ( isMailPoet . current ) . toBe ( true ) ;
137139 } ) ;
138140
139141 it ( 'returns undefined when config is invalidated' , ( ) => {
140142 registry . dispatch ( CONFIG_STORE ) . receiveConfig ( mockConfigData ) ;
141143
142- const { result, rerender } = renderHook ( ( ) => useConfigValue ( 'hasAI' ) , { wrapper } ) ;
144+ const { result, rerender } = renderHook ( ( ) => useConfigValue ( 'isIntegrationsEnabled' ) , {
145+ wrapper,
146+ } ) ;
143147
144- expect ( result . current ) . toBe ( false ) ;
148+ expect ( result . current ) . toBe ( true ) ;
145149
146150 // Invalidate the config
147151 act ( ( ) => {
@@ -156,38 +160,43 @@ describe( 'useConfigValue', () => {
156160 // Only set a few config values
157161 registry . dispatch ( CONFIG_STORE ) . receiveConfig ( {
158162 isMailPoetEnabled : true ,
159- hasAI : false ,
163+ isIntegrationsEnabled : false ,
160164 } ) ;
161165
162166 const { result : mailpoetResult } = renderHook ( ( ) => useConfigValue ( 'isMailPoetEnabled' ) , {
163167 wrapper,
164168 } ) ;
165- const { result : aiResult } = renderHook ( ( ) => useConfigValue ( 'hasAI' ) , { wrapper } ) ;
169+ const { result : integrationsResult } = renderHook (
170+ ( ) => useConfigValue ( 'isIntegrationsEnabled' ) ,
171+ { wrapper }
172+ ) ;
166173 const { result : blogIdResult } = renderHook ( ( ) => useConfigValue ( 'blogId' ) , { wrapper } ) ;
167174
168175 expect ( mailpoetResult . current ) . toBe ( true ) ;
169- expect ( aiResult . current ) . toBe ( false ) ;
176+ expect ( integrationsResult . current ) . toBe ( false ) ;
170177 expect ( blogIdResult . current ) . toBeUndefined ( ) ;
171178 } ) ;
172179
173180 it ( 'works with different config keys in the same component' , ( ) => {
174181 registry . dispatch ( CONFIG_STORE ) . receiveConfig ( mockConfigData ) ;
175182
176- const { result : result1 } = renderHook ( ( ) => useConfigValue ( 'hasAI' ) , { wrapper } ) ;
183+ const { result : result1 } = renderHook ( ( ) => useConfigValue ( 'isIntegrationsEnabled' ) , {
184+ wrapper,
185+ } ) ;
177186 const { result : result2 } = renderHook ( ( ) => useConfigValue ( 'blogId' ) , { wrapper } ) ;
178187 const { result : result3 } = renderHook ( ( ) => useConfigValue ( 'canInstallPlugins' ) , {
179188 wrapper,
180189 } ) ;
181190
182- expect ( result1 . current ) . toBe ( false ) ;
191+ expect ( result1 . current ) . toBe ( true ) ;
183192 expect ( result2 . current ) . toBe ( 12345 ) ;
184193 expect ( result3 . current ) . toBe ( false ) ;
185194 } ) ;
186195
187196 it ( 'handles empty config object' , ( ) => {
188197 registry . dispatch ( CONFIG_STORE ) . receiveConfig ( { } ) ;
189198
190- const { result } = renderHook ( ( ) => useConfigValue ( 'hasAI ' ) , { wrapper } ) ;
199+ const { result } = renderHook ( ( ) => useConfigValue ( 'isIntegrationsEnabled ' ) , { wrapper } ) ;
191200
192201 expect ( result . current ) . toBeUndefined ( ) ;
193202 } ) ;
0 commit comments