Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions sdks/js/node-sdk/test/Preferences.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,14 +246,25 @@ describe("Preferences", () => {
await client2.conversations.syncAll();
await sleep(1000);

setTimeout(() => {
const preferences: UserPreferenceUpdate[] = [];

// Safety net: end the stream if the expected updates never arrive, so the
// assertion below fails clearly instead of the test hanging until timeout.
// The HmacKeyUpdate events depend on network propagation, so we collect
// until we have all 4 expected updates rather than ending on a fixed timer.
const endTimeout = setTimeout(() => {
void stream.end();
}, 100);
}, 10000);

const preferences: UserPreferenceUpdate[] = [];
for await (const update of stream) {
preferences.push(...update);
if (preferences.length >= 4) {
break;
}
}
clearTimeout(endTimeout);
await stream.end();

expect(preferences.length).toBe(4);
const consentUpdate1 = preferences[0] as Extract<
UserPreferenceUpdate,
Expand Down
Loading