Skip to content

Commit

Permalink
Do not check for globallyEnabled on Feature Flags
Browse files Browse the repository at this point in the history
This is something that was also different after the actual
implementation of the Feature Flag endpoint. Previously we may have
expected some disabled flags would still show up in the response but
with a `globallyEnabled` flag set to false. The current endpoint just
gives us a list of enabled flags.
  • Loading branch information
meisekimiu committed Dec 9, 2024
1 parent 2f56fa8 commit 44bd887
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,7 @@ describe('FeatureFlagApiService', () => {

it('can fetch feature flags from the back end', (done) => {
const expectedFlags = {
items: [
{ name: 'potato', globallyEnabled: true },
{ name: 'tomato', globallyEnabled: true },
],
items: [{ name: 'potato' }, { name: 'tomato' }],
};

service
Expand Down
7 changes: 2 additions & 5 deletions src/app/feature-flag/services/feature-flag.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,11 @@ describe('FeatureFlagService', () => {
});

it('should fetch from the API on init', async () => {
mockApi.flags = [
{ name: 'api0', globallyEnabled: true },
{ name: 'api1', globallyEnabled: false },
];
mockApi.flags = [{ name: 'api0', globallyEnabled: true }, { name: 'api1' }];
await service.fetchFromApi();

expect(service.isEnabled('api0')).toBeTrue();
expect(service.isEnabled('api1')).toBeFalse();
expect(service.isEnabled('api1')).toBeTrue();
});

it('should fetch from Secrets on local environment', async () => {
Expand Down
2 changes: 1 addition & 1 deletion src/app/feature-flag/services/feature-flag.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export class FeatureFlagService {
public async fetchFromApi(): Promise<void> {
try {
const flags = await this.api.getFeatureFlags();
flags.forEach((flag) => this.set(flag.name, flag.globallyEnabled));
flags.forEach((flag) => this.set(flag.name, true));
} catch {
// Do nothing
}
Expand Down
2 changes: 1 addition & 1 deletion src/app/feature-flag/types/feature-flag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

export interface FeatureFlag {
name: string;
globallyEnabled: boolean;
globallyEnabled?: boolean;
}

0 comments on commit 44bd887

Please sign in to comment.