Skip to content

Commit

Permalink
AAE-20808 Refactoring WS service to filter unwanted results
Browse files Browse the repository at this point in the history
  • Loading branch information
ehsan-2019 committed Dec 4, 2024
1 parent ffdfbe7 commit 60c0803
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ describe('WebSocketService', () => {
});
service = TestBed.inject(WebSocketService);
featureService = TestBed.inject(FeaturesServiceToken);
spyOn(featureService, 'isOn$').and.returnValue(of(true));
apolloMock.use.and.returnValues(undefined, { subscribe: () => of({}) });
});

Expand Down Expand Up @@ -115,7 +114,7 @@ describe('WebSocketService', () => {
});

it('should create named client with the right authentication token when FF is off', (done) => {
featureService.isOn$ = jasmine.createSpy().and.returnValue(of(false));
featureService.getFlags$ = jasmine.createSpy().and.returnValue(of({ 'studio-ws-graphql-subprotocol': { current: false } }));
let headers = {};
const expectedHeaders = { 'X-Authorization': 'Bearer testToken' };
const apolloClientName = 'testClient';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import { Apollo } from 'apollo-angular';
import { onError } from '@apollo/client/link/error';
import { RetryLink } from '@apollo/client/link/retry';
import { Observable } from 'rxjs';
import { switchMap, take, tap } from 'rxjs/operators';
import { filter, map, switchMap, take, tap } from 'rxjs/operators';
import { FeaturesServiceToken, IFeaturesService } from '@alfresco/adf-core/feature-flags';
import { AuthenticationService, AppConfigService } from '@alfresco/adf-core';

Expand Down Expand Up @@ -74,7 +74,9 @@ export class WebSocketService {
}
});

return this.featuresService.isOn$('studio-ws-graphql-subprotocol').pipe(
return this.featuresService.getFlags$().pipe(
filter((flags) => Object.keys(flags).length > 0),
map((flags) => !!flags['studio-ws-graphql-subprotocol'].current),
tap((isOn) => {
if (isOn) {
this.subscriptionProtocol = 'graphql-ws';
Expand Down

0 comments on commit 60c0803

Please sign in to comment.