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

Call the correct API to determine if a user is in treatment or control group #20690

Merged
merged 2 commits into from
Feb 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions .github/workflows/pr-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -266,15 +266,6 @@ jobs:
working-directory: ${{ env.special-working-directory }}
if: matrix.test-suite == 'single-workspace'

- name: Run multi-workspace tests
env:
CI_PYTHON_VERSION: ${{ matrix.python }}
uses: GabrielBB/xvfb-action@v1.6
with:
run: npm run testMultiWorkspace
working-directory: ${{ env.special-working-directory }}
if: matrix.test-suite == 'multi-workspace'

- name: Run debugger tests
env:
CI_PYTHON_VERSION: ${{ matrix.python }}
Expand Down
2 changes: 1 addition & 1 deletion src/client/common/experiments/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ export class ExperimentService implements IExperimentService {
// it means that the value for this experiment was not found on the server.
const treatmentVariable = this.experimentationService.getTreatmentVariable(EXP_CONFIG_ID, experiment);

return treatmentVariable !== undefined;
return treatmentVariable === true;
}

public async getExperimentValue<T extends boolean | number | string>(experiment: string): Promise<T | undefined> {
Expand Down
33 changes: 32 additions & 1 deletion src/test/common/experiments/service.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ suite('Experimentation service', () => {
telemetryEvents.push(telemetry);
});

getTreatmentVariable = sinon.stub().returns(Promise.resolve(true));
getTreatmentVariable = sinon.stub().returns(true);
sinon.stub(tasClient, 'getExperimentationService').returns(({
getTreatmentVariable,
} as unknown) as tasClient.IExperimentationService);
Expand Down Expand Up @@ -205,6 +205,37 @@ suite('Experimentation service', () => {
sinon.assert.calledOnce(getTreatmentVariable);
});

test('If in control group, return false', async () => {
sinon.restore();
sendTelemetryEventStub = sinon
.stub(Telemetry, 'sendTelemetryEvent')
.callsFake((eventName: string, _, properties: unknown) => {
const telemetry = { eventName, properties };
telemetryEvents.push(telemetry);
});

// Control group returns false.
getTreatmentVariable = sinon.stub().returns(false);
sinon.stub(tasClient, 'getExperimentationService').returns(({
getTreatmentVariable,
} as unknown) as tasClient.IExperimentationService);

configureApplicationEnvironment('stable', extensionVersion);

configureSettings(true, [], []);

const experimentService = new ExperimentService(
instance(workspaceService),
instance(appEnvironment),
instance(stateFactory),
);
const result = experimentService.inExperimentSync(experiment);

assert.isFalse(result);
sinon.assert.notCalled(sendTelemetryEventStub);
sinon.assert.calledOnce(getTreatmentVariable);
});

test('If the experiment setting is disabled, inExperiment should return false', async () => {
configureSettings(false, [], []);

Expand Down