11import { RequestContext } from '../openmfp-request-context-provider.js' ;
22import { ContentConfigurationServiceProvidersService } from './content-configuration-service-providers.service.js' ;
3+ import { welcomeNodeConfig } from './models/welcome-node-config.js' ;
4+ import { EnvService } from '@openmfp/portal-server-lib' ;
35import { GraphQLClient } from 'graphql-request' ;
6+ import { mock } from 'jest-mock-extended' ;
47
58jest . mock ( 'graphql-request' , ( ) => {
69 return {
@@ -16,10 +19,13 @@ jest.mock('graphql-request', () => {
1619describe ( 'ContentConfigurationServiceProvidersService' , ( ) => {
1720 let service : ContentConfigurationServiceProvidersService ;
1821 let mockClient : jest . Mocked < GraphQLClient > ;
22+ let mockEnvService : jest . Mocked < EnvService > ;
1923 let context : RequestContext ;
2024
2125 beforeEach ( ( ) => {
22- service = new ContentConfigurationServiceProvidersService ( ) ;
26+ mockEnvService = mock ( ) ;
27+ mockEnvService . getEnv . mockReturnValue ( { isLocal : false } ) ;
28+ service = new ContentConfigurationServiceProvidersService ( mockEnvService ) ;
2329 mockClient = new GraphQLClient ( '' ) as any ;
2430 ( GraphQLClient as jest . Mock ) . mockReturnValue ( mockClient ) ;
2531 context = {
@@ -44,6 +50,17 @@ describe('ContentConfigurationServiceProvidersService', () => {
4450 ) . rejects . toThrow ( 'Context with organization is required' ) ;
4551 } ) ;
4652
53+ it ( 'throws if context organization is missing' , async ( ) => {
54+ context . isSubDomain = false ;
55+ const result = await service . getServiceProviders (
56+ 'token' ,
57+ [ 'entity' ] ,
58+ context ,
59+ ) ;
60+
61+ expect ( result ) . toEqual ( welcomeNodeConfig ) ;
62+ } ) ;
63+
4764 it ( 'returns parsed content configurations' , async ( ) => {
4865 mockClient . request . mockResolvedValue ( {
4966 ui_platform_mesh_io : {
0 commit comments