From dfc65ae45c348fbb20765be54da1267bfedadd8f Mon Sep 17 00:00:00 2001 From: Michaela <85624192+mkrbr@users.noreply.github.com> Date: Thu, 16 Oct 2025 06:29:26 +0200 Subject: [PATCH] AAE-38919 There is no deployment update without closing the panel (#11263) * Fixes WebSocket client re-initialization. Ensures proper handling of WebSocket client re-initialization by creating a unique client for each user session and token refresh, and removing the client on logout. Addresses issues with deployment updates not being received due to incorrect client handling. This change ensures that the WebSocket connection is properly re-established when the user logs in again and when tokens are refreshed. * reverts changes * Removes HttpClientTestingModule import Replaces the `HttpClientTestingModule` import with `provideHttpClientTesting` to align with Angular's updated testing practices. This change ensures compatibility and avoids potential issues related to the deprecated module. Fixes AAE-38919 * revert more changes * Update lib/process-services-cloud/src/lib/services/web-socket.service.spec.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .../src/lib/services/web-socket.service.spec.ts | 4 ++-- .../src/lib/services/web-socket.service.ts | 10 +++++++--- 2 files changed, 9 insertions(+), 5 deletions(-) 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);