Various fixes for message forwarding
This commit is contained in:
parent
3face767aa
commit
353becffac
8 changed files with 222 additions and 44 deletions
|
@ -13,6 +13,7 @@ import {
|
|||
import {
|
||||
_getConversationComparator,
|
||||
_getLeftPaneLists,
|
||||
getAllComposableConversations,
|
||||
getCandidateContactsForNewGroup,
|
||||
getCantAddContactForModal,
|
||||
getComposeContacts,
|
||||
|
@ -450,6 +451,85 @@ describe('both/state/selectors/conversations', () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe('#getAllComposableConversations', () => {
|
||||
const getRootState = (): StateType => {
|
||||
const rootState = getEmptyRootState();
|
||||
return {
|
||||
...rootState,
|
||||
conversations: {
|
||||
...getEmptyState(),
|
||||
conversationLookup: {
|
||||
'our-conversation-id': {
|
||||
...getDefaultConversation('our-conversation-id'),
|
||||
isMe: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
user: {
|
||||
...rootState.user,
|
||||
ourConversationId: 'our-conversation-id',
|
||||
i18n,
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
const getRootStateWithConversations = (): StateType => {
|
||||
const result = getRootState();
|
||||
Object.assign(result.conversations.conversationLookup, {
|
||||
'convo-1': {
|
||||
...getDefaultConversation('convo-1'),
|
||||
title: 'A',
|
||||
},
|
||||
'convo-2': {
|
||||
...getDefaultConversation('convo-2'),
|
||||
type: 'group',
|
||||
isGroupV1AndDisabled: true,
|
||||
title: 'Should Be Dropped (GV1)',
|
||||
},
|
||||
'convo-3': {
|
||||
...getDefaultConversation('convo-3'),
|
||||
type: 'group',
|
||||
title: 'B',
|
||||
},
|
||||
'convo-4': {
|
||||
...getDefaultConversation('convo-4'),
|
||||
isBlocked: true,
|
||||
title: 'Should Be Dropped (blocked)',
|
||||
},
|
||||
'convo-5': {
|
||||
...getDefaultConversation('convo-5'),
|
||||
discoveredUnregisteredAt: new Date(1999, 3, 20).getTime(),
|
||||
title: 'C',
|
||||
},
|
||||
'convo-6': {
|
||||
...getDefaultConversation('convo-6'),
|
||||
profileSharing: true,
|
||||
name: 'Should Be Droped (no title)',
|
||||
title: null,
|
||||
},
|
||||
'convo-7': {
|
||||
...getDefaultConversation('convo-7'),
|
||||
discoveredUnregisteredAt: Date.now(),
|
||||
title: 'Should Be Dropped (unregistered)',
|
||||
},
|
||||
});
|
||||
return result;
|
||||
};
|
||||
|
||||
it('returns no gv1, no blocked, no missing titles', () => {
|
||||
const state = getRootStateWithConversations();
|
||||
const result = getAllComposableConversations(state);
|
||||
|
||||
const ids = result.map(contact => contact.id);
|
||||
assert.deepEqual(ids, [
|
||||
'our-conversation-id',
|
||||
'convo-1',
|
||||
'convo-3',
|
||||
'convo-5',
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#getComposeContacts', () => {
|
||||
const getRootState = (searchTerm = ''): StateType => {
|
||||
const rootState = getEmptyRootState();
|
||||
|
@ -558,7 +638,7 @@ describe('both/state/selectors/conversations', () => {
|
|||
assert.deepEqual(ids, ['convo-0']);
|
||||
});
|
||||
|
||||
it('returns not to self when searching for your own name', () => {
|
||||
it('returns note to self when searching for your own name', () => {
|
||||
const state = getRootStateWithConversations('Myself');
|
||||
const result = getComposeContacts(state);
|
||||
|
||||
|
|
|
@ -4,9 +4,12 @@
|
|||
import { assert } from 'chai';
|
||||
import { getDefaultConversation } from '../helpers/getDefaultConversation';
|
||||
|
||||
import { filterAndSortConversations } from '../../util/filterAndSortConversations';
|
||||
import {
|
||||
filterAndSortConversationsByTitle,
|
||||
filterAndSortConversationsByRecent,
|
||||
} from '../../util/filterAndSortConversations';
|
||||
|
||||
describe('filterAndSortConversations', () => {
|
||||
describe('filterAndSortConversationsByTitle', () => {
|
||||
const conversations = [
|
||||
getDefaultConversation({
|
||||
title: '+16505551234',
|
||||
|
@ -34,7 +37,7 @@ describe('filterAndSortConversations', () => {
|
|||
];
|
||||
|
||||
it('without a search term, sorts conversations by title (but puts no-name contacts at the bottom)', () => {
|
||||
const titles = filterAndSortConversations(conversations, '').map(
|
||||
const titles = filterAndSortConversationsByTitle(conversations, '').map(
|
||||
contact => contact.title
|
||||
);
|
||||
assert.deepEqual(titles, [
|
||||
|
@ -47,16 +50,56 @@ describe('filterAndSortConversations', () => {
|
|||
});
|
||||
|
||||
it('can search for contacts by title', () => {
|
||||
const titles = filterAndSortConversations(conversations, 'belind').map(
|
||||
contact => contact.title
|
||||
);
|
||||
const titles = filterAndSortConversationsByTitle(
|
||||
conversations,
|
||||
'belind'
|
||||
).map(contact => contact.title);
|
||||
assert.sameMembers(titles, ['Belinda Beetle', 'Belinda Zephyr']);
|
||||
});
|
||||
|
||||
it('can search for contacts by phone number (and puts no-name contacts at the bottom)', () => {
|
||||
const titles = filterAndSortConversations(conversations, '650555').map(
|
||||
contact => contact.title
|
||||
);
|
||||
const titles = filterAndSortConversationsByTitle(
|
||||
conversations,
|
||||
'650555'
|
||||
).map(contact => contact.title);
|
||||
assert.sameMembers(titles, ['Carlos Santana', '+16505551234']);
|
||||
});
|
||||
});
|
||||
|
||||
describe('filterAndSortConversationsByRecent', () => {
|
||||
const conversations = [
|
||||
getDefaultConversation({
|
||||
title: '+16505551234',
|
||||
activeAt: 1,
|
||||
}),
|
||||
getDefaultConversation({
|
||||
title: 'Abraham Lincoln',
|
||||
activeAt: 4,
|
||||
}),
|
||||
getDefaultConversation({
|
||||
title: 'Boxing Club',
|
||||
activeAt: 3,
|
||||
}),
|
||||
getDefaultConversation({
|
||||
title: 'Not recent',
|
||||
}),
|
||||
getDefaultConversation({
|
||||
title: 'George Washington',
|
||||
e164: '+16505559876',
|
||||
activeAt: 2,
|
||||
}),
|
||||
];
|
||||
|
||||
it('sorts by recency when no search term is provided', () => {
|
||||
const titles = filterAndSortConversationsByRecent(conversations, '').map(
|
||||
contact => contact.title
|
||||
);
|
||||
assert.sameMembers(titles, [
|
||||
'+16505551234',
|
||||
'George Washington',
|
||||
'Boxing Club',
|
||||
'Abraham Lincoln',
|
||||
'Not recent',
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue