## Description Adds the account-level `unread_count_for_filters` feature flag as the dark-launch gate for filtered sidebar unread counts. This reuses the deprecated `quoted_email_reply` flag slot, resets the reused bit for existing accounts, and removes stale defaults so new accounts do not reference the old flag. This also adds the feature where we are now calculating the unread counts for built in filters like mentions, participating and unattended along with unread count for saved filters/folders. Closes [CW-7262](https://linear.app/chatwoot/issue/CW-7262/unread-counts-for-filters-folders) ## Type of change - [ ] Bug fix (non-breaking change which fixes an issue) - [x] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality not to work as expected) - [ ] This change requires a documentation update
59 lines
1.4 KiB
JavaScript
59 lines
1.4 KiB
JavaScript
import axios from 'axios';
|
|
import { actions } from '../../conversationUnreadCounts';
|
|
import types from '../../../mutation-types';
|
|
|
|
const commit = vi.fn();
|
|
global.axios = axios;
|
|
vi.mock('axios');
|
|
|
|
describe('#actions', () => {
|
|
beforeEach(() => {
|
|
commit.mockClear();
|
|
axios.get.mockReset();
|
|
});
|
|
|
|
describe('#get', () => {
|
|
it('commits unread counts when API is successful', async () => {
|
|
const payload = {
|
|
all_count: 2,
|
|
inboxes: { 1: '2' },
|
|
labels: { 3: 4 },
|
|
teams: { 5: 6 },
|
|
mentions_count: 7,
|
|
participating_count: 8,
|
|
unattended_count: 9,
|
|
folders: { 10: 11 },
|
|
};
|
|
axios.get.mockResolvedValue({ data: { payload } });
|
|
|
|
await actions.get({ commit });
|
|
|
|
expect(axios.get).toHaveBeenCalledWith(
|
|
'/api/v1/conversations/unread_counts'
|
|
);
|
|
expect(commit.mock.calls).toEqual([
|
|
[types.SET_CONVERSATION_UNREAD_COUNTS, payload],
|
|
]);
|
|
});
|
|
|
|
it('does not commit when API fails', async () => {
|
|
axios.get.mockRejectedValue({ message: 'Incorrect header' });
|
|
|
|
await actions.get({ commit });
|
|
|
|
expect(commit).not.toHaveBeenCalled();
|
|
});
|
|
});
|
|
|
|
describe('#clear', () => {
|
|
it('clears unread counts', () => {
|
|
actions.clear({ commit });
|
|
|
|
expect(commit).toHaveBeenCalledWith(
|
|
types.SET_CONVERSATION_UNREAD_COUNTS,
|
|
{}
|
|
);
|
|
});
|
|
});
|
|
});
|