diff --git a/lib/process-services-cloud/src/lib/services/web-socket.service.spec.ts b/lib/process-services-cloud/src/lib/services/web-socket.service.spec.ts index b89a0f629a..7164ab3922 100644 --- a/lib/process-services-cloud/src/lib/services/web-socket.service.spec.ts +++ b/lib/process-services-cloud/src/lib/services/web-socket.service.spec.ts @@ -20,7 +20,7 @@ import { Apollo, gql } from 'apollo-angular'; import { lastValueFrom, of, Subject } from 'rxjs'; import { WebSocketService } from './web-socket.service'; import { SubscriptionOptions } from '@apollo/client/core'; -import { HttpClientTestingModule } from '@angular/common/http/testing'; +import { provideHttpClientTesting } from '@angular/common/http/testing'; import { AuthenticationService, AppConfigService } from '@alfresco/adf-core'; describe('WebSocketService', () => { @@ -31,8 +31,8 @@ describe('WebSocketService', () => { beforeEach(() => { TestBed.configureTestingModule({ - imports: [HttpClientTestingModule], providers: [ + provideHttpClientTesting(), { provide: Apollo, useValue: apolloMock diff --git a/lib/process-services-cloud/src/lib/services/web-socket.service.ts b/lib/process-services-cloud/src/lib/services/web-socket.service.ts index f84ac9ef5f..f7c01282de 100644 --- a/lib/process-services-cloud/src/lib/services/web-socket.service.ts +++ b/lib/process-services-cloud/src/lib/services/web-socket.service.ts @@ -56,7 +56,11 @@ export class WebSocketService { private wsLink: GraphQLWsLink | WebSocketLink; private httpLinkHandler: HttpLinkHandler; - constructor(private readonly apollo: Apollo, private readonly httpLink: HttpLink, private readonly authService: AuthenticationService) {} + constructor( + private readonly apollo: Apollo, + private readonly httpLink: HttpLink, + private readonly authService: AuthenticationService + ) {} public getSubscription(options: serviceOptions): Observable> { const { apolloClientName, subscriptionOptions } = options; @@ -155,9 +159,9 @@ export class WebSocketService { this.wsLink = new GraphQLWsLink( createClient({ url: this.createWsUrl(options.wsUrl) + '/v2/ws/graphql', - connectionParams: { + connectionParams: () => ({ Authorization: 'Bearer ' + this.authService.getToken() - }, + }), on: { error: () => { this.apollo.removeClient(options.apolloClientName);