@@ -7,6 +7,7 @@ import { beforeEach, describe, expect, it, vi } from 'vitest'
77const mocks = vi . hoisted ( ( ) => ( {
88 getWorkspaceOwnerSubscriptionAccess : vi . fn ( ) ,
99 isCredentialGroupsAvailable : vi . fn ( ) ,
10+ isCredentialGroupsEnterprisePlanRequired : vi . fn ( ) ,
1011 listCredentials : vi . fn ( ) ,
1112 loadGroup : vi . fn ( ) ,
1213 loadWorkspace : vi . fn ( ) ,
@@ -19,6 +20,7 @@ vi.mock('@/lib/billing/core/workspace-access', () => ({
1920
2021vi . mock ( '@/lib/credential-groups/availability' , ( ) => ( {
2122 isCredentialGroupsAvailable : mocks . isCredentialGroupsAvailable ,
23+ isCredentialGroupsEnterprisePlanRequired : mocks . isCredentialGroupsEnterprisePlanRequired ,
2224} ) )
2325
2426vi . mock ( '@/lib/credential-groups/credentials' , ( ) => ( {
@@ -105,6 +107,7 @@ describe('listCredentialGroupCredentials', () => {
105107 mocks . resolvePermission . mockResolvedValue ( 'read' )
106108 mocks . getWorkspaceOwnerSubscriptionAccess . mockResolvedValue ( { isEnterprise : true } )
107109 mocks . isCredentialGroupsAvailable . mockResolvedValue ( true )
110+ mocks . isCredentialGroupsEnterprisePlanRequired . mockReturnValue ( false )
108111 mocks . listCredentials . mockResolvedValue ( {
109112 credentials : [
110113 {
@@ -230,6 +233,20 @@ describe('listCredentialGroupCredentials', () => {
230233 expect ( mocks . listCredentials ) . not . toHaveBeenCalled ( )
231234 } )
232235
236+ it ( 'identifies the Enterprise requirement for unavailable hosted workspaces' , async ( ) => {
237+ mocks . getWorkspaceOwnerSubscriptionAccess . mockResolvedValue ( { isEnterprise : false } )
238+ mocks . isCredentialGroupsAvailable . mockResolvedValue ( false )
239+ mocks . isCredentialGroupsEnterprisePlanRequired . mockReturnValue ( true )
240+
241+ await expect (
242+ listCredentialGroupCredentials . execute ( { principal : executorPrincipal ( ) , input } )
243+ ) . rejects . toMatchObject ( {
244+ code : 'forbidden' ,
245+ message : 'Credential Groups are not available. Enterprise plan required.' ,
246+ } )
247+ expect ( mocks . listCredentials ) . not . toHaveBeenCalled ( )
248+ } )
249+
233250 it ( 'rejects limits outside the bounded page size' , async ( ) => {
234251 await expect (
235252 listCredentialGroupCredentials . execute ( {
0 commit comments