Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(announcements): directive update handling of nonexistent feature flags #27709

Merged
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ describe('DotPropertiesService', () => {
const apiResponse = {
entity: {
[FeaturedFlags.DOTFAVORITEPAGE_FEATURE_ENABLE]: 'true',
[FeaturedFlags.FEATURE_FLAG_EDIT_URL_CONTENT_MAP]: 'NOT_FOUND'
[FeaturedFlags.FEATURE_FLAG_EDIT_URL_CONTENT_MAP]: FEATURE_FLAG_NOT_FOUND
}
};

Expand All @@ -112,6 +112,23 @@ describe('DotPropertiesService', () => {
req.flush(apiResponse);
});

it('should get feature flag value as true when not found', (done) => {
const featureFlag = FeaturedFlags.FEATURE_FLAG_ANNOUNCEMENTS;
const apiResponse = {
entity: {
[FeaturedFlags.FEATURE_FLAG_ANNOUNCEMENTS]: 'NOT_FOUND'
manuelrojas marked this conversation as resolved.
Show resolved Hide resolved
}
};

service.getFeatureFlag(featureFlag).subscribe((response) => {
expect(response).toEqual(true);
done();
});
const req = httpMock.expectOne(`/api/v1/configuration/config?keys=${featureFlag}`);
expect(req.request.method).toBe('GET');
req.flush(apiResponse);
});

afterEach(() => {
httpMock.verify();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Injectable } from '@angular/core';

import { map, pluck, take } from 'rxjs/operators';

import { FeaturedFlags } from '@dotcms/dotcms-models';
import { FEATURE_FLAG_NOT_FOUND, FeaturedFlags } from '@dotcms/dotcms-models';

@Injectable({
providedIn: 'root'
Expand Down Expand Up @@ -57,13 +57,14 @@ export class DotPropertiesService {

/**
* Get the value of specific feature flag
*
* @param {FeaturedFlags} key
* @return {*} {Observable<boolean>}
* @memberof DotPropertiesService
*/
getFeatureFlag(key: FeaturedFlags): Observable<boolean> {
return this.getKey(key).pipe(map((value) => value === 'true'));
return this.getKey(key).pipe(
map((value) => (value === FEATURE_FLAG_NOT_FOUND ? true : value === 'true'))
zJaaal marked this conversation as resolved.
Show resolved Hide resolved
);
}

/**
Expand Down
Loading