feat: densify enterprise signature management

This commit is contained in:
hectorzhao
2026-09-02 10:04:58 +08:00
parent 1f2dfb5caf
commit 9e34757d6f
14 changed files with 240 additions and 119 deletions
@@ -0,0 +1,65 @@
import { render, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import { describe, expect, it, vi } from 'vitest';
import type { ClientSmsSignature } from '@/api/adminApi';
import { EnterpriseSignaturesTable } from './EnterpriseSignaturesTable';
const signature = {
id: 'signature-1',
tenantId: 'tenant-1',
applicationId: 'app-1',
name: '【聆界科技】',
auditStatus: 'approved',
createdAt: '2026-09-01T00:00:00.000Z',
updatedAt: '2026-09-01T01:00:00.000Z',
tenant: { id: 'tenant-1', name: '深圳市聆界科技有限公司', status: 'active' },
application: { id: 'app-1', tenantId: 'tenant-1', name: '营销通知应用', status: 'active' },
carrierReportSummary: {
mobile: { status: 'approved', approved: 3, total: 3 },
unicom: { status: 'reporting', approved: 2, total: 3 },
telecom: { status: 'waiting_material', approved: 1, total: 3 },
},
drainageInfo: { links: [{ id: 'drainage-1', siteName: 'www.lisglo.com', url: 'www.lisglo.com', auditStatus: 'approved' }] },
drainageCarrierReportSummary: {
'drainage-1': {
mobile: { status: 'approved', approved: 3, total: 3 },
unicom: { status: 'reporting', approved: 1, total: 3 },
telecom: { status: 'waiting_material', approved: 0, total: 3 },
},
},
} as unknown as ClientSmsSignature;
function renderTable(overrides: Partial<Parameters<typeof EnterpriseSignaturesTable>[0]> = {}) {
const props: Parameters<typeof EnterpriseSignaturesTable>[0] = {
appliedDrainageKeyword: '', currentPage: 1, expandedSignatureId: signature.id,
filteredSignatures: [signature], visibleSignatures: [signature], total: 1, totalPages: 1,
loadData: vi.fn().mockResolvedValue(undefined), setDeleteTarget: vi.fn(), setDrainageModal: vi.fn(),
setDrainageStatusTarget: vi.fn(), setExpandedSignatureId: vi.fn(), setPage: vi.fn(),
setReportStatusTarget: vi.fn(), setSignatureModal: vi.fn(), setSignatureSort: vi.fn(), signatureSort: 'asc',
...overrides,
};
return { ...render(<EnterpriseSignaturesTable {...props} />), props };
}
describe('EnterpriseSignaturesTable dense presentation', () => {
it('uses compact headers, bracketed signatures, channel counts and only the requested row actions', () => {
renderTable();
expect(screen.getByText('【聆界科技】')).toBeVisible();
expect(screen.getAllByText('审核状态')).toHaveLength(2);
expect(screen.queryByText('签名名称')).not.toBeInTheDocument();
expect(screen.queryByText('签名审核')).not.toBeInTheDocument();
expect(screen.queryByText('报备详情')).not.toBeInTheDocument();
expect(screen.getAllByLabelText('已报备通过3个,总通道数3个')).toHaveLength(2);
expect(screen.getByLabelText('已报备通过2个,总通道数3个')).toHaveTextContent('2/3');
expect(screen.getAllByRole('button', { name: '报备状态' })).toHaveLength(2);
expect(screen.getAllByRole('button', { name: '编辑' })).toHaveLength(2);
expect(screen.getAllByRole('button', { name: '删除' })).toHaveLength(2);
});
it('requests a real descending sort from the signature column control', async () => {
const setSignatureSort = vi.fn();
renderTable({ expandedSignatureId: '', setSignatureSort });
await userEvent.click(screen.getByRole('button', { name: '签名降序' }));
expect(setSignatureSort).toHaveBeenCalledWith('desc');
});
});