@@ -14,13 +14,15 @@ import {
1414 listOrganizationAccountPeopleContract ,
1515 updateOrganizationAccountsContract ,
1616} from '@/lib/api/contracts/organization-accounts'
17+ import { resourceScopeKey } from '@/lib/core/resource-scope'
1718import {
1819 organizationAccountsKeys ,
1920 useDisconnectPersonalOrganizationAccount ,
2021 useOrganizationAccountPeople ,
2122 useUpdateOrganizationAccounts ,
2223} from '@/hooks/queries/organization-accounts'
2324import { slackSearchKeys } from '@/hooks/queries/slack-search'
25+ import { knowledgeKeys } from '@/hooks/queries/utils/knowledge-keys'
2426import { searchSourceKeys } from '@/hooks/queries/utils/search-source-keys'
2527
2628describe ( 'personal account disconnect' , ( ) => {
@@ -48,7 +50,39 @@ describe('personal account disconnect', () => {
4850 )
4951 const people = organizationAccountsKeys . people ( 'org-1' )
5052 const other = searchSourceKeys . list ( { kind : 'organization' , organizationId : 'org-2' } )
51- for ( const key of [ own , catalog , people , other ] ) client . setQueryData ( key , { existing : true } )
53+ const results = knowledgeKeys . search (
54+ resourceScopeKey ( { kind : 'organization' , organizationId : 'org-1' } ) ,
55+ 'private content'
56+ )
57+ const otherResults = knowledgeKeys . search (
58+ resourceScopeKey ( { kind : 'organization' , organizationId : 'org-2' } ) ,
59+ 'private content'
60+ )
61+ const workspaceResults = knowledgeKeys . search ( 'workspace-1' , 'private content' )
62+ const ownDocument = knowledgeKeys . document ( 'kb-1' , 'document-1' )
63+ const chunks = knowledgeKeys . chunks ( 'kb-2' , 'document-2' , '' )
64+ const otherDocument = knowledgeKeys . document ( 'kb-other' , 'document-other' )
65+ const resultOnlyDocument = knowledgeKeys . document ( 'kb-result-only' , 'document-result-only' )
66+ const sourcePages = {
67+ pages : [
68+ { sources : [ { knowledgeBaseId : 'kb-1' } ] , nextCursor : 'next' } ,
69+ { sources : [ { knowledgeBaseId : 'kb-2' } ] , nextCursor : null } ,
70+ ] ,
71+ pageParams : [ undefined , 'next' ] ,
72+ }
73+ for ( const key of [ own , catalog ] ) client . setQueryData ( key , sourcePages )
74+ client . setQueryData ( results , [ { knowledgeBaseId : 'kb-result-only' } ] )
75+ for ( const key of [
76+ people ,
77+ other ,
78+ otherResults ,
79+ workspaceResults ,
80+ ownDocument ,
81+ resultOnlyDocument ,
82+ chunks ,
83+ otherDocument ,
84+ ] )
85+ client . setQueryData ( key , { content : 'previously authorized content' } )
5286 try {
5387 await act ( async ( ) =>
5488 root . render (
@@ -78,9 +112,14 @@ describe('personal account disconnect', () => {
78112 disconnectPersonalOrganizationAccountContract ,
79113 { params : { credentialId : 'own-credential' } }
80114 )
81- for ( const key of [ own , catalog , people ] )
82- expect ( client . getQueryState ( key ) ?. isInvalidated ) . toBe ( success )
115+ for ( const key of [ own , catalog , results , ownDocument , resultOnlyDocument , chunks ] ) {
116+ if ( success ) expect ( client . getQueryData ( key ) ) . toBeUndefined ( )
117+ else expect ( client . getQueryData ( key ) ) . toBeDefined ( )
118+ }
119+ expect ( client . getQueryState ( people ) ?. isInvalidated ) . toBe ( success )
83120 expect ( client . getQueryState ( other ) ?. isInvalidated ) . toBe ( false )
121+ for ( const key of [ otherResults , workspaceResults , otherDocument ] )
122+ expect ( client . getQueryData ( key ) ) . toEqual ( { content : 'previously authorized content' } )
84123 } finally {
85124 await act ( async ( ) => root . unmount ( ) )
86125 client . clear ( )
0 commit comments