From b92267ac299875c4dae4486f06a9f12804a7906c Mon Sep 17 00:00:00 2001 From: Simon Schrottner Date: Wed, 6 Nov 2024 18:12:21 +0100 Subject: [PATCH] fixup: pr changes Signed-off-by: Simon Schrottner --- .../src/e2e/step-definitions/flag.ts | 37 +++++++++---------- .../flagd/src/e2e/step-definitions/flag.ts | 26 ++++++------- 2 files changed, 29 insertions(+), 34 deletions(-) diff --git a/libs/providers/flagd-web/src/e2e/step-definitions/flag.ts b/libs/providers/flagd-web/src/e2e/step-definitions/flag.ts index 1b3e9b2ab..fa76df59e 100644 --- a/libs/providers/flagd-web/src/e2e/step-definitions/flag.ts +++ b/libs/providers/flagd-web/src/e2e/step-definitions/flag.ts @@ -255,12 +255,10 @@ export const flagStepDefinitions: StepDefinitions = ({ given, and, when, then }) }, ); - let ran: Promise; + let ran: boolean; when('a PROVIDER_READY handler is added', () => { - ran = new Promise((resolve) => { - client.addHandler(ProviderEvents.Ready, async () => { - resolve(true); - }); + client.addHandler(ProviderEvents.Ready, async () => { + ran = true; }); }); then('the PROVIDER_READY handler must run', () => { @@ -268,18 +266,19 @@ export const flagStepDefinitions: StepDefinitions = ({ given, and, when, then }) }); when('a PROVIDER_CONFIGURATION_CHANGED handler is added', () => { - ran = new Promise((resolve) => { - client.addHandler(ProviderEvents.ConfigurationChanged, async (details) => { - // file writes are not atomic, so we get a few events in quick succession from the testbed - // some will not contain changes, this tolerates that; at least 1 should have our change - - // All Flags are changed we do not provide a list of changed flags, that is the nature of the web sdk - //if (details?.flagsChanged?.length) { - // flagsChanged = details?.flagsChanged; - - resolve(true); - //} - }); + client.addHandler(ProviderEvents.ConfigurationChanged, async (details) => { + // file writes are not atomic, so we get a few events in quick succession from the testbed + // some will not contain changes, this tolerates that; at least 1 should have our change + + + // TODO: enable this for testing of issue + //if (details?.flagsChanged?.length) { + // flagsChanged = details?.flagsChanged; + // ran = true; + //} + + // TODO: remove this for testing of issue + ran = true; }); }); @@ -289,11 +288,11 @@ export const flagStepDefinitions: StepDefinitions = ({ given, and, when, then }) }); then('the PROVIDER_CONFIGURATION_CHANGED handler must run', async () => { - expect(await ran).toBeTruthy(); + expect(ran).toBeTruthy(); }); and(/^the event details must indicate "(.*)" was altered$/, (flagName) => { - // All Flags are changed we do not provide a list of changed flags, that is the nature of the web sdk + // TODO: enable this for testing of issue //expect(flagsChanged).toContain(flagName); }); diff --git a/libs/providers/flagd/src/e2e/step-definitions/flag.ts b/libs/providers/flagd/src/e2e/step-definitions/flag.ts index 29d28ea69..92e85da9b 100644 --- a/libs/providers/flagd/src/e2e/step-definitions/flag.ts +++ b/libs/providers/flagd/src/e2e/step-definitions/flag.ts @@ -284,12 +284,10 @@ export const flagStepDefinitions: StepDefinitions = ({ given, and, when, then }) }, ); - let ran: Promise; + let ran: boolean; when('a PROVIDER_READY handler is added', () => { - ran = new Promise((resolve) => { - client.addHandler(ProviderEvents.Ready, async () => { - resolve(true); - }); + client.addHandler(ProviderEvents.Ready, async () => { + ran = true; }); }); then('the PROVIDER_READY handler must run', () => { @@ -297,16 +295,14 @@ export const flagStepDefinitions: StepDefinitions = ({ given, and, when, then }) }); when('a PROVIDER_CONFIGURATION_CHANGED handler is added', () => { - ran = new Promise((resolve) => { - client.addHandler(ProviderEvents.ConfigurationChanged, async (details) => { - // file writes are not atomic, so we get a few events in quick succession from the testbed - // some will not contain changes, this tolerates that; at least 1 should have our change - if (details?.flagsChanged?.length) { - flagsChanged = details?.flagsChanged; - - resolve(true); - } - }); + client.addHandler(ProviderEvents.ConfigurationChanged, async (details) => { + // file writes are not atomic, so we get a few events in quick succession from the testbed + // some will not contain changes, this tolerates that; at least 1 should have our change + if (details?.flagsChanged?.length) { + flagsChanged = details?.flagsChanged; + + ran = true; + } }); });