Add "new conversation" composer for direct messages
This commit is contained in:
parent
84dc166b63
commit
06fb4fd0bc
61 changed files with 5960 additions and 3887 deletions
|
@ -9,9 +9,16 @@ import {
|
|||
MessageType,
|
||||
} from '../../../state/ducks/conversations';
|
||||
import { noopAction } from '../../../state/ducks/noop';
|
||||
import { getEmptyState as getEmptySearchState } from '../../../state/ducks/search';
|
||||
import {
|
||||
getEmptyState as getEmptySearchState,
|
||||
MessageSearchResultType,
|
||||
} from '../../../state/ducks/search';
|
||||
import { getEmptyState as getEmptyUserState } from '../../../state/ducks/user';
|
||||
import { getMessageSearchResultSelector } from '../../../state/selectors/search';
|
||||
import {
|
||||
getMessageSearchResultSelector,
|
||||
getSearchResults,
|
||||
} from '../../../state/selectors/search';
|
||||
import { makeLookup } from '../../../util/makeLookup';
|
||||
|
||||
import { StateType, reducer as rootReducer } from '../../../state/reducer';
|
||||
|
||||
|
@ -34,6 +41,13 @@ describe('both/state/selectors/search', () => {
|
|||
};
|
||||
}
|
||||
|
||||
function getDefaultSearchMessage(id: string): MessageSearchResultType {
|
||||
return {
|
||||
...getDefaultMessage(id),
|
||||
snippet: 'foo bar',
|
||||
};
|
||||
}
|
||||
|
||||
function getDefaultConversation(id: string): ConversationType {
|
||||
return {
|
||||
id,
|
||||
|
@ -209,4 +223,81 @@ describe('both/state/selectors/search', () => {
|
|||
assert.notStrictEqual(actual, thirdActual);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#getSearchResults', () => {
|
||||
it("returns loading search results when they're loading", () => {
|
||||
const state = {
|
||||
...getEmptyRootState(),
|
||||
search: {
|
||||
...getEmptySearchState(),
|
||||
query: 'foo bar',
|
||||
discussionsLoading: true,
|
||||
messagesLoading: true,
|
||||
},
|
||||
};
|
||||
|
||||
assert.deepEqual(getSearchResults(state), {
|
||||
conversationResults: { isLoading: true },
|
||||
contactResults: { isLoading: true },
|
||||
messageResults: { isLoading: true },
|
||||
searchConversationName: undefined,
|
||||
searchTerm: 'foo bar',
|
||||
});
|
||||
});
|
||||
|
||||
it('returns loaded search results', () => {
|
||||
const conversations: Array<ConversationType> = [
|
||||
getDefaultConversation('1'),
|
||||
getDefaultConversation('2'),
|
||||
];
|
||||
const contacts: Array<ConversationType> = [
|
||||
getDefaultConversation('3'),
|
||||
getDefaultConversation('4'),
|
||||
getDefaultConversation('5'),
|
||||
];
|
||||
const messages: Array<MessageSearchResultType> = [
|
||||
getDefaultSearchMessage('a'),
|
||||
getDefaultSearchMessage('b'),
|
||||
getDefaultSearchMessage('c'),
|
||||
];
|
||||
|
||||
const getId = ({ id }: Readonly<{ id: string }>) => id;
|
||||
|
||||
const state: StateType = {
|
||||
...getEmptyRootState(),
|
||||
conversations: {
|
||||
// This test state is invalid, but is good enough for this test.
|
||||
...getEmptyConversationState(),
|
||||
conversationLookup: makeLookup([...conversations, ...contacts], 'id'),
|
||||
},
|
||||
search: {
|
||||
...getEmptySearchState(),
|
||||
query: 'foo bar',
|
||||
conversationIds: conversations.map(getId),
|
||||
contactIds: contacts.map(getId),
|
||||
messageIds: messages.map(getId),
|
||||
messageLookup: makeLookup(messages, 'id'),
|
||||
discussionsLoading: false,
|
||||
messagesLoading: false,
|
||||
},
|
||||
};
|
||||
|
||||
assert.deepEqual(getSearchResults(state), {
|
||||
conversationResults: {
|
||||
isLoading: false,
|
||||
results: conversations,
|
||||
},
|
||||
contactResults: {
|
||||
isLoading: false,
|
||||
results: contacts,
|
||||
},
|
||||
messageResults: {
|
||||
isLoading: false,
|
||||
results: messages,
|
||||
},
|
||||
searchConversationName: undefined,
|
||||
searchTerm: 'foo bar',
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue