agent-list-mock.test.ts
1.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import { describe, expect, it } from 'vitest';
import {
agentListMockFixtures,
agentPositionOptions,
getAgentListPage,
sortAgentsForDisplay,
} from './agent-list-mock';
describe('agent list mock contract', () => {
it('provides the minimal page-facing fields and stable position options', () => {
const [agent] = agentListMockFixtures.normal.items;
expect(agent).toMatchObject({
agent_id: expect.any(Number),
name: expect.any(String),
is_manager: expect.any(Boolean),
positions: expect.any(Array),
status: expect.stringMatching(/enable|disable/),
bound_group_count: expect.any(Number),
bound_skill_count: expect.any(Number),
updated_at: expect.any(String),
available_actions: expect.any(Array),
});
expect(agentPositionOptions[0]).toEqual({ id: 'sales', name: '驻店销售岗' });
});
it('covers required page state fixtures without a backend service', () => {
expect(Object.keys(agentListMockFixtures).sort()).toEqual([
'disabledActions',
'empty',
'error',
'filteredEmpty',
'loading',
'longText',
'managerOnly',
'normal',
'paginationBoundary',
]);
});
it('keeps manager agents visible and sorted before ordinary agents', () => {
const sorted = sortAgentsForDisplay(agentListMockFixtures.normal.items);
expect(sorted[0].is_manager).toBe(true);
expect(sorted[0].positions).toEqual([]);
});
it('filters and paginates mock data from page-facing query fields', () => {
const result = getAgentListPage({ keyword: '复盘', positionId: 'sales', status: 'enable', page: 1, pageSize: 10 });
expect(result.total).toBe(1);
expect(result.items[0].name).toBe('复盘Agent');
});
});