hunk.code_window:     const name = 'topic-name';
       const topicId = 'topic-id';
       const pageSize = 20;
       const mockedResponse = {
         totalCount: 1,
         pageSize,
         page: 0,
         data: [
           {
             _id: 'topic-id',
             _environmentId: 'environment-id',
             _organizationId: 'organization-id',
             key,
             name,
             subscribers: ['subscriber-id-1', 'subscriber-id-2'],
           },
         ],
       };
       mockedAxios.get.mockResolvedValue(mockedResponse);
       const result = await novu.topics.list({ page: 0, pageSize });
  
hunk.labels: keep keep keep keep keep replace replace replace replace replace replace replace replace replace replace replace replace replace keep keep keep keep
hunk.after_edit:       data: {
           totalCount: 1,
           pageSize,
           page: 0,
           data: [
             {
               _id: 'topic-id',
               _environmentId: 'environment-id',
               _organizationId: 'organization-id',
               key,
               name,
               subscribers: ['subscriber-id-1', 'subscriber-id-2'],
             },
           ],
         },
  
hunk.file_path: packages/node/src/lib/topics/topics.spec.ts
hunk.type: replace
file: import { Inject, Injectable } from '@nestjs/common';
  import { IntegrationEntity, IntegrationRepository, DalException } from '@novu/dal';
  import { ChannelTypeEnum } from '@novu/shared';
  import { AnalyticsService } from '@novu/application-generic';
  
  import { CreateIntegrationCommand } from './create-integration.command';
  import { ApiException } from '../../../shared/exceptions/api.exception';
  import { DeactivateSimilarChannelIntegrations } from '../deactivate-integration/deactivate-integration.usecase';
  import { encryptCredentials } from '../../../shared/services/encryption';
  import { CheckIntegrationCommand } from '../check-integration/check-integration.command';
  import { CheckIntegration } from '../check-integration/check-integration.usecase';
  import { ANALYTICS_SERVICE } from '../../../shared/shared.module';
  import { CacheKeyPrefixEnum, InvalidateCacheService } from '../../../shared/services/cache';
  @Injectable()
  export class CreateIntegration {
    @Inject()
    private checkIntegration: CheckIntegration;
    constructor(
      private invalidateCache: InvalidateCacheService,
      private integrationRepository: IntegrationRepository,
      private deactivateSimilarChannelIntegrations: DeactivateSimilarChannelIntegrations,
      @Inject(ANALYTICS_SERVICE) private analyticsService: AnalyticsService
    ) {}
  
    async execute(command: CreateIntegrationCommand): Promise<IntegrationEntity> {
      let response: IntegrationEntity;
  
      this.analyticsService.track('Create Integration - [Integrations]', command.userId, {
        providerId: command.providerId,
        channel: command.channel,
        _organization: command.organizationId,
      });
  
      try {
        if (command.check) {
          await this.checkIntegration.execute(
            CheckIntegrationCommand.create({
              environmentId: command.environmentId,
              organizationId: command.organizationId,
              providerId: command.providerId,
              channel: command.channel,
              credentials: command.credentials,
            })
          );
        }
  
        await this.invalidateCache.clearCache({
          storeKeyPrefix: [CacheKeyPrefixEnum.INTEGRATION],
          credentials: {
            environmentId: command.environmentId,
          },
        });
  
        response = await this.integrationRepository.create({
          _environmentId: command.environmentId,
          _organizationId: command.organizationId,
          providerId: command.providerId,
          channel: command.channel,
          credentials: encryptCredentials(command.credentials),
          active: command.active,
        });
  
        if (command.active && ![ChannelTypeEnum.CHAT, ChannelTypeEnum.PUSH].includes(command.channel)) {
          await this.deactivateSimilarChannelIntegrations.execute({
            environmentId: command.environmentId,
            organizationId: command.organizationId,
            integrationId: response._id,
            channel: command.channel,
          });
        }
      } catch (e) {
        if (e instanceof DalException) {
          throw new ApiException(e.message);
        }
        throw e;
      }
  
      return response;
    }
  }
  