@@ -13,7 +13,6 @@ vi.mock('@/lib/api/client/request', () => ({
1313} ) )
1414
1515import { warmSettingsSectionQuery } from '@/app/workspace/[workspaceId]/w/components/sidebar/components/settings-sidebar/settings-query-warmers'
16- import { apiKeysQueryOptions } from '@/hooks/queries/api-key-list'
1716import { workspaceCredentialListQueryOptions } from '@/hooks/queries/utils/fetch-workspace-credentials'
1817
1918let queryClient : QueryClient
@@ -25,16 +24,16 @@ describe('settings query warmers', () => {
2524 defaultOptions : { queries : { retry : false , retryOnMount : false } } ,
2625 } )
2726 mockRequestJson . mockImplementation ( ( contract : { path : string } ) => {
28- if ( contract . path === '/api/mcp/servers' || contract . path === '/api/mcp/workflow-servers' ) {
29- return Promise . resolve ( { data : { servers : [ ] } } )
30- }
31- if ( contract . path === '/api/workspaces/[id]/sandboxes' ) {
32- return Promise . resolve ( { sandboxes : [ ] , entitled : true , strategy : 'prebuilt' } )
33- }
3427 if ( contract . path === '/api/credentials' ) {
3528 return Promise . resolve ( { credentials : [ ] } )
3629 }
37- return Promise . resolve ( { keys : [ ] } )
30+ if (
31+ contract . path === '/api/billing' ||
32+ contract . path === '/api/organizations/[id]/billing-summary'
33+ ) {
34+ return Promise . resolve ( { } )
35+ }
36+ throw new Error ( `Unexpected settings warmer contract: ${ contract . path } ` )
3837 } )
3938 } )
4039
@@ -43,28 +42,11 @@ describe('settings query warmers', () => {
4342 vi . clearAllMocks ( )
4443 } )
4544
46- it ( 'warms only the approved first-content list for each section' , async ( ) => {
47- expect ( warmSettingsSectionQuery ( queryClient , personalContext , 'apikeys' ) ) . toBe ( true )
48- expect ( warmSettingsSectionQuery ( queryClient , personalContext , 'sandboxes' ) ) . toBe ( true )
49- expect ( warmSettingsSectionQuery ( queryClient , personalContext , 'byok' ) ) . toBe ( true )
50- expect ( warmSettingsSectionQuery ( queryClient , personalContext , 'mcp' ) ) . toBe ( true )
45+ it ( 'warms only first-content data already present in the shared sidebar graph' , async ( ) => {
5146 expect ( warmSettingsSectionQuery ( queryClient , personalContext , 'secrets' ) ) . toBe ( true )
52- expect ( warmSettingsSectionQuery ( queryClient , personalContext , 'workflow-mcp-servers' ) ) . toBe (
53- true
54- )
5547
56- await vi . waitFor ( ( ) => expect ( mockRequestJson ) . toHaveBeenCalledTimes ( 7 ) )
57- expect ( mockRequestJson . mock . calls . map ( ( [ contract ] ) => contract . path ) ) . toEqual (
58- expect . arrayContaining ( [
59- '/api/workspaces/[id]/api-keys' ,
60- '/api/users/me/api-keys' ,
61- '/api/workspaces/[id]/sandboxes' ,
62- '/api/workspaces/[id]/byok-keys' ,
63- '/api/mcp/servers' ,
64- '/api/mcp/workflow-servers' ,
65- '/api/credentials' ,
66- ] )
67- )
48+ await vi . waitFor ( ( ) => expect ( mockRequestJson ) . toHaveBeenCalledTimes ( 1 ) )
49+ expect ( mockRequestJson . mock . calls [ 0 ] [ 0 ] . path ) . toBe ( '/api/credentials' )
6850 expect (
6951 mockRequestJson . mock . calls . find ( ( [ contract ] ) => contract . path === '/api/credentials' ) ?. [ 1 ]
7052 ) . toEqual (
@@ -73,6 +55,13 @@ describe('settings query warmers', () => {
7355 } )
7456
7557 it ( 'does not warm broad settings data' , ( ) => {
58+ expect ( warmSettingsSectionQuery ( queryClient , personalContext , 'apikeys' ) ) . toBe ( false )
59+ expect ( warmSettingsSectionQuery ( queryClient , personalContext , 'sandboxes' ) ) . toBe ( false )
60+ expect ( warmSettingsSectionQuery ( queryClient , personalContext , 'byok' ) ) . toBe ( false )
61+ expect ( warmSettingsSectionQuery ( queryClient , personalContext , 'mcp' ) ) . toBe ( false )
62+ expect ( warmSettingsSectionQuery ( queryClient , personalContext , 'workflow-mcp-servers' ) ) . toBe (
63+ false
64+ )
7665 expect ( warmSettingsSectionQuery ( queryClient , personalContext , 'custom-tools' ) ) . toBe ( false )
7766
7867 expect ( mockRequestJson ) . not . toHaveBeenCalled ( )
@@ -100,15 +89,6 @@ describe('settings query warmers', () => {
10089 )
10190 } )
10291
103- it ( 'deduplicates a successful API-key warm with the eventual consumer' , async ( ) => {
104- warmSettingsSectionQuery ( queryClient , personalContext , 'apikeys' )
105- await vi . waitFor ( ( ) => expect ( mockRequestJson ) . toHaveBeenCalledTimes ( 2 ) )
106-
107- await queryClient . fetchQuery ( apiKeysQueryOptions ( 'workspace-1' , 'combined' ) )
108-
109- expect ( mockRequestJson ) . toHaveBeenCalledTimes ( 2 )
110- } )
111-
11292 it ( 'keeps the Secrets warmer and consumer on mount-recoverable shared options' , ( ) => {
11393 const options = workspaceCredentialListQueryOptions ( 'workspace-1' , 'env_workspace' )
11494
0 commit comments