mirror of
https://gitee.com/baidu/amis.git
synced 2024-12-02 11:58:10 +08:00
chore: 表单报错时表单的 notify 里不再显示表单项的报错信息,等后续能拿到 label 的时候再加回来 (#3632)
* chore: 表单报错时表单的 notify 里不再显示表单项的报错信息,等后续能拿到 label 的时候再加回来 * 修复单元测试 * 修复单元测试
This commit is contained in:
parent
8d06eb0305
commit
ebb2c86692
@ -60,10 +60,7 @@ test('Renderer:FormItem:validateApi:success', async () => {
|
||||
expect(onSubmit).not.toHaveBeenCalled();
|
||||
|
||||
await wait(100);
|
||||
expect(notify).toHaveBeenCalledWith(
|
||||
'error',
|
||||
'依赖的部分字段没有通过验证\n这是必填项'
|
||||
);
|
||||
expect(notify).toHaveBeenCalledWith('error', '依赖的部分字段没有通过验证');
|
||||
|
||||
const input = container.querySelector('input[name=a]');
|
||||
expect(input).toBeTruthy();
|
||||
@ -132,10 +129,7 @@ test('Renderer:FormItem:validateApi:failed', async () => {
|
||||
expect(onSubmit).not.toHaveBeenCalled();
|
||||
|
||||
await wait(100);
|
||||
expect(notify).toHaveBeenCalledWith(
|
||||
'error',
|
||||
'依赖的部分字段没有通过验证\n这是必填项'
|
||||
);
|
||||
expect(notify).toHaveBeenCalledWith('error', '依赖的部分字段没有通过验证');
|
||||
|
||||
const input = container.querySelector('input[name=a]');
|
||||
expect(input).toBeTruthy();
|
||||
|
@ -88,7 +88,7 @@ test('Renderer:formula', async () => {
|
||||
value: 2
|
||||
}
|
||||
});
|
||||
await wait(100);
|
||||
await wait(600);
|
||||
expect(inputs[2].value).toBe('3');
|
||||
expect(inputs[3].value).toBe('4');
|
||||
expect(inputs[4].value).toBe('5');
|
||||
|
@ -106,10 +106,7 @@ test('Renderer:Form:valdiate', async () => {
|
||||
expect(onSubmit).not.toHaveBeenCalled();
|
||||
|
||||
await wait(100);
|
||||
expect(notify).toHaveBeenCalledWith(
|
||||
'error',
|
||||
'依赖的部分字段没有通过验证\n这是必填项'
|
||||
);
|
||||
expect(notify).toHaveBeenCalledWith('error', '依赖的部分字段没有通过验证');
|
||||
|
||||
const input = container.querySelector('input[name=a]');
|
||||
expect(input).toBeTruthy();
|
||||
@ -231,10 +228,7 @@ test('Renderer:Form:onValidate', async () => {
|
||||
expect(onValidate.mock.calls[0][0]).toMatchSnapshot();
|
||||
|
||||
await wait(100);
|
||||
expect(notify).toHaveBeenCalledWith(
|
||||
'error',
|
||||
'依赖的部分字段没有通过验证\na is wrong\nb is wrong\nb is wrong 2'
|
||||
);
|
||||
expect(notify).toHaveBeenCalledWith('error', '依赖的部分字段没有通过验证');
|
||||
|
||||
fireEvent.click(getByText('Submit'));
|
||||
await wait(100);
|
||||
|
@ -26,7 +26,7 @@ test('Renderer:range', async () => {
|
||||
)
|
||||
);
|
||||
|
||||
const slider = container.querySelector('.cxd-InputRange-handle');
|
||||
const slider = container.querySelector('.cxd-InputRange-handle')!;
|
||||
fireEvent.mouseDown(slider);
|
||||
fireEvent.mouseMove(slider, {
|
||||
clientX: 400,
|
||||
|
@ -474,15 +474,6 @@ export const FormStore = ServiceStore.named('FormStore')
|
||||
) {
|
||||
let msg = failedMessage ?? self.__('Form.validateFailed');
|
||||
const env = getEnv(self);
|
||||
// 同时也列出所有表单项报错,方便在很长的表单中知道是哪个字段的问题
|
||||
// 支持在env中配hideValidateFailedDetail来隐藏所有表单项报错
|
||||
failedMessage == null &&
|
||||
!env.hideValidateFailedDetail &&
|
||||
self.items.forEach(item => {
|
||||
item.errorData.forEach(errorData => {
|
||||
msg = `${msg}\n${errorData.msg}`;
|
||||
});
|
||||
});
|
||||
|
||||
msg && env.notify('error', msg);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user