Skip to content

Commit 049df44

Browse files
authored
Merge branch 'main' into feat/add-certpath-support-158
2 parents 9d8f981 + 1bccd11 commit 049df44

File tree

3 files changed

+33
-0
lines changed

3 files changed

+33
-0
lines changed

libs/providers/flagd/src/e2e/constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ export const UNSTABLE_CLIENT_NAME = 'unstable';
44
export const UNAVAILABLE_CLIENT_NAME = 'unavailable';
55

66
export const GHERKIN_FLAGD = getGherkinTestPath('*.feature');
7+
export const CONFIG_FEATURE = getGherkinTestPath('config.feature');

libs/providers/flagd/src/e2e/step-definitions/configSteps.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,19 @@ export const configSteps: Steps = (state: State) => {
1313
}
1414
}
1515

16+
const originalEnv = { ...process.env };
17+
1618
return ({ given, when, then }: StepsDefinitionCallbackOptions) => {
1719
beforeEach(() => {
1820
state.options = {};
21+
state.config = undefined;
22+
state.events = [];
23+
Object.keys(process.env)
24+
.filter((key) => !Object.prototype.hasOwnProperty.call(originalEnv, key))
25+
.forEach((key) => delete process.env[key]);
26+
Object.assign(process.env, originalEnv);
1927
});
28+
2029
given(/^an option "(.*)" of type "(.*)" with value "(.*)"$/, (name: string, type: string, value: string) => {
2130
state.options[mapName(name)] = mapValueToType(value, type);
2231
});

libs/providers/flagd/src/lib/configuration.spec.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ import type { Config, FlagdProviderOptions } from './configuration';
22
import { getConfig } from './configuration';
33
import { DEFAULT_MAX_CACHE_SIZE } from './constants';
44
import type { EvaluationContext } from '@openfeature/server-sdk';
5+
import { configSteps } from '../e2e/step-definitions/configSteps';
6+
import type { State } from '../e2e/step-definitions/state';
7+
import { autoBindSteps, loadFeatures } from 'jest-cucumber';
8+
import { CONFIG_FEATURE } from '../e2e';
59

610
describe('Configuration', () => {
711
const OLD_ENV = process.env;
@@ -168,4 +172,23 @@ describe('Configuration', () => {
168172
});
169173
});
170174
});
175+
176+
describe('config.feature', () => {
177+
const state: State = {
178+
resolverType: 'in-process',
179+
options: {},
180+
config: undefined,
181+
events: [],
182+
};
183+
184+
autoBindSteps(
185+
loadFeatures(CONFIG_FEATURE, {
186+
scenarioNameTemplate: (vars) => {
187+
const tags = [...new Set([...vars.scenarioTags, ...vars.featureTags])];
188+
return `${vars.scenarioTitle}${tags.length > 0 ? ` (${tags.join(', ')})` : ''}`;
189+
},
190+
}),
191+
[configSteps(state)],
192+
);
193+
});
171194
});

0 commit comments

Comments
 (0)