Some checks failed
Lock Threads / action (push) Has been cancelled
Mark stale issues and pull requests / stale (push) Has been cancelled
Publish Chatwoot EE docker images / build (linux/amd64, ubuntu-latest) (push) Has been cancelled
Publish Chatwoot EE docker images / build (linux/arm64, ubuntu-22.04-arm) (push) Has been cancelled
Publish Chatwoot EE docker images / merge (push) Has been cancelled
Publish Chatwoot CE docker images / build (linux/amd64, ubuntu-latest) (push) Has been cancelled
Publish Chatwoot CE docker images / build (linux/arm64, ubuntu-22.04-arm) (push) Has been cancelled
Publish Chatwoot CE docker images / merge (push) Has been cancelled
Run Chatwoot CE spec / lint-backend (push) Has been cancelled
Run Chatwoot CE spec / lint-frontend (push) Has been cancelled
Run Chatwoot CE spec / frontend-tests (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (0, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (1, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (10, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (11, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (12, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (13, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (14, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (15, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (2, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (3, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (4, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (5, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (6, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (7, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (8, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (9, 16) (push) Has been cancelled
Run Linux nightly installer / nightly (push) Has been cancelled
- Add Logistics component with progress tracking - Add OrderDetail component for order information - Support data-driven steps and actions - Add blue color scale to widget SCSS - Fix node overflow and progress bar rendering issues - Add English translations for dashboard components Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
99 lines
3.2 KiB
JavaScript
99 lines
3.2 KiB
JavaScript
import agentCapacityPolicies from '../agentCapacityPolicies';
|
|
import ApiClient from '../ApiClient';
|
|
|
|
describe('#AgentCapacityPoliciesAPI', () => {
|
|
it('creates correct instance', () => {
|
|
expect(agentCapacityPolicies).toBeInstanceOf(ApiClient);
|
|
expect(agentCapacityPolicies).toHaveProperty('get');
|
|
expect(agentCapacityPolicies).toHaveProperty('show');
|
|
expect(agentCapacityPolicies).toHaveProperty('create');
|
|
expect(agentCapacityPolicies).toHaveProperty('update');
|
|
expect(agentCapacityPolicies).toHaveProperty('delete');
|
|
expect(agentCapacityPolicies).toHaveProperty('getUsers');
|
|
expect(agentCapacityPolicies).toHaveProperty('addUser');
|
|
expect(agentCapacityPolicies).toHaveProperty('removeUser');
|
|
expect(agentCapacityPolicies).toHaveProperty('createInboxLimit');
|
|
expect(agentCapacityPolicies).toHaveProperty('updateInboxLimit');
|
|
expect(agentCapacityPolicies).toHaveProperty('deleteInboxLimit');
|
|
});
|
|
|
|
describe('API calls', () => {
|
|
const originalAxios = window.axios;
|
|
const axiosMock = {
|
|
get: vi.fn(() => Promise.resolve()),
|
|
post: vi.fn(() => Promise.resolve()),
|
|
put: vi.fn(() => Promise.resolve()),
|
|
delete: vi.fn(() => Promise.resolve()),
|
|
};
|
|
|
|
beforeEach(() => {
|
|
window.axios = axiosMock;
|
|
// Mock accountIdFromRoute
|
|
Object.defineProperty(agentCapacityPolicies, 'accountIdFromRoute', {
|
|
get: () => '1',
|
|
configurable: true,
|
|
});
|
|
});
|
|
|
|
afterEach(() => {
|
|
window.axios = originalAxios;
|
|
});
|
|
|
|
it('#getUsers', () => {
|
|
agentCapacityPolicies.getUsers(123);
|
|
expect(axiosMock.get).toHaveBeenCalledWith(
|
|
'/api/v1/accounts/1/agent_capacity_policies/123/users'
|
|
);
|
|
});
|
|
|
|
it('#addUser', () => {
|
|
const userData = { id: 456, capacity: 20 };
|
|
agentCapacityPolicies.addUser(123, userData);
|
|
expect(axiosMock.post).toHaveBeenCalledWith(
|
|
'/api/v1/accounts/1/agent_capacity_policies/123/users',
|
|
{
|
|
user_id: 456,
|
|
capacity: 20,
|
|
}
|
|
);
|
|
});
|
|
|
|
it('#removeUser', () => {
|
|
agentCapacityPolicies.removeUser(123, 456);
|
|
expect(axiosMock.delete).toHaveBeenCalledWith(
|
|
'/api/v1/accounts/1/agent_capacity_policies/123/users/456'
|
|
);
|
|
});
|
|
|
|
it('#createInboxLimit', () => {
|
|
const limitData = { inboxId: 1, conversationLimit: 10 };
|
|
agentCapacityPolicies.createInboxLimit(123, limitData);
|
|
expect(axiosMock.post).toHaveBeenCalledWith(
|
|
'/api/v1/accounts/1/agent_capacity_policies/123/inbox_limits',
|
|
{
|
|
inbox_id: 1,
|
|
conversation_limit: 10,
|
|
}
|
|
);
|
|
});
|
|
|
|
it('#updateInboxLimit', () => {
|
|
const limitData = { conversationLimit: 15 };
|
|
agentCapacityPolicies.updateInboxLimit(123, 789, limitData);
|
|
expect(axiosMock.put).toHaveBeenCalledWith(
|
|
'/api/v1/accounts/1/agent_capacity_policies/123/inbox_limits/789',
|
|
{
|
|
conversation_limit: 15,
|
|
}
|
|
);
|
|
});
|
|
|
|
it('#deleteInboxLimit', () => {
|
|
agentCapacityPolicies.deleteInboxLimit(123, 789);
|
|
expect(axiosMock.delete).toHaveBeenCalledWith(
|
|
'/api/v1/accounts/1/agent_capacity_policies/123/inbox_limits/789'
|
|
);
|
|
});
|
|
});
|
|
});
|