Skip to content

Commit e7f8499

Browse files
committed
test: fix
1 parent 8293c42 commit e7f8499

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

packages/browser-sdk/src/flag/flags.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,7 @@ export class FlagsClient {
289289
async initialize() {
290290
if (this.initialized) {
291291
this.logger.error("flags client already initialized");
292+
return;
292293
}
293294
this.setFetchedFlags((await this.maybeFetchFlags()) || {});
294295
this.initialized = true;

packages/browser-sdk/test/flags.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ describe("FlagsClient", () => {
108108
expect(testLogger.warn).toHaveBeenCalledTimes(1);
109109
vi.advanceTimersByTime(60 * 1000);
110110
await flagsClient.initialize();
111-
expect(testLogger.warn).toHaveBeenCalledTimes(2);
111+
expect(testLogger.error).toHaveBeenCalledTimes(1);
112112
});
113113

114114
test("ignores undefined context", async () => {
@@ -508,14 +508,14 @@ describe("FlagsClient", () => {
508508
updateTriggered = true;
509509
});
510510

511-
// Trigger the flags updated event by setting context (which should not fetch since already initialized)
511+
// Trigger the flags updated event by setting context (which should still fetch)
512512
await flagsClient.setContext({
513513
user: { id: "456" },
514514
company: { id: "789" },
515515
other: { eventId: "other-conference" },
516516
});
517517

518-
expect(updateTriggered).toBe(false); // No update since context change doesn't affect pre-fetched flags
518+
expect(updateTriggered).toBe(true);
519519
});
520520

521521
test("should work with fallback flags when initialization fails", async () => {

0 commit comments

Comments
 (0)