mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2026-01-27 04:48:14 +00:00
fix: fix composeTitle returns redundant icons
This commit is contained in:
parent
e1864fdf71
commit
ed252fa135
16
.github/workflows/test packages.yml
vendored
16
.github/workflows/test packages.yml
vendored
@ -42,3 +42,19 @@ jobs:
|
|||||||
|
|
||||||
- name: test
|
- name: test
|
||||||
run: cd packages/designer && npm test
|
run: cd packages/designer && npm test
|
||||||
|
|
||||||
|
editor-skeleton:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: checkout
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- uses: actions/setup-node@v2
|
||||||
|
with:
|
||||||
|
node-version: '14'
|
||||||
|
|
||||||
|
- name: install
|
||||||
|
run: npm i && npm run setup:skip-build
|
||||||
|
|
||||||
|
- name: test
|
||||||
|
run: cd packages/editor-skeleton && npm test
|
||||||
9
packages/editor-skeleton/build.test.json
Normal file
9
packages/editor-skeleton/build.test.json
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"plugins": [
|
||||||
|
"build-plugin-component",
|
||||||
|
"@alilc/lowcode-test-mate/plugin/index.ts"
|
||||||
|
],
|
||||||
|
"babelPlugins": [
|
||||||
|
["@babel/plugin-proposal-private-property-in-object", { "loose": true }]
|
||||||
|
]
|
||||||
|
}
|
||||||
29
packages/editor-skeleton/jest.config.js
Normal file
29
packages/editor-skeleton/jest.config.js
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
const fs = require('fs');
|
||||||
|
const { join } = require('path');
|
||||||
|
const esModules = [].join('|');
|
||||||
|
const pkgNames = fs.readdirSync(join('..')).filter(pkgName => !pkgName.startsWith('.'));
|
||||||
|
|
||||||
|
const jestConfig = {
|
||||||
|
// transform: {
|
||||||
|
// '^.+\\.[jt]sx?$': 'babel-jest',
|
||||||
|
// // '^.+\\.(ts|tsx)$': 'ts-jest',
|
||||||
|
// // '^.+\\.(js|jsx)$': 'babel-jest',
|
||||||
|
// },
|
||||||
|
transformIgnorePatterns: [
|
||||||
|
`/node_modules/(?!${esModules})/`,
|
||||||
|
],
|
||||||
|
moduleFileExtensions: ['ts', 'tsx', 'js', 'json'],
|
||||||
|
collectCoverage: false,
|
||||||
|
collectCoverageFrom: [
|
||||||
|
'src/**/*.ts',
|
||||||
|
'!src/**/*.d.ts',
|
||||||
|
'!**/node_modules/**',
|
||||||
|
'!**/vendor/**',
|
||||||
|
],
|
||||||
|
};
|
||||||
|
|
||||||
|
// 只对本仓库内的 pkg 做 mapping
|
||||||
|
jestConfig.moduleNameMapper = {};
|
||||||
|
jestConfig.moduleNameMapper[`^@alilc/lowcode\\-(${pkgNames.join('|')})$`] = '<rootDir>/../$1/src';
|
||||||
|
|
||||||
|
module.exports = jestConfig;
|
||||||
@ -10,6 +10,7 @@
|
|||||||
"es"
|
"es"
|
||||||
],
|
],
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
"test": "build-scripts test --config build.test.json",
|
||||||
"build": "build-scripts build --skip-demo"
|
"build": "build-scripts build --skip-demo"
|
||||||
},
|
},
|
||||||
"keywords": [
|
"keywords": [
|
||||||
|
|||||||
@ -45,7 +45,7 @@ export function composeTitle(title?: IPublicTypeTitleContent, icon?: IPublicType
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (isTitleConfig(_title) && noIcon) {
|
if (isTitleConfig(_title) && noIcon) {
|
||||||
if (!isValidElement(title)) {
|
if (!isValidElement(_title)) {
|
||||||
_title.icon = undefined;
|
_title.icon = undefined;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
54
packages/editor-skeleton/tests/widget/utils.test.ts
Normal file
54
packages/editor-skeleton/tests/widget/utils.test.ts
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
import { composeTitle } from '../../src/widget/utils';
|
||||||
|
import * as React from 'react';
|
||||||
|
|
||||||
|
const label = React.createElement('div');
|
||||||
|
|
||||||
|
describe('composeTitle 测试', () => {
|
||||||
|
it('基础能力测试', () => {
|
||||||
|
expect(composeTitle(undefined)).toEqual({
|
||||||
|
label: undefined,
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(composeTitle(undefined, undefined, 'tips', true, true)).toEqual({
|
||||||
|
icon: undefined,
|
||||||
|
label: 'tips',
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(composeTitle(undefined, undefined, label, true, true)).toEqual({
|
||||||
|
icon: undefined,
|
||||||
|
label,
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(composeTitle({
|
||||||
|
icon: undefined,
|
||||||
|
label,
|
||||||
|
}, undefined, '')).toEqual({
|
||||||
|
icon: undefined,
|
||||||
|
label,
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(composeTitle('settingsPane')).toEqual('settingsPane');
|
||||||
|
|
||||||
|
expect(composeTitle(label, undefined, '物料面板', true, true)).toEqual({
|
||||||
|
icon: undefined,
|
||||||
|
label,
|
||||||
|
tip: '物料面板',
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(composeTitle(label, undefined, label, true, true)).toEqual({
|
||||||
|
icon: undefined,
|
||||||
|
label,
|
||||||
|
tip: label,
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(composeTitle({
|
||||||
|
label: "物料面板",
|
||||||
|
icon: undefined,
|
||||||
|
tip: null,
|
||||||
|
})).toEqual({
|
||||||
|
label: "物料面板",
|
||||||
|
icon: undefined,
|
||||||
|
tip: null,
|
||||||
|
})
|
||||||
|
});
|
||||||
|
})
|
||||||
@ -23,6 +23,9 @@ export interface IPublicTypePanelDockConfig extends IPublicTypeWidgetBaseConfig
|
|||||||
panelProps?: IPublicTypePanelDockPanelProps;
|
panelProps?: IPublicTypePanelDockPanelProps;
|
||||||
|
|
||||||
props?: IPublicTypePanelDockProps;
|
props?: IPublicTypePanelDockProps;
|
||||||
|
|
||||||
|
/** 面板 name, 当没有 props.title 时, 会使用 name 作为标题 */
|
||||||
|
name?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IPublicTypePanelDockProps {
|
export interface IPublicTypePanelDockProps {
|
||||||
@ -32,12 +35,19 @@ export interface IPublicTypePanelDockProps {
|
|||||||
|
|
||||||
className?: string;
|
className?: string;
|
||||||
|
|
||||||
|
/** 详细描述,hover 时在标题上方显示的 tips 内容 */
|
||||||
description?: TipContent;
|
description?: TipContent;
|
||||||
|
|
||||||
onClick?: () => void;
|
onClick?: () => void;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 面板标题前的 icon
|
||||||
|
*/
|
||||||
icon?: IPublicTypeIconType;
|
icon?: IPublicTypeIconType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 面板标题
|
||||||
|
*/
|
||||||
title?: IPublicTypeTitleContent;
|
title?: IPublicTypeTitleContent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user