forked from wangziqi/gongxue-base
feat: 为批量归档补充批量恢复
This commit is contained in:
58
apps/admin/src/pages/archive-view.integration.test.ts
Normal file
58
apps/admin/src/pages/archive-view.integration.test.ts
Normal file
@@ -0,0 +1,58 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import {
|
||||
archiveViewPolicy,
|
||||
expenseStatusForView,
|
||||
occupancyParamsForView,
|
||||
occupancyViewPolicy,
|
||||
selectArchiveRecords,
|
||||
shouldClearSelectionOnViewChange,
|
||||
} from './archive-view';
|
||||
|
||||
describe('归档数据视图', () => {
|
||||
it('正常视图与归档视图不会混合记录', () => {
|
||||
const records = [
|
||||
{ id: 1, status: 'active' },
|
||||
{ id: 2, status: 'graduated' },
|
||||
{ id: 3, status: 'archived' },
|
||||
];
|
||||
|
||||
expect(selectArchiveRecords(records, 'active').map((item) => item.id)).toEqual([1, 2]);
|
||||
expect(selectArchiveRecords(records, 'archived').map((item) => item.id)).toEqual([3]);
|
||||
});
|
||||
|
||||
it('费用视图映射为后端 status 查询', () => {
|
||||
expect(expenseStatusForView('active')).toBe('active');
|
||||
expect(expenseStatusForView('archived')).toBe('archived');
|
||||
});
|
||||
|
||||
it('入住三态分别映射为在住、全部活动记录和归档记录', () => {
|
||||
expect(occupancyParamsForView('active')).toEqual({ active: 'true', status: 'active' });
|
||||
expect(occupancyParamsForView('all')).toEqual({ active: undefined, status: 'active' });
|
||||
expect(occupancyParamsForView('archived')).toEqual({
|
||||
active: undefined,
|
||||
status: 'archived',
|
||||
});
|
||||
});
|
||||
|
||||
it('正常与归档视图的批量动作互斥,且归档视图只读', () => {
|
||||
expect(archiveViewPolicy('active')).toEqual({ batchAction: 'archive', readonly: false });
|
||||
expect(archiveViewPolicy('archived')).toEqual({ batchAction: 'restore', readonly: true });
|
||||
});
|
||||
|
||||
it('入住三态分别只提供退宿、归档和恢复动作', () => {
|
||||
expect(occupancyViewPolicy('active')).toEqual({
|
||||
batchAction: 'checkout',
|
||||
readonly: false,
|
||||
});
|
||||
expect(occupancyViewPolicy('all')).toEqual({ batchAction: 'archive', readonly: false });
|
||||
expect(occupancyViewPolicy('archived')).toEqual({
|
||||
batchAction: 'restore',
|
||||
readonly: true,
|
||||
});
|
||||
});
|
||||
|
||||
it('只有实际切换视图时才要求清空选择', () => {
|
||||
expect(shouldClearSelectionOnViewChange('active', 'archived')).toBe(true);
|
||||
expect(shouldClearSelectionOnViewChange('archived', 'archived')).toBe(false);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user