Skip to content

Commit

Permalink
Allow opting into specific feature flags (#2931)
Browse files Browse the repository at this point in the history
### Motivation

In the implementation of feature flags, I forgot to check if the user opted into a specific flag. Currently, the code doesn't check for that, which means you can only opt into all of them.

### Implementation

We just need to check if the user opted into that specific flag.

### Automated Tests

Added a test.
  • Loading branch information
vinistock authored Nov 28, 2024
1 parent ce50f49 commit dc805d9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion vscode/src/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ export function featureEnabled(feature: keyof typeof FEATURE_FLAGS): boolean {
}

// If the user opted-in to all features, return true
if (flagConfiguration.all) {
if (flagConfiguration.all || flagConfiguration[feature]) {
return true;
}

Expand Down
14 changes: 14 additions & 0 deletions vscode/src/test/suite/common.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,18 @@ suite("Common", () => {
stub.restore();
assert.strictEqual(result, true);
});

test("returns true if user opted in to a specific feature", () => {
(FEATURE_FLAGS as any).fakeFeature = 0.02;

const stub = sandbox.stub(vscode.workspace, "getConfiguration").returns({
get: () => {
return { fakeFeature: true };
},
} as any);

const result = featureEnabled("fakeFeature" as any);
stub.restore();
assert.strictEqual(result, true);
});
});

0 comments on commit dc805d9

Please sign in to comment.