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>
This commit is contained in:
Michaela
2025-10-16 06:29:26 +02:00
committed by GitHub
co-authored by Copilot
parent cef71a2d71
commit dfc65ae45c
2 changed files with 9 additions and 5 deletions
@@ -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
@@ -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<T>(options: serviceOptions): Observable<FetchResult<T>> {
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);