feat: 参考原型图 ui优化提交 企业端-企业中心 相关的页面
This commit is contained in:
@@ -45,3 +45,10 @@ test('cloud brain organization routes and modules are centrally classified', ()
|
||||
assert.equal(isCloudBrainOrgPath('/org/effectiveness'), true);
|
||||
assert.equal(isCloudBrainOrgPath('/org/members'), false);
|
||||
});
|
||||
|
||||
test('member capabilities are gated by the cloud brain UI flag', () => {
|
||||
assert.equal(isCloudBrainOrgModule('mySkills'), true);
|
||||
assert.equal(isCloudBrainOrgPath('/org/my-capabilities'), true);
|
||||
assert.equal(isCloudBrainOrgModule('myConnectors'), true);
|
||||
assert.equal(isCloudBrainOrgPath('/org/connectors'), true);
|
||||
});
|
||||
|
||||
@@ -21,6 +21,12 @@ import assert from 'node:assert/strict';
|
||||
import { readFileSync } from 'node:fs';
|
||||
import test from 'node:test';
|
||||
import postcss from 'postcss';
|
||||
import { readFile } from 'node:fs/promises';
|
||||
import { runInNewContext } from 'node:vm';
|
||||
import React from 'react';
|
||||
import { renderToStaticMarkup } from 'react-dom/server';
|
||||
import * as Ant from 'antd';
|
||||
import { transformWithEsbuild } from 'vite';
|
||||
|
||||
const css = readFileSync(new URL('../src/styles/prototype.css', import.meta.url), 'utf8');
|
||||
const root = postcss.parse(css);
|
||||
@@ -81,3 +87,64 @@ test('headerless viewport previews override standard body overflow', () => {
|
||||
{ maxWidth: 'none', overflowX: 'visible', overflowY: 'visible' },
|
||||
);
|
||||
});
|
||||
|
||||
const file = new URL('../src/components/ui/form.jsx', import.meta.url);
|
||||
const { code } = await transformWithEsbuild(await readFile(file, 'utf8'), file.pathname, {
|
||||
loader: 'jsx', format: 'cjs', jsx: 'transform',
|
||||
});
|
||||
const module = { exports: {} };
|
||||
runInNewContext(code, {
|
||||
module, exports: module.exports,
|
||||
require(name) {
|
||||
if (name === 'react') return React;
|
||||
if (name === 'antd') return Ant;
|
||||
if (name === './controls') return Object.fromEntries(
|
||||
['Input', 'TextArea', 'InputNumber', 'Select', 'DatePicker', 'TimePicker', 'RadioGroup', 'CheckboxGroup', 'TagInput', 'TreeSelect', 'AutoComplete', 'Upload', 'Switch'].map(key => [key, Ant.Input]),
|
||||
);
|
||||
throw new Error(`Unexpected dependency: ${name}`);
|
||||
},
|
||||
});
|
||||
const { Form } = module.exports;
|
||||
const render = (props) => renderToStaticMarkup(
|
||||
React.createElement(Form, { labelPosition: 'left', ...props },
|
||||
React.createElement(Form.Input, { field: 'sample', label: 'Setting label' })),
|
||||
);
|
||||
|
||||
for (const [width, css] of [[180, '180px'], ['120px', '120px'], ['25%', '25%']]) {
|
||||
test(`form label width ${width} keeps its unit and cannot grow across the row`, () => {
|
||||
const html = render({ labelWidth: width });
|
||||
assert.ok(html.includes(`flex:0 0 ${css}`));
|
||||
assert.ok(html.includes('flex:1 1 0'));
|
||||
});
|
||||
}
|
||||
test('explicit Ant Design column settings take precedence over legacy labelWidth', () => {
|
||||
const html = render({ labelWidth: 180, labelCol: { flex: '0 0 96px' }, wrapperCol: { flex: '1 1 240px' } });
|
||||
assert.ok(html.includes('flex:0 0 96px'));
|
||||
assert.ok(html.includes('flex:1 1 240px'));
|
||||
assert.ok(!html.includes('flex:0 0 180px'));
|
||||
});
|
||||
test('vertical forms without label widths keep the default Ant layout', () => {
|
||||
const html = render({ labelPosition: 'top' });
|
||||
assert.match(html, /ant-form-vertical/);
|
||||
assert.ok(!html.includes('flex:0 0'));
|
||||
});
|
||||
|
||||
const stylesheet = postcss.parse(await readFile(new URL('../src/pages/Setting/Setting.css', import.meta.url), 'utf8'));
|
||||
test('settings labels stack on narrow screens without overriding inline flex declarations', () => {
|
||||
let mobileRule;
|
||||
stylesheet.walkRules(rule => {
|
||||
if (rule.selectors.includes('.settings-page .ant-form-horizontal .ant-form-item-row')) mobileRule = rule;
|
||||
});
|
||||
assert.ok(mobileRule.selectors.includes('.settings-form-dialog .ant-form-horizontal .ant-form-item-row'));
|
||||
assert.match(mobileRule.parent.params, /max-width: 767px/);
|
||||
assert.ok(mobileRule.nodes.some(node => node.prop === 'display' && node.value === 'block'));
|
||||
});
|
||||
test('settings layout rules stay scoped and use the existing scrollbar policy', () => {
|
||||
stylesheet.walkRules(rule => {
|
||||
assert.ok(rule.selectors.every(selector => selector.startsWith('.settings-page') || selector.startsWith('.settings-form-dialog')));
|
||||
rule.walkDecls(decl => {
|
||||
assert.equal(Boolean(decl.important), false);
|
||||
assert.ok(!['scrollbar-width', 'scrollbar-color'].includes(decl.prop));
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -23,6 +23,9 @@ import { paginationEvents } from '../src/components/ui/pagination.js';
|
||||
import test from 'node:test';
|
||||
import { runInNewContext } from 'node:vm';
|
||||
import React from 'react';
|
||||
import { renderToStaticMarkup } from 'react-dom/server';
|
||||
import * as Ant from 'antd';
|
||||
import * as pagination from '../src/components/ui/pagination.js';
|
||||
import { transformWithEsbuild } from 'vite';
|
||||
|
||||
async function compile(relativePath) {
|
||||
@@ -156,3 +159,56 @@ for (const isMobile of [false, true]) {
|
||||
assert.deepEqual(calls, [['page', 2]]);
|
||||
});
|
||||
}
|
||||
|
||||
const loadUi = await compile('../src/components/ui/index.jsx');
|
||||
const { Table, Pagination } = loadUi({
|
||||
react: React,
|
||||
antd: Ant,
|
||||
'./controls': { controlSize: (size) => size },
|
||||
'./pagination': pagination,
|
||||
'./overlayPolicy': {},
|
||||
'./form': {},
|
||||
'./chat': {},
|
||||
});
|
||||
|
||||
for (const [name, render] of [
|
||||
[
|
||||
'Table',
|
||||
(props) =>
|
||||
Table({
|
||||
columns: [{ title: 'Model', dataIndex: 'model' }],
|
||||
dataSource: [{ key: '1', model: 'test-model' }],
|
||||
pagination: props,
|
||||
}),
|
||||
],
|
||||
['Pagination', (props) => Pagination(props)],
|
||||
]) {
|
||||
test(`${name} renders legacy boolean showTotal without crashing`, () => {
|
||||
const element = render({ total: 25, pageSize: 10, showTotal: true });
|
||||
const html = renderToStaticMarkup(element);
|
||||
assert.match(html, /class="ant-pagination-total-text">25<\/li>/);
|
||||
});
|
||||
|
||||
test(`${name} preserves a custom total renderer and its range arguments`, () => {
|
||||
const showTotal = (total, range) => `${range.join('-')} of ${total}`;
|
||||
const element = render({ total: 25, pageSize: 10, showTotal });
|
||||
const props = name === 'Table' ? element.props.pagination : element.props;
|
||||
assert.equal(props.showTotal, showTotal);
|
||||
assert.match(renderToStaticMarkup(element), /1-10 of 25/);
|
||||
});
|
||||
|
||||
for (const showTotal of [false, undefined]) {
|
||||
test(`${name} hides the total when showTotal is ${showTotal}`, () => {
|
||||
const html = renderToStaticMarkup(
|
||||
render({ total: 25, pageSize: 10, showTotal }),
|
||||
);
|
||||
assert.doesNotMatch(html, /ant-pagination-total-text/);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
test('Table keeps pagination disabled for settings tables without pagination', () => {
|
||||
const element = Table({ columns: [], dataSource: [], pagination: false });
|
||||
assert.equal(element.props.pagination, false);
|
||||
assert.doesNotMatch(renderToStaticMarkup(element), /ant-pagination/);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user