Skip to content

Commit

Permalink
fixup: pr changes
Browse files Browse the repository at this point in the history
Signed-off-by: Simon Schrottner <[email protected]>
  • Loading branch information
aepfli committed Nov 6, 2024
1 parent f0b1dd1 commit b92267a
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 34 deletions.
37 changes: 18 additions & 19 deletions libs/providers/flagd-web/src/e2e/step-definitions/flag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -255,31 +255,30 @@ export const flagStepDefinitions: StepDefinitions = ({ given, and, when, then })
},
);

let ran: Promise<boolean>;
let ran: boolean;
when('a PROVIDER_READY handler is added', () => {
ran = new Promise<boolean>((resolve) => {
client.addHandler(ProviderEvents.Ready, async () => {
resolve(true);
});
client.addHandler(ProviderEvents.Ready, async () => {
ran = true;
});
});
then('the PROVIDER_READY handler must run', () => {
expect(ran).toBeTruthy();
});

when('a PROVIDER_CONFIGURATION_CHANGED handler is added', () => {
ran = new Promise<boolean>((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) => {

Check warning on line 269 in libs/providers/flagd-web/src/e2e/step-definitions/flag.ts

View workflow job for this annotation

GitHub Actions / lint-test-build (18.x)

'details' is defined but never used

Check warning on line 269 in libs/providers/flagd-web/src/e2e/step-definitions/flag.ts

View workflow job for this annotation

GitHub Actions / lint-test-build (20.x)

'details' is defined but never used
// 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


Check failure on line 273 in libs/providers/flagd-web/src/e2e/step-definitions/flag.ts

View workflow job for this annotation

GitHub Actions / lint-test-build (18.x)

Delete `⏎`

Check failure on line 273 in libs/providers/flagd-web/src/e2e/step-definitions/flag.ts

View workflow job for this annotation

GitHub Actions / lint-test-build (20.x)

Delete `⏎`
// 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;
});
});

Expand All @@ -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) => {

Check warning on line 294 in libs/providers/flagd-web/src/e2e/step-definitions/flag.ts

View workflow job for this annotation

GitHub Actions / lint-test-build (18.x)

'flagName' is defined but never used

Check warning on line 294 in libs/providers/flagd-web/src/e2e/step-definitions/flag.ts

View workflow job for this annotation

GitHub Actions / lint-test-build (20.x)

'flagName' is defined but never used
// 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);
});

Expand Down
26 changes: 11 additions & 15 deletions libs/providers/flagd/src/e2e/step-definitions/flag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -284,29 +284,25 @@ export const flagStepDefinitions: StepDefinitions = ({ given, and, when, then })
},
);

let ran: Promise<boolean>;
let ran: boolean;
when('a PROVIDER_READY handler is added', () => {
ran = new Promise<boolean>((resolve) => {
client.addHandler(ProviderEvents.Ready, async () => {
resolve(true);
});
client.addHandler(ProviderEvents.Ready, async () => {
ran = true;
});
});
then('the PROVIDER_READY handler must run', () => {
expect(ran).toBeTruthy();
});

when('a PROVIDER_CONFIGURATION_CHANGED handler is added', () => {
ran = new Promise<boolean>((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;
}
});
});

Expand Down

0 comments on commit b92267a

Please sign in to comment.