471d7843de
- 公共表格:统一分组标签、状态开关和危险操作确认,支持防重复提交和失败重试,修复浮层触发组件的 ref 转发。 - 控制台:统一用户和渠道编辑抽屉,修正分组回填与提交格式,对齐系统设置操作区和预约列表。 - 企业中心:调整技能中心页签和窄屏布局,优化质量监控提示栏、效能分析及成本对账,统一消耗明细和审计日志筛选。 - 用户中心及公共页面:优化密钥和消费记录展示,对齐模型超市筛选,统一公开与内嵌客户端下载页。 - 同步多语言文案、组件规范与移动端视口要求。
73 lines
2.2 KiB
JavaScript
73 lines
2.2 KiB
JavaScript
import assert from 'node:assert/strict';
|
|
import test from 'node:test';
|
|
import React from 'react';
|
|
import { loadFrontendModule } from './frontend-module.js';
|
|
|
|
const { default: TableStatusSwitch } = await loadFrontendModule(
|
|
new URL(
|
|
'../../src/components/common/table/TableStatusSwitch.jsx',
|
|
import.meta.url,
|
|
),
|
|
{
|
|
react: React,
|
|
antd: { Switch: 'mock-switch' },
|
|
'react-i18next': { useTranslation: () => ({ t: (key) => key }) },
|
|
},
|
|
);
|
|
const { default: TableGroupTags, TableGroupTag } = await loadFrontendModule(
|
|
new URL(
|
|
'../../src/components/common/table/TableGroupTags.jsx',
|
|
import.meta.url,
|
|
),
|
|
{ react: React, antd: { Tag: 'mock-tag' }, './table-group-tags.css': {} },
|
|
);
|
|
|
|
test('table switches share a compact appearance without replacing row actions', () => {
|
|
const onChange = () => {};
|
|
const ref = React.createRef();
|
|
const { props, ref: switchRef } = TableStatusSwitch.render(
|
|
{
|
|
checked: false,
|
|
size: 'large',
|
|
disabled: true,
|
|
loading: true,
|
|
onChange,
|
|
},
|
|
ref,
|
|
);
|
|
assert.equal(switchRef, ref);
|
|
assert.equal(props.size, 'small');
|
|
assert.equal(props.checkedChildren, '启用');
|
|
assert.equal(props.unCheckedChildren, '禁用');
|
|
assert.equal(props.checked, false);
|
|
assert.equal(props.disabled, true);
|
|
assert.equal(props.loading, true);
|
|
assert.equal(props.onChange, onChange);
|
|
assert.equal(
|
|
TableStatusSwitch.render({ checkedChildren: '是' }, null).props
|
|
.checkedChildren,
|
|
'是',
|
|
);
|
|
});
|
|
|
|
test('single and multiple groups use one outlined color mapping', () => {
|
|
const { props } = TableGroupTags({
|
|
groups: ['default, svip', ' vip ', 'default', 'custom', ''],
|
|
});
|
|
const tags = Array.from(
|
|
props.children,
|
|
(child) => TableGroupTag(child.props).props,
|
|
);
|
|
assert.deepEqual(
|
|
tags.map((tag) => tag.children),
|
|
['default', 'svip', 'vip', 'custom'],
|
|
);
|
|
assert.deepEqual(
|
|
tags.map((tag) => tag.color),
|
|
['blue', 'red', 'yellow', 'default'],
|
|
);
|
|
assert.ok(tags.every((tag) => tag.variant === 'outlined'));
|
|
assert.equal(TableGroupTag({ group: 'VIP' }).props.color, 'yellow');
|
|
assert.equal(TableGroupTags({ groups: null, empty: 'fallback' }), 'fallback');
|
|
});
|