Skip to content

Commit 3d6e262

Browse files
committed
Fixed test
1 parent 9a09a0c commit 3d6e262

File tree

1 file changed

+33
-25
lines changed

1 file changed

+33
-25
lines changed

__tests__/member-message-role.test.ts

Lines changed: 33 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import { createTestClient } from './create-test-client';
66
import { StreamClient } from '../src/StreamClient';
77
import { StreamChannel } from '../src/StreamChannel';
88

9-
109
describe('member message role propagation', () => {
1110
let client: StreamClient;
1211
let channel: StreamChannel;
@@ -37,24 +36,28 @@ describe('member message role propagation', () => {
3736
await channel.getOrCreate({
3837
data: {
3938
created_by: { id: user1.id },
40-
members: [{
41-
user_id: user1.id, channel_role: user1.channel_role,
42-
banned: false,
43-
created_at: new Date(),
44-
notifications_muted: false,
45-
shadow_banned: false,
46-
updated_at: new Date(),
47-
custom: []
48-
}, {
49-
user_id: user2.id,
50-
banned: false,
51-
channel_role: '',
52-
created_at: new Date(),
53-
notifications_muted: false,
54-
shadow_banned: false,
55-
updated_at: new Date(),
56-
custom: []
57-
}],
39+
members: [
40+
{
41+
user_id: user1.id,
42+
channel_role: user1.channel_role,
43+
banned: false,
44+
created_at: new Date(),
45+
notifications_muted: false,
46+
shadow_banned: false,
47+
updated_at: new Date(),
48+
custom: [],
49+
},
50+
{
51+
user_id: user2.id,
52+
banned: false,
53+
channel_role: '',
54+
created_at: new Date(),
55+
notifications_muted: false,
56+
shadow_banned: false,
57+
updated_at: new Date(),
58+
custom: [],
59+
},
60+
],
5861
},
5962
});
6063
});
@@ -71,7 +74,7 @@ describe('member message role propagation', () => {
7174
messageId1 = resp1.message.id;
7275

7376
expect(resp1.message?.user?.id).toBe(user1.id);
74-
expect(resp1.message?.member?.channel_role).toBe();
77+
expect(resp1.message?.member?.channel_role).toBe(user1.channel_role);
7578

7679
const resp2 = await channel.sendMessage({
7780
message: {
@@ -87,18 +90,23 @@ describe('member message role propagation', () => {
8790
});
8891

8992
it('channel state messages should include creator role', async () => {
90-
const state = await channel.getOrCreate();
93+
const queryResp = await client.chat.queryChannels({
94+
filter_conditions: { id: channelId },
95+
limit: 1,
96+
message_limit: 10,
97+
state: true,
98+
});
9199

92-
// Ensure both messages are present with correct roles.
93-
const msg1 = state.messages.find((m) => m.id === messageId1);
94-
const msg2 = state.messages.find((m) => m.id === messageId2);
100+
const messages = queryResp.channels[0].messages;
101+
const msg1 = messages.find((m) => m.id === messageId1);
102+
const msg2 = messages.find((m) => m.id === messageId2);
95103

96104
expect(msg1?.member?.channel_role).toBe(user1.channel_role);
97105
expect(msg2?.member?.channel_role).toBe(user2.channel_role);
98106
});
99107

100108
afterAll(async () => {
101109
// Clean up the channel after test run
102-
await channel.delete({ hard_delete: true });
110+
// await channel.delete({ hard_delete: true });
103111
});
104112
});

0 commit comments

Comments
 (0)