mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-03 21:43:21 +00:00 
			
		
		
		
	If two user_ids in a recent huddle have ids
that sort lexically differently than numerically,
such as 7 and 66, then we were creating two
different buckets in pm_conversations.
This regression was introduced in
263ac0eb45 on
November 21, 2019.
		
	
		
			
				
	
	
		
			57 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			57 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
const pmc = zrequire('pm_conversations');
 | 
						|
 | 
						|
run_test('partners', () => {
 | 
						|
    const user1_id = 1;
 | 
						|
    const user2_id = 2;
 | 
						|
    const user3_id = 3;
 | 
						|
 | 
						|
    pmc.set_partner(user1_id);
 | 
						|
    pmc.set_partner(user3_id);
 | 
						|
 | 
						|
    assert.equal(pmc.is_partner(user1_id), true);
 | 
						|
    assert.equal(pmc.is_partner(user2_id), false);
 | 
						|
    assert.equal(pmc.is_partner(user3_id), true);
 | 
						|
});
 | 
						|
 | 
						|
zrequire("people");
 | 
						|
 | 
						|
run_test('insert_recent_private_message', () => {
 | 
						|
    set_global('page_params', {
 | 
						|
        recent_private_conversations: [
 | 
						|
            {user_ids: [11, 2],
 | 
						|
             max_message_id: 150,
 | 
						|
            },
 | 
						|
            {user_ids: [1],
 | 
						|
             max_message_id: 111,
 | 
						|
            },
 | 
						|
            {user_ids: [],
 | 
						|
             max_message_id: 7,
 | 
						|
            },
 | 
						|
        ],
 | 
						|
    });
 | 
						|
    people.initialize_current_user(15);
 | 
						|
    pmc.recent.initialize();
 | 
						|
 | 
						|
    assert.deepEqual(pmc.recent.get(), [
 | 
						|
        {user_ids_string: '2,11', max_message_id: 150},
 | 
						|
        {user_ids_string: '1', max_message_id: 111},
 | 
						|
        {user_ids_string: '15', max_message_id: 7},
 | 
						|
    ]);
 | 
						|
 | 
						|
    pmc.recent.insert([1], 1001);
 | 
						|
    pmc.recent.insert([2], 2001);
 | 
						|
    pmc.recent.insert([1], 3001);
 | 
						|
 | 
						|
    // try to backdate user1's latest message
 | 
						|
    pmc.recent.insert([1], 555);
 | 
						|
 | 
						|
    assert.deepEqual(pmc.recent.get(), [
 | 
						|
        {user_ids_string: '1', max_message_id: 3001},
 | 
						|
        {user_ids_string: '2', max_message_id: 2001},
 | 
						|
        {user_ids_string: '2,11', max_message_id: 150},
 | 
						|
        {user_ids_string: '15', max_message_id: 7},
 | 
						|
    ]);
 | 
						|
 | 
						|
    assert.deepEqual(pmc.recent.get_strings(), ['1', '2', '2,11', '15']);
 | 
						|
});
 |