mirror of
https://github.com/zulip/zulip.git
synced 2025-11-03 13:33:24 +00:00
This will help us accurately track participants in every narrow to be used buddy list and other components.
57 lines
1.3 KiB
JavaScript
57 lines
1.3 KiB
JavaScript
"use strict";
|
|
|
|
const assert = require("node:assert/strict");
|
|
|
|
const _ = require("lodash");
|
|
|
|
const {make_user, make_bot} = require("./lib/example_user.cjs");
|
|
const {zrequire} = require("./lib/namespace.cjs");
|
|
const {run_test} = require("./lib/test.cjs");
|
|
|
|
const people = zrequire("people");
|
|
const {ConversationParticipants} = zrequire("../src/conversation_participants.ts");
|
|
|
|
const user1 = make_user();
|
|
const user2 = make_user();
|
|
const bot1 = make_bot();
|
|
const bot2 = make_bot();
|
|
|
|
people._add_user(user1);
|
|
people._add_user(user2);
|
|
people._add_user(bot1);
|
|
people._add_user(bot2);
|
|
|
|
const human_messages = [
|
|
{
|
|
id: 1,
|
|
sender_id: user1.user_id,
|
|
sent_by_me: true,
|
|
},
|
|
{
|
|
id: 2,
|
|
sender_id: user2.user_id,
|
|
sent_by_me: false,
|
|
},
|
|
];
|
|
|
|
const bot_messages = [
|
|
{
|
|
id: 4,
|
|
sender_id: bot1.user_id,
|
|
sent_by_me: false,
|
|
},
|
|
{
|
|
id: 5,
|
|
sender_id: bot2.user_id,
|
|
sent_by_me: false,
|
|
},
|
|
];
|
|
|
|
const all_messages = [...human_messages, ...bot_messages];
|
|
|
|
run_test("Add participants", () => {
|
|
const participants = new ConversationParticipants(all_messages);
|
|
assert.ok(_.isEqual(participants.humans, new Set([user1.user_id, user2.user_id])));
|
|
assert.ok(_.isEqual(participants.bots, new Set([bot1.user_id, bot2.user_id])));
|
|
});
|