fix: e2e-failed (#3828)
* fix: e2e-failed * fix: ci * fix: ci bug * fix: ci(skip server ci) * fix: ci [skip ci] * fix: ci(skip server ci) * fix: ci * fix: ci * fix: remove skip if --------- Co-authored-by: dream2023 <1098626505@qq.com>
This commit is contained in:
parent
78697e02be
commit
d04a60d386
8
.github/workflows/nocobase-test-backend.yml
vendored
8
.github/workflows/nocobase-test-backend.yml
vendored
@ -13,6 +13,8 @@ on:
|
||||
- 'packages/core/acl/**'
|
||||
- 'packages/core/actions/**'
|
||||
- 'packages/core/database/**'
|
||||
- 'packages/core/resourcer/**'
|
||||
- 'packages/core/data-source-manager/**'
|
||||
- 'packages/core/server/**'
|
||||
- 'packages/core/utils/**'
|
||||
- 'packages/plugins/**/src/server/**'
|
||||
@ -23,6 +25,8 @@ on:
|
||||
- 'packages/core/acl/**'
|
||||
- 'packages/core/actions/**'
|
||||
- 'packages/core/database/**'
|
||||
- 'packages/core/resourcer/**'
|
||||
- 'packages/core/data-source-manager/**'
|
||||
- 'packages/core/server/**'
|
||||
- 'packages/core/utils/**'
|
||||
- 'packages/plugins/**/src/server/**'
|
||||
@ -30,7 +34,6 @@ on:
|
||||
|
||||
jobs:
|
||||
sqlite-test:
|
||||
if: "!contains(github.event.head_commit.message, 'skip server ci'))"
|
||||
strategy:
|
||||
matrix:
|
||||
node_version: ['18']
|
||||
@ -68,7 +71,6 @@ jobs:
|
||||
timeout-minutes: 40
|
||||
|
||||
postgres-test:
|
||||
if: "!contains(github.event.head_commit.message, 'skip server ci'))"
|
||||
strategy:
|
||||
matrix:
|
||||
node_version: ['18']
|
||||
@ -133,7 +135,6 @@ jobs:
|
||||
timeout-minutes: 40
|
||||
|
||||
mysql-test:
|
||||
if: "!contains(github.event.head_commit.message, 'skip server ci'))"
|
||||
strategy:
|
||||
matrix:
|
||||
node_version: ['18']
|
||||
@ -184,7 +185,6 @@ jobs:
|
||||
DB_TEST_PREFIX: test_
|
||||
timeout-minutes: 40
|
||||
mariadb-test:
|
||||
if: "!contains(github.event.head_commit.message, 'skip server ci'))"
|
||||
strategy:
|
||||
matrix:
|
||||
node_version: ['18']
|
||||
|
1
.github/workflows/nocobase-test-e2e.yml
vendored
1
.github/workflows/nocobase-test-e2e.yml
vendored
@ -21,7 +21,6 @@ on:
|
||||
|
||||
jobs:
|
||||
e2e-test-postgres:
|
||||
if: "!contains(github.event.head_commit.message, 'skip e2e ci'))"
|
||||
strategy:
|
||||
matrix:
|
||||
node_version: ['18']
|
||||
|
1
.github/workflows/nocobase-test-frontend.yml
vendored
1
.github/workflows/nocobase-test-frontend.yml
vendored
@ -29,7 +29,6 @@ on:
|
||||
|
||||
jobs:
|
||||
frontend-test:
|
||||
if: "!contains(github.event.head_commit.message, 'skip client ci'))"
|
||||
strategy:
|
||||
matrix:
|
||||
node_version: [ '18' ]
|
||||
|
@ -2,9 +2,9 @@ import { isValid } from '@formily/shared';
|
||||
import { toFixedByStep } from '@nocobase/utils/client';
|
||||
import type { InputProps } from 'antd/es/input';
|
||||
import type { InputNumberProps } from 'antd/es/input-number';
|
||||
import { format } from 'd3-format';
|
||||
import * as math from 'mathjs';
|
||||
import React, { useMemo } from 'react';
|
||||
import { format } from 'd3-format';
|
||||
|
||||
function countDecimalPlaces(value) {
|
||||
const number = Number(value);
|
||||
@ -20,7 +20,7 @@ const separators = {
|
||||
'0.00': { thousands: '', decimal: '.' }, // 没有千位分隔符
|
||||
};
|
||||
//分隔符换算
|
||||
export function formatNumberWithSeparator(number, format = '0,0.00', step = 1) {
|
||||
export function formatNumberWithSeparator(number, format = '0.00', step = 1) {
|
||||
let formattedNumber = '';
|
||||
|
||||
if (separators[format]) {
|
||||
@ -84,11 +84,14 @@ export function scientificNotation(number, decimalPlaces, separator = '.') {
|
||||
|
||||
return result;
|
||||
}
|
||||
export const ReadPretty: React.FC<InputProps & InputNumberProps> = (props: any) => {
|
||||
const { step, formatStyle, value, addonBefore, addonAfter, unitConversion, unitConversionType, separator } = props;
|
||||
if (!isValid(props.value)) {
|
||||
|
||||
export function formatNumber(props) {
|
||||
const { step, formatStyle, value, unitConversion, unitConversionType, separator = '0.00' } = props;
|
||||
|
||||
if (!isValid(value)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
//单位换算
|
||||
const unitData = formatUnitConversion(value, unitConversionType, unitConversion);
|
||||
//精度换算
|
||||
@ -100,10 +103,20 @@ export const ReadPretty: React.FC<InputProps & InputNumberProps> = (props: any)
|
||||
//科学计数显示
|
||||
result = scientificNotation(Number(unitData), countDecimalPlaces(step), separators?.[separator]?.['decimal']);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
if (!result) {
|
||||
export const ReadPretty: React.FC<InputProps & InputNumberProps> = (props: any) => {
|
||||
const { step, formatStyle, value, addonBefore, addonAfter, unitConversion, unitConversionType, separator } = props;
|
||||
|
||||
const result = useMemo(() => {
|
||||
return formatNumber({ step, formatStyle, value, unitConversion, unitConversionType, separator });
|
||||
}, [step, formatStyle, value, unitConversion, unitConversionType, separator]);
|
||||
|
||||
if (!isValid(result)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<div className={'nb-read-pretty-input-number'}>
|
||||
{addonBefore}
|
||||
|
@ -1,9 +1,9 @@
|
||||
import { fireEvent, render, screen } from '@nocobase/test/client';
|
||||
import React from 'react';
|
||||
import { formatNumberWithSeparator, formatUnitConversion, scientificNotation } from '../ReadPretty';
|
||||
import App2 from '../demos/addonBefore&addonAfter';
|
||||
import App3 from '../demos/highPrecisionDecimals';
|
||||
import App1 from '../demos/inputNumber';
|
||||
import { formatNumberWithSeparator, formatUnitConversion, scientificNotation } from '../ReadPretty';
|
||||
|
||||
describe('InputNumber', () => {
|
||||
it('should display the title', () => {
|
||||
@ -81,13 +81,13 @@ describe('ReadPretty:formatNumberWithSeparator', () => {
|
||||
// Test case 1: Format a number with default format '0,0.00'
|
||||
test('Format number with default separator', () => {
|
||||
const formatted = formatNumberWithSeparator(1234567.89);
|
||||
expect(formatted).toBe('1,234,567.9');
|
||||
expect(formatted).toBe('1234567.9');
|
||||
});
|
||||
|
||||
// Test case 2: Format a number with custom format '0.00'
|
||||
test('Format number with custom separator', () => {
|
||||
const formatted = formatNumberWithSeparator(1234567.89, '0.00', 1);
|
||||
expect(formatted).toBe('1234567.9');
|
||||
const formatted = formatNumberWithSeparator(1234567.89, '0,0.00', 1);
|
||||
expect(formatted).toBe('1,234,567.9');
|
||||
});
|
||||
});
|
||||
describe('ReadPretty:formatUnitConversion', () => {
|
||||
@ -101,6 +101,11 @@ describe('ReadPretty:formatUnitConversion', () => {
|
||||
const result = formatUnitConversion(10, '/', 0);
|
||||
expect(result).toBe(10);
|
||||
});
|
||||
|
||||
test('0.1*0.2', () => {
|
||||
const result = formatUnitConversion(0.1, '*', 0.2);
|
||||
expect(result).toBe(0.02);
|
||||
});
|
||||
});
|
||||
|
||||
describe('ReadPretty:scientificNotation', () => {
|
||||
|
Loading…
Reference in New Issue
Block a user