chore: Search improvements (#10801)
- Adds pagination support for search. - Use composition API on all search related component. - Minor UI improvements. - Adds missing specs Loom video https://www.loom.com/share/5b01afa5c9204e7d97ff81b215621dde?sid=82ca6d22-ca8c-4d5e-8740-ba06ca4051ba
This commit is contained in:
@@ -10,7 +10,7 @@ describe('#mutations', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('#SEARCH_CONVERSATIONS_SET', () => {
|
||||
describe('#SEARCH_CONVERSATIONS_SET_UI_FLAG', () => {
|
||||
it('set uiFlags correctly', () => {
|
||||
const state = { uiFlags: { isFetching: true } };
|
||||
mutations[types.SEARCH_CONVERSATIONS_SET_UI_FLAG](state, {
|
||||
@@ -19,4 +19,99 @@ describe('#mutations', () => {
|
||||
expect(state.uiFlags).toEqual({ isFetching: false });
|
||||
});
|
||||
});
|
||||
|
||||
describe('#CONTACT_SEARCH_SET', () => {
|
||||
it('should append new contact records to existing ones', () => {
|
||||
const state = { contactRecords: [{ id: 1 }] };
|
||||
mutations[types.CONTACT_SEARCH_SET](state, [{ id: 2 }]);
|
||||
expect(state.contactRecords).toEqual([{ id: 1 }, { id: 2 }]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#CONVERSATION_SEARCH_SET', () => {
|
||||
it('should append new conversation records to existing ones', () => {
|
||||
const state = { conversationRecords: [{ id: 1 }] };
|
||||
mutations[types.CONVERSATION_SEARCH_SET](state, [{ id: 2 }]);
|
||||
expect(state.conversationRecords).toEqual([{ id: 1 }, { id: 2 }]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#MESSAGE_SEARCH_SET', () => {
|
||||
it('should append new message records to existing ones', () => {
|
||||
const state = { messageRecords: [{ id: 1 }] };
|
||||
mutations[types.MESSAGE_SEARCH_SET](state, [{ id: 2 }]);
|
||||
expect(state.messageRecords).toEqual([{ id: 1 }, { id: 2 }]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#FULL_SEARCH_SET_UI_FLAG', () => {
|
||||
it('set full search UI flags correctly', () => {
|
||||
const state = {
|
||||
uiFlags: {
|
||||
isFetching: true,
|
||||
isSearchCompleted: false,
|
||||
},
|
||||
};
|
||||
mutations[types.FULL_SEARCH_SET_UI_FLAG](state, {
|
||||
isFetching: false,
|
||||
isSearchCompleted: true,
|
||||
});
|
||||
expect(state.uiFlags).toEqual({
|
||||
isFetching: false,
|
||||
isSearchCompleted: true,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('#CONTACT_SEARCH_SET_UI_FLAG', () => {
|
||||
it('set contact search UI flags correctly', () => {
|
||||
const state = {
|
||||
uiFlags: {
|
||||
contact: { isFetching: true },
|
||||
},
|
||||
};
|
||||
mutations[types.CONTACT_SEARCH_SET_UI_FLAG](state, { isFetching: false });
|
||||
expect(state.uiFlags.contact).toEqual({ isFetching: false });
|
||||
});
|
||||
});
|
||||
|
||||
describe('#CONVERSATION_SEARCH_SET_UI_FLAG', () => {
|
||||
it('set conversation search UI flags correctly', () => {
|
||||
const state = {
|
||||
uiFlags: {
|
||||
conversation: { isFetching: true },
|
||||
},
|
||||
};
|
||||
mutations[types.CONVERSATION_SEARCH_SET_UI_FLAG](state, {
|
||||
isFetching: false,
|
||||
});
|
||||
expect(state.uiFlags.conversation).toEqual({ isFetching: false });
|
||||
});
|
||||
});
|
||||
|
||||
describe('#MESSAGE_SEARCH_SET_UI_FLAG', () => {
|
||||
it('set message search UI flags correctly', () => {
|
||||
const state = {
|
||||
uiFlags: {
|
||||
message: { isFetching: true },
|
||||
},
|
||||
};
|
||||
mutations[types.MESSAGE_SEARCH_SET_UI_FLAG](state, { isFetching: false });
|
||||
expect(state.uiFlags.message).toEqual({ isFetching: false });
|
||||
});
|
||||
});
|
||||
|
||||
describe('#CLEAR_SEARCH_RESULTS', () => {
|
||||
it('should clear all search records', () => {
|
||||
const state = {
|
||||
contactRecords: [{ id: 1 }],
|
||||
conversationRecords: [{ id: 1 }],
|
||||
messageRecords: [{ id: 1 }],
|
||||
};
|
||||
mutations[types.CLEAR_SEARCH_RESULTS](state);
|
||||
expect(state.contactRecords).toEqual([]);
|
||||
expect(state.conversationRecords).toEqual([]);
|
||||
expect(state.messageRecords).toEqual([]);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user