vendor: amis 6.13.0 base (fork root)

This commit is contained in:
2026-06-16 22:14:57 +08:00
commit 8c8e4247a9
3840 changed files with 2467374 additions and 0 deletions

View File

@@ -0,0 +1,147 @@
import {fireEvent, render} from '@testing-library/react';
import '../../src';
import {render as amisRender} from '../../src';
import {makeEnv, wait} from '../helper';
test('EventAction:disabled', async () => {
const {getByText, container}: any = render(
amisRender(
{
type: 'page',
data: {
btnDisabled: true,
btnNotDisabled: false
},
body: [
{
type: 'action',
label: '按钮1',
disabledOn: '${btnDisabled}'
},
{
type: 'action',
label: '按钮2',
disabledOn: '${btnNotDisabled}',
onEvent: {
click: {
actions: [
{
actionType: 'disabled',
componentId: 'ui:button_test_3'
}
]
}
}
},
{
type: 'action',
label: '按钮3',
disabledOn: '${btnNotDisabled}',
id: 'ui:button_test_3'
},
{
type: 'action',
label: '按钮4',
disabledOn: '${btnNotDisabled}',
onEvent: {
click: {
actions: [
{
actionType: 'enabled',
componentId: 'ui:button_test_5'
}
]
}
}
},
{
type: 'action',
label: '按钮5',
disabled: true,
id: 'ui:button_test_5'
},
{
type: 'action',
label: '按钮6',
onEvent: {
click: {
actions: [
{
actionType: 'disabled',
componentId: 'ui:form_disable'
}
]
}
}
},
{
type: 'form',
id: 'ui:form_disable',
title: '表单',
body: [
{
type: 'button',
className: 'ml-2',
label: '我的状态变了'
}
]
}
]
},
{},
makeEnv({})
)
);
fireEvent.click(getByText(/按钮2/));
fireEvent.click(getByText(/按钮4/));
fireEvent.click(getByText(/按钮6/));
expect(container).toMatchSnapshot();
});
test('EventAction:disabledFormItem', async () => {
const {getByText, container}: any = render(
amisRender(
{
type: 'page',
body: [
{
type: 'form',
body: [
{
type: 'textarea',
id: 'textarea',
name: 'textarea',
disabled: true
}
]
},
{
type: 'action',
label: '启用textarea',
onEvent: {
click: {
actions: [
{
actionType: 'enabled',
componentId: 'textarea'
}
]
}
}
}
]
},
{},
makeEnv({})
)
);
expect(container.querySelector('textarea[name="textarea"]')).toBeDisabled();
fireEvent.click(getByText(/启用textarea/));
await wait(200);
expect(
container.querySelector('textarea[name="textarea"]')
).not.toBeDisabled();
});