people.js: Rename add() to add_active_user().

This commit is contained in:
clarammdantas
2020-05-26 17:34:15 -03:00
committed by Tim Abbott
parent c90c8c0b19
commit aae7c79c00
41 changed files with 219 additions and 187 deletions

View File

@@ -122,13 +122,13 @@ const zoe = {
full_name: 'Zoe Yang',
};
people.add(alice);
people.add(fred);
people.add(jill);
people.add(mark);
people.add(norbert);
people.add(zoe);
people.add(me);
people.add_active_user(alice);
people.add_active_user(fred);
people.add_active_user(jill);
people.add_active_user(mark);
people.add_active_user(norbert);
people.add_active_user(zoe);
people.add_active_user(me);
people.initialize_current_user(me.user_id);
const real_update_huddles = activity.update_huddles;
@@ -647,7 +647,7 @@ run_test('insert_fred_then_alice_then_rename', () => {
user_id: fred.user_id,
full_name: "Aaron",
};
people.add(fred_with_new_name);
people.add_active_user(fred_with_new_name);
const alice_stub = $.create('alice-first');
buddy_list_add(alice.user_id, alice_stub);
@@ -660,7 +660,7 @@ run_test('insert_fred_then_alice_then_rename', () => {
assert(appended_html.indexOf('data-user-id="2"') > 0);
// restore old Fred data
people.add(fred);
people.add_active_user(fred);
});
// Reset jquery here.

View File

@@ -7,7 +7,7 @@ zrequire('alert_words');
alert_words.initialize(params);
people.add({
people.add_active_user({
email: 'tester@zulip.com',
full_name: 'Tester von Tester',
user_id: 42,

View File

@@ -19,8 +19,8 @@ const fred = {
user_id: 3,
};
people.add(me);
people.add(fred);
people.add_active_user(me);
people.add_active_user(fred);
people.initialize_current_user(me.user_id);
const bot_data_params = {

View File

@@ -55,14 +55,14 @@ function make_people() {
full_name: `Human ${i}`,
email: `person${i}@example.com`,
};
people.add(person);
people.add_active_user(person);
}
people.add(bot);
people.add(bot_with_owner);
people.add(selma);
people.add(me);
people.add(old_user);
people.add_active_user(bot);
people.add_active_user(bot_with_owner);
people.add_active_user(selma);
people.add_active_user(me);
people.add_active_user(old_user);
people.initialize_current_user(me.user_id);
}

View File

@@ -31,7 +31,7 @@ const alice = {
user_id: 10,
full_name: 'Alice Smith',
};
people.add(alice);
people.add_active_user(alice);
run_test('get_items', () => {
const alice_li = $.create('alice stub');
@@ -112,7 +112,7 @@ run_test('big_list', () => {
user_id: 100 + i,
full_name: 'Somebody ' + i,
};
people.add(person);
people.add_active_user(person);
user_ids.push(person.user_id);
});

View File

@@ -122,12 +122,12 @@ const bob = {
full_name: 'Bob',
};
people.add(new_user);
people.add(me);
people.add_active_user(new_user);
people.add_active_user(me);
people.initialize_current_user(me.user_id);
people.add(alice);
people.add(bob);
people.add_active_user(alice);
people.add_active_user(bob);
run_test('validate_stream_message_address_info', () => {
const sub = {
@@ -264,7 +264,7 @@ run_test('validate', () => {
assert.equal($('#compose-error-msg').html(), i18n.t('Please specify at least one valid recipient', {}));
people.add(bob);
people.add_active_user(bob);
compose_state.private_message_recipient('bob@example.com');
assert(compose.validate());

View File

@@ -234,7 +234,7 @@ run_test('respond_to_message', () => {
email: 'alice@example.com',
full_name: 'Alice',
};
people.add(person);
people.add_active_user(person);
let msg = {
type: 'private',
@@ -295,13 +295,13 @@ run_test('reply_with_mention', () => {
email: 'bob1@example.com',
full_name: 'Bob Roberts',
};
people.add(bob_1);
people.add_active_user(bob_1);
const bob_2 = {
user_id: 40,
email: 'bob2@example.com',
full_name: 'Bob Roberts',
};
people.add(bob_2);
people.add_active_user(bob_2);
reply_with_mention(opts);
assert.equal($('#stream_message_recipient_stream').val(), 'devel');

View File

@@ -20,11 +20,11 @@ const bob = {
full_name: 'Bob',
};
people.add(me);
people.add_active_user(me);
people.initialize_current_user(me.user_id);
people.add(alice);
people.add(bob);
people.add_active_user(alice);
people.add_active_user(bob);
run_test('set_focused_recipient', () => {
const sub = {

View File

@@ -19,8 +19,8 @@ const bob = {
full_name: 'Bob',
};
people.add(alice);
people.add(bob);
people.add_active_user(alice);
people.add_active_user(bob);
function make_textbox(s) {
// Simulate a jQuery textbox for testing purposes.

View File

@@ -239,17 +239,17 @@ const harry = {
email: 'harry@zulip.com',
};
people.add(alice);
people.add(hamlet);
people.add(othello);
people.add(cordelia);
people.add(lear);
people.add(twin1);
people.add(twin2);
people.add(gael);
people.add(hal);
people.add(harry);
people.add(deactivated_user);
people.add_active_user(alice);
people.add_active_user(hamlet);
people.add_active_user(othello);
people.add_active_user(cordelia);
people.add_active_user(lear);
people.add_active_user(twin1);
people.add_active_user(twin2);
people.add_active_user(gael);
people.add_active_user(hal);
people.add_active_user(harry);
people.add_active_user(deactivated_user);
people.deactivate(deactivated_user);
const hamletcharacters = {

View File

@@ -116,7 +116,7 @@ const test_user = {
};
people.init();
people.add(test_user);
people.add_active_user(test_user);
const test_message = {
sender_id: test_user.user_id,

View File

@@ -26,9 +26,9 @@ const steve = {
full_name: 'steve',
};
people.add(me);
people.add(joe);
people.add(steve);
people.add_active_user(me);
people.add_active_user(joe);
people.add_active_user(steve);
people.initialize_current_user(me.user_id);
function assert_same_operators(result, terms) {

View File

@@ -23,7 +23,7 @@ const isaac = {
};
assert(!people.is_known_user_id(isaac.user_id));
people.add(isaac);
people.add_active_user(isaac);
assert(people.is_known_user_id(isaac.user_id));
// The `people`object is a very fundamental object in the
@@ -37,7 +37,7 @@ const me = {
user_id: 31,
full_name: 'Me Myself',
};
people.add(me);
people.add_active_user(me);
people.initialize_current_user(me.user_id);
// Let's look at stream_data next, and we will start by putting

View File

@@ -15,7 +15,7 @@ const hamlet = {
full_name: 'Hamlet',
};
people.add(hamlet);
people.add_active_user(hamlet);
const frontend = {
stream_id: 99,

View File

@@ -93,7 +93,7 @@ run_test('people_slugs', () => {
full_name: 'Alice Smith',
};
people.add(alice);
people.add_active_user(alice);
operators = [
{operator: 'sender', operand: 'alice@example.com'},
];

View File

@@ -59,39 +59,39 @@ const cordelia = {
user_id: 101,
email: 'cordelia@zulip.com',
};
people.add(cordelia);
people.add_active_user(cordelia);
people.add({
people.add_active_user({
full_name: 'Leo',
user_id: 102,
email: 'leo@zulip.com',
});
people.add({
people.add_active_user({
full_name: 'Bobby <h1>Tables</h1>',
user_id: 103,
email: 'bobby@zulip.com',
});
people.add({
people.add_active_user({
full_name: 'Mark Twin',
user_id: 104,
email: 'twin1@zulip.com',
});
people.add({
people.add_active_user({
full_name: 'Mark Twin',
user_id: 105,
email: 'twin2@zulip.com',
});
people.add({
people.add_active_user({
full_name: 'Brother of Bobby|123',
user_id: 106,
email: 'bobby2@zulip.com',
});
people.add({
people.add_active_user({
full_name: "& & &amp;",
user_id: 107,
email: "ampampamp@zulip.com",

View File

@@ -27,7 +27,7 @@ const alice = {
full_name: 'Alice Patel',
};
people.add(alice);
people.add_active_user(alice);
const denmark = {
subscribed: false,

View File

@@ -46,7 +46,7 @@ const alice = {
user_id: 7,
full_name: 'Alice',
};
people.add(alice);
people.add_active_user(alice);
resize.resize_bottom_whitespace = noop;
server_events.home_view_loaded = noop;

View File

@@ -55,11 +55,11 @@ const denise = {
full_name: 'Denise ',
};
people.add(me);
people.add(alice);
people.add(bob);
people.add(cindy);
people.add(denise);
people.add_active_user(me);
people.add_active_user(alice);
people.add_active_user(bob);
people.add_active_user(cindy);
people.add_active_user(denise);
people.initialize_current_user(me.user_id);

View File

@@ -43,9 +43,9 @@ const ray = {
};
run_test('uris', () => {
people.add(ray);
people.add(alice);
people.add(me);
people.add_active_user(ray);
people.add_active_user(alice);
people.add_active_user(me);
people.initialize_current_user(me.user_id);
let uri = hash_util.pm_with_uri(ray.email);
@@ -109,7 +109,7 @@ run_test('show_empty_narrow_message', () => {
narrow.show_empty_narrow_message();
assert($('#non_existing_user').visible());
people.add(alice);
people.add_active_user(alice);
set_filter([['pm-with', ['alice@example.com', 'Yo']]]);
narrow.show_empty_narrow_message();
assert($('#non_existing_users').visible());
@@ -207,8 +207,8 @@ run_test('show_invalid_narrow_message', () => {
assert($('#empty_search_narrow_message').visible());
assert.equal(display.text(), 'translated: You are searching for messages that belong to more than one topic, which is not possible.');
people.add(ray);
people.add(alice);
people.add_active_user(ray);
people.add_active_user(alice);
set_filter([['sender', 'alice@example.com'], ['sender', 'ray@example.com']]);
narrow.show_empty_narrow_message();
@@ -286,9 +286,9 @@ run_test('narrow_to_compose_target', () => {
// --- Tests for PMs ---
global.compose_state.get_message_type = () => 'private';
people.add(ray);
people.add(alice);
people.add(me);
people.add_active_user(ray);
people.add_active_user(alice);
people.add_active_user(me);
// Test with valid person
global.compose_state.private_message_recipient = () => 'alice@example.com';

View File

@@ -163,8 +163,8 @@ run_test('set_compose_defaults', () => {
user_id: 57,
full_name: 'John Doe',
};
people.add(john);
people.add(john);
people.add_active_user(john);
people.add_active_user(john);
set_filter([['pm-with', 'john@doe.com']]);
pm_test = narrow_state.set_compose_defaults();
@@ -187,7 +187,7 @@ run_test('update_email', () => {
full_name: 'Steve',
};
people.add(steve);
people.add_active_user(steve);
set_filter([
['pm-with', 'steve@foo.com'],
['sender', 'steve@foo.com'],
@@ -267,8 +267,8 @@ run_test('pm_string', () => {
full_name: 'Bob',
};
people.add(alice);
people.add(bob);
people.add_active_user(alice);
people.add_active_user(bob);
set_filter([['pm-with', 'bob@foo.com,alice@foo.com']]);
assert.equal(narrow_state.pm_string(), '444,555');

View File

@@ -21,7 +21,7 @@ const alice = {
};
people.init();
people.add(alice);
people.add_active_user(alice);
people.is_my_user_id = () => false;
function set_filter(terms) {

View File

@@ -44,7 +44,7 @@ const isaac = {
function initialize() {
people.init();
people.add(me);
people.add_active_user(me);
people.initialize_current_user(me.user_id);
}
@@ -217,7 +217,7 @@ run_test('basics', () => {
assert(!people.is_valid_full_name_and_user_id(full_name, 32));
assert.equal(people.get_user_id_from_name(full_name), undefined);
people.add(isaac);
people.add_active_user(isaac);
assert.equal(
people.get_actual_name_from_user_id(32),
@@ -255,7 +255,7 @@ run_test('basics', () => {
assert.equal(people.is_active_user_for_popover(isaac.user_id), false);
assert.equal(people.is_valid_email_for_compose(isaac.email), false);
people.add(bot_botson);
people.add_active_user(bot_botson);
assert.equal(people.is_active_user_for_popover(bot_botson.user_id), true);
assert.equal(
@@ -308,7 +308,7 @@ run_test('basics', () => {
assert.equal(people.is_my_user_id(undefined), false);
// Reactivating issac
people.add(isaac);
people.add_active_user(isaac);
const active_humans = people.get_active_humans();
assert.equal(active_humans.length, 2);
assert.deepEqual(
@@ -316,6 +316,39 @@ run_test('basics', () => {
[me, isaac]);
});
run_test('check_active_non_active_users', () => {
let active_users = people.get_realm_users();
let non_active_users = people.get_non_active_realm_users();
assert.equal(active_users.length, 3);
assert.equal(non_active_users.length, 0);
people.add_active_user(maria);
people.add_active_user(linus);
active_users = people.get_realm_users();
assert.equal(active_users.length, 5);
// Invalid ID
blueslip.expect('error', 'No user found.');
people.is_person_active(1000001);
assert.equal(people.is_person_active(maria.user_id), true);
assert.equal(people.is_person_active(linus.user_id), true);
people.deactivate(maria);
non_active_users = people.get_non_active_realm_users();
active_users = people.get_realm_users();
assert.equal(non_active_users.length, 1);
assert.equal(active_users.length, 4);
assert.equal(people.is_person_active(maria.user_id), false);
people.deactivate(linus);
people.add_active_user(maria);
non_active_users = people.get_non_active_realm_users();
active_users = people.get_realm_users();
assert.equal(non_active_users.length, 1);
assert.equal(active_users.length, 4);
assert.equal(people.is_person_active(maria.user_id), true);
assert.equal(people.is_person_active(linus.user_id), false);
});
run_test('pm_lookup_key', () => {
assert.equal(people.pm_lookup_key('30'), '30');
assert.equal(people.pm_lookup_key('32,30'), '32');
@@ -343,7 +376,7 @@ run_test('bot_custom_profile_data', () => {
// If this test fails, then try opening organization settings > bots
// http://localhost:9991/#organization/bot-list-admin
// and then try to edit any of the bots.
people.add(bot_botson);
people.add_active_user(bot_botson);
assert.equal(people.get_custom_profile_data(bot_botson.user_id, 3), null);
});
@@ -374,10 +407,10 @@ run_test('user_timezone', () => {
run_test('user_type', () => {
people.init();
people.add(me);
people.add(realm_admin);
people.add(guest);
people.add(bot_botson);
people.add_active_user(me);
people.add_active_user(realm_admin);
people.add_active_user(guest);
people.add_active_user(bot_botson);
assert.equal(people.get_user_type(me.user_id), i18n.t('Member'));
assert.equal(people.get_user_type(realm_admin.user_id), i18n.t('Administrator'));
assert.equal(people.get_user_type(guest.user_id), i18n.t('Guest'));
@@ -398,7 +431,7 @@ run_test('get_by_user_id', () => {
user_id: 42,
full_name: 'Mary',
};
people.add(person);
people.add_active_user(person);
person = people.get_by_email('mary@example.com');
assert.equal(person.full_name, 'Mary');
person = people.get_by_user_id(42);
@@ -432,9 +465,9 @@ run_test('set_custom_profile_field_data', () => {
initialize();
run_test('get_people_for_stream_create', () => {
people.add(alice1);
people.add(bob);
people.add(alice2);
people.add_active_user(alice1);
people.add_active_user(bob);
people.add_active_user(alice2);
assert.equal(people.get_active_human_count(), 4);
const others = people.get_people_for_stream_create();
@@ -460,12 +493,12 @@ run_test('recipient_counts', () => {
});
run_test('filtered_users', () => {
people.add(charles);
people.add(maria);
people.add(ashton);
people.add(linus);
people.add(noah);
people.add(plain_noah);
people.add_active_user(charles);
people.add_active_user(maria);
people.add_active_user(ashton);
people.add_active_user(linus);
people.add_active_user(noah);
people.add_active_user(plain_noah);
const search_term = 'a';
const users = people.get_people_for_stream_create();
@@ -510,8 +543,8 @@ run_test('filtered_users', () => {
people.init();
run_test('multi_user_methods', () => {
people.add(emp401);
people.add(emp402);
people.add_active_user(emp401);
people.add_active_user(emp402);
// The order of user_ids is relevant here.
assert.equal(emp401.user_id, 401);
@@ -566,8 +599,8 @@ run_test('concat_huddle', () => {
initialize();
run_test('message_methods', () => {
people.add(charles);
people.add(maria);
people.add_active_user(charles);
people.add_active_user(maria);
// We don't rely on Maria to have all flags set explicitly--
// undefined values are just treated as falsy.
@@ -644,7 +677,7 @@ run_test('message_methods', () => {
// Test sender_is_bot
const bot = bot_botson;
people.add(bot);
people.add_active_user(bot);
message = { sender_id: bot.user_id };
assert.equal(people.sender_is_bot(message), true);
@@ -656,7 +689,7 @@ run_test('message_methods', () => {
assert.equal(people.sender_is_bot(message), false);
// Test sender_is_guest
people.add(guest);
people.add_active_user(guest);
message = { sender_id: guest.user_id };
assert.equal(people.sender_is_guest(message), true);
@@ -711,7 +744,7 @@ run_test('maybe_incr_recipient_count', () => {
const maria_recip = {
id: maria.user_id,
};
people.add(maria);
people.add_active_user(maria);
let message = {
type: 'private',
@@ -754,7 +787,7 @@ run_test('maybe_incr_recipient_count', () => {
});
run_test('slugs', () => {
people.add(debbie);
people.add_active_user(debbie);
const slug = people.emails_to_slug(debbie.email);
assert.equal(slug, '501-debbie71');
@@ -777,7 +810,7 @@ run_test('get_people_for_search_bar', () => {
full_name: 'James Jones',
user_id: 1000 + i,
};
people.add(person);
people.add_active_user(person);
}
const big_results = people.get_people_for_search_bar('James');
@@ -808,7 +841,7 @@ run_test('updates', () => {
user_id: user_id,
full_name: 'Foo Barson',
};
people.add(person);
people.add_active_user(person);
// Do sanity checks on our data.
assert.equal(people.get_by_email(old_email).user_id, user_id);
@@ -843,8 +876,8 @@ run_test('updates', () => {
initialize();
run_test('update_email_in_reply_to', () => {
people.add(charles);
people.add(maria);
people.add_active_user(charles);
people.add_active_user(maria);
let reply_to = ' charles@example.com, athens@example.com';
assert.equal(
@@ -866,8 +899,8 @@ run_test('update_email_in_reply_to', () => {
initialize();
run_test('track_duplicate_full_names', () => {
people.add(maria);
people.add(stephen1);
people.add_active_user(maria);
people.add_active_user(stephen1);
assert(!people.is_duplicate_full_name('Stephen King'));
assert.equal(
@@ -876,7 +909,7 @@ run_test('track_duplicate_full_names', () => {
);
// Now duplicate the Stephen King name.
people.add({...stephen2});
people.add_active_user({...stephen2});
// For duplicate names we won't try to guess which
// user_id the person means; the UI should use
@@ -901,9 +934,9 @@ run_test('track_duplicate_full_names', () => {
initialize();
run_test('get_mention_syntax', () => {
people.add(stephen1);
people.add(stephen2);
people.add(maria);
people.add_active_user(stephen1);
people.add_active_user(stephen2);
people.add_active_user(maria);
assert(people.is_duplicate_full_name('Stephen King'));
@@ -1035,8 +1068,8 @@ run_test('is_valid_full_name_and_user_id', () => {
});
run_test('emails_strings_to_user_ids_array', function () {
people.add(steven);
people.add(maria);
people.add_active_user(steven);
people.add_active_user(maria);
let user_ids = people.emails_strings_to_user_ids_array(`${steven.email},${maria.email}`);
assert.deepEqual(user_ids, [steven.user_id, maria.user_id]);
@@ -1047,8 +1080,8 @@ run_test('emails_strings_to_user_ids_array', function () {
});
run_test('get_visible_email', function () {
people.add(steven);
people.add(maria);
people.add_active_user(steven);
people.add_active_user(maria);
let email = people.get_visible_email(steven);
assert.equal(email, steven.delivery_email);
@@ -1066,9 +1099,9 @@ run_test('get_active_message_people', function () {
];
};
people.add(steven);
people.add(maria);
people.add(alice1);
people.add_active_user(steven);
people.add_active_user(maria);
people.add_active_user(alice1);
let active_message_people = people.get_active_message_people();
assert.deepEqual(active_message_people, [steven, maria, alice1]);

View File

@@ -14,7 +14,7 @@ const me = {
};
people.init();
people.add(me);
people.add_active_user(me);
people.initialize_current_user(me.user_id);
run_test('report_late_add', () => {
@@ -52,7 +52,7 @@ run_test('blueslip', () => {
user_id: undefined,
full_name: 'Person Person',
};
people.add(person);
people.add_active_user(person);
blueslip.expect('error', 'No user_id found for person@example.com');
const user_id = people.get_user_id('person@example.com');
@@ -86,8 +86,8 @@ run_test('blueslip', () => {
user_id: 452,
full_name: 'Maria Athens',
};
people.add(charles);
people.add(maria);
people.add_active_user(charles);
people.add_active_user(maria);
message = {
type: 'private',

View File

@@ -46,10 +46,10 @@ const bot_test = {
is_admin: false,
is_bot: true,
};
people.add(alice);
people.add(bob);
people.add(me);
people.add(bot_test);
people.add_active_user(alice);
people.add_active_user(bob);
people.add_active_user(me);
people.add_active_user(bot_test);
people.initialize_current_user(me.user_id);
run_test('close', () => {

View File

@@ -75,8 +75,8 @@ const e = {
function initialize_people() {
people.init();
people.add(me);
people.add(alice);
people.add_active_user(me);
people.add_active_user(alice);
people.initialize_current_user(me.user_id);
}

View File

@@ -48,12 +48,12 @@ const bot = {
is_bot: true,
};
people.add(me);
people.add(alice);
people.add(fred);
people.add(sally);
people.add(zoe);
people.add(bot);
people.add_active_user(me);
people.add_active_user(alice);
people.add_active_user(fred);
people.add_active_user(sally);
people.add_active_user(zoe);
people.add_active_user(bot);
people.initialize_current_user(me.user_id);
run_test('my user', () => {

View File

@@ -67,9 +67,9 @@ const cali = {
user_id: 7,
full_name: 'Cali',
};
people.add(alice);
people.add(bob);
people.add(cali);
people.add_active_user(alice);
people.add_active_user(bob);
people.add_active_user(cali);
const message = {
id: 1001,
@@ -754,4 +754,3 @@ run_test('process_reaction_click errors', () => {
blueslip.expect('error', 'Data integrity problem for reaction bad-local-id (message some-msg-id)');
reactions.process_reaction_click('some-msg-id', 'bad-local-id');
});

View File

@@ -22,8 +22,8 @@ const cordelia = {
full_name: 'Cordelia',
};
people.init();
people.add(iago);
people.add(cordelia);
people.add_active_user(iago);
people.add_active_user(cordelia);
people.initialize_current_user(iago.user_id);
const group_me = {

View File

@@ -62,11 +62,11 @@ const noop = () => {};
function init() {
people.init();
people.add(bob);
people.add(me);
people.add(ted);
people.add(alice);
people.add(jeff);
people.add_active_user(bob);
people.add_active_user(me);
people.add_active_user(ted);
people.add_active_user(alice);
people.add_active_user(jeff);
people.initialize_current_user(me.user_id);
}
@@ -993,7 +993,7 @@ function people_suggestion_setup() {
user_id: 201,
full_name: 'Ted Smith',
};
people.add(ted);
people.add_active_user(ted);
const bob = {
email: 'bob@zulip.com',
@@ -1001,13 +1001,13 @@ function people_suggestion_setup() {
full_name: 'Bob Térry',
};
people.add(bob);
people.add_active_user(bob);
const alice = {
email: 'alice@zulip.com',
user_id: 203,
full_name: 'Alice Ignore',
};
people.add(alice);
people.add_active_user(alice);
stream_topic_history.reset();
}

View File

@@ -59,11 +59,11 @@ const jeff =
function init() {
people.init();
people.add(bob);
people.add(me);
people.add(ted);
people.add(alice);
people.add(jeff);
people.add_active_user(bob);
people.add_active_user(me);
people.add_active_user(ted);
people.add_active_user(alice);
people.add_active_user(jeff);
people.initialize_current_user(me.user_id);
}
@@ -987,9 +987,9 @@ run_test('people_suggestions', () => {
user_id: 203,
full_name: 'Alice Ignore',
};
people.add(ted);
people.add(bob);
people.add(alice);
people.add_active_user(ted);
people.add_active_user(bob);
people.add_active_user(alice);
stream_topic_history.reset();

View File

@@ -31,7 +31,7 @@ const me = {
};
// set up user data
people.add(me);
people.add_active_user(me);
people.initialize_current_user(me.user_id);
function contains_sub(subs, sub) {
@@ -181,9 +181,9 @@ run_test('subscribers', () => {
full_name: 'George',
user_id: 103,
};
people.add(fred);
people.add(not_fred);
people.add(george);
people.add_active_user(fred);
people.add_active_user(not_fred);
people.add_active_user(george);
function potential_subscriber_ids() {
const users = stream_data.potential_subscribers(sub);
@@ -221,7 +221,7 @@ run_test('subscribers', () => {
full_name: 'Brutus',
user_id: 104,
};
people.add(brutus);
people.add_active_user(brutus);
assert(!stream_data.is_user_subscribed('Rome', brutus.user_id));
// add
@@ -608,7 +608,7 @@ run_test('get_subscriber_count', () => {
full_name: 'Fred',
user_id: 101,
};
people.add(fred);
people.add_active_user(fred);
stream_data.add_subscriber('India', 102);
assert.equal(stream_data.get_subscriber_count('India'), 1);
const george = {
@@ -616,7 +616,7 @@ run_test('get_subscriber_count', () => {
full_name: 'George',
user_id: 103,
};
people.add(george);
people.add_active_user(george);
stream_data.add_subscriber('India', 103);
assert.equal(stream_data.get_subscriber_count('India'), 2);

View File

@@ -17,7 +17,7 @@ const george = {
full_name: 'George',
user_id: 103,
};
people.add(george);
people.add_active_user(george);
const frontend = {
subscribed: false,

View File

@@ -35,8 +35,8 @@ run_test('narrowing', () => {
full_name: 'Bob Patel',
};
people.add(alice);
people.add(bob);
people.add_active_user(alice);
people.add_active_user(bob);
pm_expanded = false;
filter = new Filter([

View File

@@ -135,7 +135,7 @@ run_test('reply_message_private', () => {
email: 'fred@example.com',
full_name: 'Fred Frost',
};
people.add(fred);
people.add_active_user(fred);
people.is_my_user_id = () => false;

View File

@@ -201,7 +201,7 @@ const matches = [
];
for (const person of matches) {
people.add(person);
people.add_active_user(person);
}
function get_typeahead_result(query, current_stream, current_topic) {

View File

@@ -20,7 +20,7 @@ const me = {
user_id: 30,
full_name: 'Me Myself',
};
people.add(me);
people.add_active_user(me);
people.initialize_current_user(me.user_id);
const social = {
@@ -399,7 +399,7 @@ run_test('private_messages', () => {
user_id: 999,
full_name: 'Any Body',
};
people.add(anybody);
people.add_active_user(anybody);
const message = {
id: 15,
@@ -430,14 +430,14 @@ run_test('private_messages', () => {
user_id: 101,
full_name: 'Alice',
};
people.add(alice);
people.add_active_user(alice);
const bob = {
email: 'bob@example.com',
user_id: 102,
full_name: 'Bob',
};
people.add(bob);
people.add_active_user(bob);
assert.equal(unread.num_unread_for_person(alice.user_id.toString()), 0);
assert.equal(unread.num_unread_for_person(bob.user_id.toString()), 0);

View File

@@ -59,7 +59,7 @@ const me = {
function initialize() {
people.init();
people.add(me);
people.add_active_user(me);
people.initialize_current_user(me.user_id);
}
@@ -73,7 +73,7 @@ run_test('updates', () => {
user_id: 32,
full_name: 'Isaac Newton',
};
people.add(isaac);
people.add_active_user(isaac);
user_events.update_person({user_id: isaac.user_id, is_guest: true});
person = people.get_by_email(isaac.email);
@@ -174,7 +174,7 @@ run_test('updates', () => {
is_bot: true,
bot_owner_id: isaac.id,
};
people.add(test_bot);
people.add_active_user(test_bot);
user_events.update_person({user_id: test_bot.user_id, bot_owner_id: me.user_id});
person = people.get_by_email(test_bot.email);

View File

@@ -32,8 +32,8 @@ const isaac_item = {
};
run_test('setup', () => {
people.add(alice);
people.add(isaac);
people.add_active_user(alice);
people.add_active_user(isaac);
});
run_test('create_item', () => {