feat: dismiss label suggestions only for 24 hours (#7579)
Co-authored-by: Muhsin Keloth <muhsinkeramam@gmail.com>
This commit is contained in:
@@ -88,47 +88,6 @@ describe('aiMixin', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('gets dismissed conversations', () => {
|
||||
const getSpy = jest.spyOn(LocalStorage, 'get');
|
||||
const setSpy = jest.spyOn(LocalStorage, 'set');
|
||||
|
||||
const accountId = 123;
|
||||
const valueFromStorage = { [accountId]: ['conv1', 'conv2'] };
|
||||
|
||||
// in case key is not initialized
|
||||
getSpy.mockReturnValueOnce(null);
|
||||
wrapper.vm.getDismissedConversations(accountId);
|
||||
|
||||
expect(getSpy).toHaveBeenCalledWith('dismissedLabelSuggestions');
|
||||
expect(setSpy).toHaveBeenCalledWith('dismissedLabelSuggestions', {
|
||||
[accountId]: [],
|
||||
});
|
||||
|
||||
// rest spy
|
||||
getSpy.mockReset();
|
||||
setSpy.mockReset();
|
||||
|
||||
// in case we get the value from storage
|
||||
getSpy.mockReturnValueOnce(valueFromStorage);
|
||||
const result = wrapper.vm.getDismissedConversations(accountId);
|
||||
expect(result).toEqual(valueFromStorage);
|
||||
expect(getSpy).toHaveBeenCalledWith('dismissedLabelSuggestions');
|
||||
expect(setSpy).not.toHaveBeenCalled();
|
||||
|
||||
// rest spy
|
||||
getSpy.mockReset();
|
||||
setSpy.mockReset();
|
||||
|
||||
// in case we get the value from storage but accountId is not present
|
||||
getSpy.mockReturnValueOnce(valueFromStorage);
|
||||
wrapper.vm.getDismissedConversations(234);
|
||||
expect(getSpy).toHaveBeenCalledWith('dismissedLabelSuggestions');
|
||||
expect(setSpy).toHaveBeenCalledWith('dismissedLabelSuggestions', {
|
||||
...valueFromStorage,
|
||||
234: [],
|
||||
});
|
||||
});
|
||||
|
||||
it('cleans labels', () => {
|
||||
const labels = 'label1, label2, label1';
|
||||
expect(wrapper.vm.cleanLabels(labels)).toEqual(['label1', 'label2']);
|
||||
|
||||
Reference in New Issue
Block a user