2020import { act , render } from '@testing-library/react' ;
2121import { CONVERSATION_TYPE } from '@wireapp/api-client/lib/conversation' ;
2222import { CONVERSATION_PROTOCOL } from '@wireapp/api-client/lib/team' ;
23+ import { UserType } from '@wireapp/api-client/lib/user' ;
2324
2425import { CellsRepository } from 'Repositories/cells/cellsRepository' ;
2526import { ConnectionRepository } from 'Repositories/connection/connectionRepository' ;
@@ -29,6 +30,7 @@ import {MessageRepository} from 'Repositories/conversation/MessageRepository';
2930import { Conversation } from 'Repositories/entity/Conversation' ;
3031import { User } from 'Repositories/entity/User' ;
3132import { IntegrationRepository } from 'Repositories/integration/IntegrationRepository' ;
33+ import { ServiceEntity } from 'Repositories/integration/ServiceEntity' ;
3234import { SearchRepository } from 'Repositories/search/searchRepository' ;
3335import { SelfRepository } from 'Repositories/self/SelfRepository' ;
3436import { TeamEntity } from 'Repositories/team/TeamEntity' ;
@@ -39,16 +41,16 @@ import {
3941 createRootContextValueForTest ,
4042 createRootProviderWrapperForTest ,
4143} from 'src/script/page/testSupport/rootContextTestSupport' ;
42- import { translate } from 'Util/localizerUtil' ;
4344import 'src/script/util/test/mock/localStorageMock' ;
45+ import { translate } from 'Util/localizerUtil' ;
46+ import { translateForTest } from 'Util/test/translateForTest' ;
4447import { createUuid } from 'Util/uuid' ;
4548
4649import { ConversationDetails } from './conversationDetails' ;
4750
4851import { TestFactory } from '../../../../../test/helper/TestFactory' ;
4952import { ActionsViewModel } from '../../../view_model/ActionsViewModel' ;
5053import { MainViewModel } from '../../../view_model/MainViewModel' ;
51- import { translateForTest } from 'Util/test/translateForTest' ;
5254
5355jest . mock ( 'Components/panel/enrichedFields' , ( ) => ( {
5456 useEnrichedFields : ( ) : never [ ] => [ ] ,
@@ -120,6 +122,48 @@ const getDefaultParams = () => {
120122} ;
121123
122124describe ( 'ConversationDetails' , ( ) => {
125+ it . each ( [ CONVERSATION_PROTOCOL . PROTEUS , CONVERSATION_PROTOCOL . MIXED , CONVERSATION_PROTOCOL . MLS ] ) (
126+ 'shows legacy bots and apps in %s groups' ,
127+ protocol => {
128+ const conversation = new Conversation ( createUuid ( ) , '' , protocol , translateForTest ) ;
129+ const regularUser = new User ( 'regular-user' , '' , translateForTest ) ;
130+ const legacyBot = new User ( 'legacy-bot' , '' , translateForTest ) ;
131+ const app = new User ( 'app' , '' , translateForTest ) ;
132+
133+ regularUser . name ( 'Regular user' ) ;
134+ legacyBot . name ( 'Legacy bot' ) ;
135+ legacyBot . isService = true ;
136+ legacyBot . type = UserType . BOT ;
137+ app . name ( 'App' ) ;
138+ app . type = UserType . APP ;
139+ conversation . participating_user_ets ( [ regularUser , legacyBot , app ] ) ;
140+
141+ const defaultProps = getDefaultParams ( ) ;
142+ const integrationRepository = {
143+ ...defaultProps . integrationRepository ,
144+ mapServiceFromUser : ( user : User ) =>
145+ new ServiceEntity ( {
146+ id : user . id ,
147+ name : user . name ( ) ,
148+ qualifiedId : user . qualifiedId ,
149+ type : 'App' ,
150+ } ) ,
151+ } as IntegrationRepository ;
152+
153+ const { getByTestId} = render (
154+ < ConversationDetails
155+ { ...defaultProps }
156+ activeConversation = { conversation }
157+ integrationRepository = { integrationRepository }
158+ /> ,
159+ { wrapper : rootProviderWrapper } ,
160+ ) ;
161+
162+ expect ( getByTestId ( `service-list-service-${ legacyBot . id } ` ) ) . not . toBeNull ( ) ;
163+ expect ( getByTestId ( `service-list-service-${ app . id } ` ) ) . not . toBeNull ( ) ;
164+ } ,
165+ ) ;
166+
123167 it ( "returns the right actions depending on the conversation's type for non group creators" , ( ) => {
124168 const conversation = new Conversation ( '' , '' , CONVERSATION_PROTOCOL . PROTEUS , translateForTest ) ;
125169 const otherUser = new User ( 'other-user' , '' , translateForTest ) ;
0 commit comments