mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2026-09-09 18:03:21 +00:00
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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user