Files
chatwoot/app/javascript/dashboard/store/modules/specs/conversationUnreadCounts/actions.spec.js
T
Sony MathewandGitHub 87df43bdd0 revert: restore conversation unread count feature flag (#14623)
This reverts #14610 so conversation unread counts are again controlled
by the `conversation_unread_counts` feature flag across the API,
ActionCable broadcasts, notifier/listener paths, and dashboard sidebar
fetching.

## Closes
- None

## What changed
- Restores feature-flag checks for conversation unread count reads and
broadcasts.
- Restores the dashboard feature flag constant and sidebar/store
behavior for disabled unread counts.
- Restores the specs that cover disabled-feature behavior.

## How to test
- In an account with `conversation_unread_counts` enabled, verify
sidebar unread counts are fetched and updated in real time.
- Disable `conversation_unread_counts` for the account and verify unread
count requests/broadcasts are skipped.
2026-06-02 21:11:48 +05:30

54 lines
1.3 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 = {
inboxes: { 1: '2' },
labels: { 3: 4 },
teams: { 5: 6 },
};
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,
{}
);
});
});
});