mirror of
https://github.com/zulip/zulip.git
synced 2026-06-24 21:08:25 +08:00
We had this API:
people.add_in_realm = full-fledged user
people.add = not necessarily in realm
Now the API is this:
people.add = full-fledged user
people._add_user = internal API for cross-realm bots
and deactivated users
I think in most of our tests the distinction between
people.add() and people.add_in_realm() was just an
accident of history and didn't reflect any real intention.
And if I had to guess the intention in 99% of the cases,
folks probably thought they were just creating ordinary,
active users in the current realm.
In places where the distinction was obviously important
(because a test failed), I deactivated the user via
`people.deactivate`.
For the 'basics' test in the people test suite, I clean
up the test setup for Isaac. Before this commit I was
adding him first as a non-realm user then as a full-fledged
user, but this was contrived and confusing, and we
didn't really need it for test coverage purposes.
80 lines
1.9 KiB
JavaScript
80 lines
1.9 KiB
JavaScript
set_global('blueslip', {});
|
|
global.blueslip.warn = function () {};
|
|
|
|
zrequire('stream_data');
|
|
zrequire('people');
|
|
zrequire('compose_fade');
|
|
|
|
const me = {
|
|
email: '[email protected]',
|
|
user_id: 30,
|
|
full_name: 'Me Myself',
|
|
};
|
|
|
|
const alice = {
|
|
email: '[email protected]',
|
|
user_id: 31,
|
|
full_name: 'Alice',
|
|
};
|
|
|
|
const bob = {
|
|
email: '[email protected]',
|
|
user_id: 32,
|
|
full_name: 'Bob',
|
|
};
|
|
|
|
people.add(me);
|
|
people.initialize_current_user(me.user_id);
|
|
|
|
people.add(alice);
|
|
people.add(bob);
|
|
|
|
|
|
run_test('set_focused_recipient', () => {
|
|
const sub = {
|
|
stream_id: 101,
|
|
name: 'social',
|
|
subscribed: true,
|
|
can_access_subscribers: true,
|
|
};
|
|
stream_data.add_sub(sub);
|
|
stream_data.set_subscribers(sub, [me.user_id, alice.user_id]);
|
|
|
|
global.$ = function (selector) {
|
|
switch (selector) {
|
|
case '#stream_message_recipient_stream':
|
|
return {
|
|
val: function () {
|
|
return 'social';
|
|
},
|
|
};
|
|
case '#stream_message_recipient_topic':
|
|
return {
|
|
val: function () {
|
|
return 'lunch';
|
|
},
|
|
};
|
|
}
|
|
};
|
|
|
|
compose_fade.set_focused_recipient('stream');
|
|
|
|
assert.equal(compose_fade.would_receive_message('[email protected]'), true);
|
|
assert.equal(compose_fade.would_receive_message('[email protected]'), true);
|
|
assert.equal(compose_fade.would_receive_message('[email protected]'), false);
|
|
assert.equal(compose_fade.would_receive_message('[email protected]'), true);
|
|
|
|
const good_msg = {
|
|
type: 'stream',
|
|
stream_id: 101,
|
|
topic: 'lunch',
|
|
};
|
|
const bad_msg = {
|
|
type: 'stream',
|
|
stream_id: 999,
|
|
topic: 'lunch',
|
|
};
|
|
assert(!compose_fade.should_fade_message(good_msg));
|
|
assert(compose_fade.should_fade_message(bad_msg));
|
|
});
|