diff --git a/example/src/tests/groupTests.ts b/example/src/tests/groupTests.ts index 2689e70d3..5fa6a34ba 100644 --- a/example/src/tests/groupTests.ts +++ b/example/src/tests/groupTests.ts @@ -1247,6 +1247,35 @@ test('can stream all groups and conversations', async () => { return true }) +test('can stream groups and messages', async () => { + for (const env of ['local', 'dev'] as const) { + const [alixClient, boClient] = await createClients(2, env) + + // Start streaming groups + const groups: Group[] = [] + await alixClient.conversations.streamGroups(async (group: Group) => { + groups.push(group) + }) + // Also stream messages + await alixClient.conversations.streamAllMessages( + async (message) => {}, + true + ) + + // bo creates a group with alix so a stream callback is fired + // eslint-disable-next-line @typescript-eslint/no-unused-vars + await boClient.conversations.newGroup([alixClient.address]) + await delayToPropogate() + if ((groups.length as number) !== 1) { + throw Error( + `Test fails in env ${env}: Unexpected num groups (should be 1): ${groups.length}` + ) + } + } + + return true +}) + test('canMessage', async () => { const [bo, alix, caro] = await createClients(3) diff --git a/example/src/tests/test-utils.ts b/example/src/tests/test-utils.ts index 6d1023938..555425476 100644 --- a/example/src/tests/test-utils.ts +++ b/example/src/tests/test-utils.ts @@ -21,7 +21,10 @@ export function assert(condition: boolean, msg: string) { } } -export async function createClients(numClients: number): Promise { +export async function createClients( + numClients: number, + env: 'dev' | 'local' | 'production' = 'local' +): Promise { const clients = [] for (let i = 0; i < numClients; i++) { const keyBytes = new Uint8Array([ @@ -30,7 +33,7 @@ export async function createClients(numClients: number): Promise { 145, ]) const client = await Client.createRandom({ - env: 'local', + env, enableV3: true, dbEncryptionKey: keyBytes, })