Skip to content

Commit f1c6001

Browse files
committed
Update test-harness to v2.15.0
Signed-off-by: marcozabel <[email protected]>
1 parent 50512ab commit f1c6001

File tree

5 files changed

+41
-12
lines changed

5 files changed

+41
-12
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export const EVENTS_FEATURE = getGherkinTestPath('events.feature');
1212
export const METADATA_FEATURE = getGherkinTestPath('metadata.feature');
1313
export const RPC_CACHING_FEATURE = getGherkinTestPath('rpc-caching.feature');
1414
export const SELECTOR_FEATURE = getGherkinTestPath('selector.feature');
15+
export const SYNC_PAYLOAD_FEATURE = getGherkinTestPath('sync-payload.feature');
1516
export const TARGETING_FEATURE = getGherkinTestPath('targeting.feature');
1617
export const GHERKIN_EVALUATION_FEATURE = getGherkinTestPath(
1718
'evaluation.feature',

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

Lines changed: 36 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { ProviderStatus } from '@openfeature/server-sdk';
12
import { OpenFeature } from '@openfeature/server-sdk';
23
import { FlagdContainer } from '../tests/flagdContainer';
34
import type { State, Steps } from './state';
@@ -6,7 +7,7 @@ import type { FlagdProviderOptions } from '../../lib/configuration';
67

78
export const providerSteps: Steps =
89
(state: State) =>
9-
({ given, when, then }) => {
10+
({ given, when, then, and }) => {
1011
const container: FlagdContainer = FlagdContainer.build();
1112
beforeAll(async () => {
1213
console.log('Setting flagd provider...');
@@ -33,26 +34,29 @@ export const providerSteps: Steps =
3334
const flagdOptions: FlagdProviderOptions = {
3435
resolverType: state.resolverType,
3536
deadlineMs: 2000,
37+
...state.config,
38+
...state.options,
3639
};
40+
3741
let type = 'default';
3842
switch (providerType) {
39-
default:
40-
flagdOptions['port'] = container.getPort(state.resolverType);
41-
if (state?.options?.['selector']) {
42-
flagdOptions['selector'] = state?.options?.['selector'] as string;
43-
}
44-
break;
4543
case 'unavailable':
4644
flagdOptions['port'] = 9999;
4745
break;
4846
case 'ssl':
4947
// TODO: modify this to support ssl
5048
flagdOptions['port'] = container.getPort(state.resolverType);
51-
if (state?.config?.selector) {
52-
flagdOptions['selector'] = state.config.selector;
53-
}
5449
type = 'ssl';
5550
break;
51+
case 'stable':
52+
flagdOptions['port'] = container.getPort(state.resolverType);
53+
break;
54+
case 'syncpayload':
55+
flagdOptions['port'] = container.getPort(state.resolverType);
56+
type = 'sync-payload';
57+
break;
58+
default:
59+
throw new Error('unknown provider type: ' + providerType);
5660
}
5761

5862
await fetch('http://' + container.getLaunchpadUrl() + '/start?config=' + type);
@@ -75,4 +79,26 @@ export const providerSteps: Steps =
7579
when('the flag was modified', async () => {
7680
await fetch('http://' + container.getLaunchpadUrl() + '/change');
7781
});
82+
83+
function mapProviderState(state: string): ProviderStatus {
84+
switch (state) {
85+
case 'fatal':
86+
return ProviderStatus.FATAL;
87+
case 'error':
88+
return ProviderStatus.ERROR;
89+
case 'ready':
90+
return ProviderStatus.READY;
91+
case 'stale':
92+
return ProviderStatus.STALE;
93+
case 'not-ready':
94+
return ProviderStatus.NOT_READY;
95+
96+
default:
97+
throw new Error('Unknown provider status');
98+
}
99+
}
100+
101+
and(/^the client should be in (.*) state/, (providerState: string) => {
102+
expect(state.client?.providerStatus).toBe(mapProviderState(providerState));
103+
});
78104
};

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ export function mapValueToType(value: string, type: string): any {
1919
return value.toLowerCase() as ResolverType;
2020
case 'CacheType':
2121
return value as CacheOption;
22+
case 'StringList':
23+
return value.split(',').map((item) => item.trim());
2224
case 'Object':
2325
if (value == 'null') {
2426
return undefined;

libs/providers/flagd/src/e2e/tests/in-process.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ describe('in-process', () => {
2222
// remove filters as we add support for features
2323
// see: https://github.com/open-feature/js-sdk-contrib/issues/1096 and child issues
2424
tagFilter:
25-
'@in-process and not @targetURI and not @customCert and not @events and not @sync and not @grace and not @metadata and not @contextEnrichment',
25+
'@in-process and not @targetURI and not @forbidden and not @customCert and not @events and not @sync and not @grace and not @metadata and not @unixsocket',
2626
scenarioNameTemplate: (vars) => {
2727
return `${vars.scenarioTitle} (${vars.scenarioTags.join(',')} ${vars.featureTags.join(',')})`;
2828
},

0 commit comments

Comments
 (0)