mirror of
https://github.com/lingble/chatwoot.git
synced 2025-10-31 19:17:48 +00:00
# Pull Request Template ## Description This PR includes a translation update for the "None" option in the agent assignment multi-select dropdown. Fixes https://linear.app/chatwoot/issue/CW-4140/none-option-in-assign-agent-multi-select-is-not-translated ## Type of change - [x] Bug fix (non-breaking change which fixes an issue) ## How Has This Been Tested? **Test cases** 1. Check in conversation sidebar 2. Check in command bar 3. Check in participation dropdown ## Checklist: - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my code - [x] I have commented on my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [x] I have added tests that prove my fix is effective or that my feature works - [x] New and existing unit tests pass locally with my changes - [ ] Any dependent changes have been merged and published in downstream modules
95 lines
2.6 KiB
JavaScript
95 lines
2.6 KiB
JavaScript
import {
|
|
getAgentsByAvailability,
|
|
getSortedAgentsByAvailability,
|
|
getAgentsByUpdatedPresence,
|
|
} from '../agentHelper';
|
|
import {
|
|
allAgentsData,
|
|
onlineAgentsData,
|
|
busyAgentsData,
|
|
offlineAgentsData,
|
|
sortedByAvailability,
|
|
formattedAgentsByPresenceOnline,
|
|
formattedAgentsByPresenceOffline,
|
|
} from 'dashboard/helper/specs/fixtures/agentFixtures';
|
|
|
|
describe('agentHelper', () => {
|
|
describe('getAgentsByAvailability', () => {
|
|
it('returns agents by availability', () => {
|
|
expect(getAgentsByAvailability(allAgentsData, 'online')).toEqual(
|
|
onlineAgentsData
|
|
);
|
|
expect(getAgentsByAvailability(allAgentsData, 'busy')).toEqual(
|
|
busyAgentsData
|
|
);
|
|
expect(getAgentsByAvailability(allAgentsData, 'offline')).toEqual(
|
|
offlineAgentsData
|
|
);
|
|
});
|
|
});
|
|
|
|
describe('getSortedAgentsByAvailability', () => {
|
|
it('returns sorted agents by availability', () => {
|
|
expect(getSortedAgentsByAvailability(allAgentsData)).toEqual(
|
|
sortedByAvailability
|
|
);
|
|
});
|
|
|
|
it('returns an empty array when given an empty input', () => {
|
|
expect(getSortedAgentsByAvailability([])).toEqual([]);
|
|
});
|
|
|
|
it('maintains the order of agents with the same availability status', () => {
|
|
const result = getSortedAgentsByAvailability(allAgentsData);
|
|
expect(result[2].name).toBe('Honey Bee');
|
|
expect(result[3].name).toBe('Samuel Keta');
|
|
});
|
|
});
|
|
|
|
describe('getAgentsByUpdatedPresence', () => {
|
|
it('returns agents with updated presence', () => {
|
|
const currentUser = {
|
|
id: 1,
|
|
accounts: [{ id: 1, availability_status: 'offline' }],
|
|
};
|
|
const currentAccountId = 1;
|
|
|
|
expect(
|
|
getAgentsByUpdatedPresence(
|
|
formattedAgentsByPresenceOnline,
|
|
currentUser,
|
|
currentAccountId
|
|
)
|
|
).toEqual(formattedAgentsByPresenceOffline);
|
|
});
|
|
|
|
it('does not modify other agents presence', () => {
|
|
const currentUser = {
|
|
id: 2,
|
|
accounts: [{ id: 1, availability_status: 'offline' }],
|
|
};
|
|
const currentAccountId = 1;
|
|
|
|
expect(
|
|
getAgentsByUpdatedPresence(
|
|
formattedAgentsByPresenceOnline,
|
|
currentUser,
|
|
currentAccountId
|
|
)
|
|
).toEqual(formattedAgentsByPresenceOnline);
|
|
});
|
|
|
|
it('handles empty agent list', () => {
|
|
const currentUser = {
|
|
id: 1,
|
|
accounts: [{ id: 1, availability_status: 'offline' }],
|
|
};
|
|
const currentAccountId = 1;
|
|
|
|
expect(
|
|
getAgentsByUpdatedPresence([], currentUser, currentAccountId)
|
|
).toEqual([]);
|
|
});
|
|
});
|
|
});
|