Skip to content

Commit

Permalink
test(erFormConfig): root:pc|Root:mobile
Browse files Browse the repository at this point in the history
  • Loading branch information
Liberty-liu committed Aug 18, 2023
1 parent a49196f commit 14bd5f0
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { ClickOutside as vClickOutside } from 'element-plus'
import CompleteButton from '@ER/formEditor/components/CompleteButton.vue'
import PanelsConfigComponentsTypeComponent from './TypeComponent.vue'
import PanelsConfigComponentsLogicComponent from './LogicComponent.vue'
import utils from '@ER/utils'
export default {
name: 'GlobalConfigPanel',
inheritAttrs: false,
Expand Down Expand Up @@ -41,7 +42,6 @@ const popperPaneRef = computed(() => {
})
let handleConfirm = ''
const handleBeforeChange = () => {
// visible.value = true
return new Promise((resolve, reject) => {
const pcObj = _.pick(unref(target).pc, compareKeys)
const mobileObj = _.pick(unref(target).mobile, compareKeys)
Expand Down Expand Up @@ -86,10 +86,6 @@ const options0 = computed(() => {
}
]
})
// <el-radio-button label="large">{{t('er.config.globalConfig.componentSize.large')}}</el-radio-button>
// <el-radio-button label="default" >{{t('er.config.globalConfig.componentSize.default')}}</el-radio-button>
// <el-radio-button label="small" >{{t('er.config.globalConfig.componentSize.small')}}</el-radio-button>
const options1 = computed(() => {
return [
{
Expand Down Expand Up @@ -152,8 +148,11 @@ const handleTypeListener = ({ property, data }) => {
</el-button>
</div>
</el-popover>
<!-- <DeviceSwitch justify-content="center"></DeviceSwitch>-->
<el-form-item :label="t('er.config.globalConfig.sync.label')" label-position="left">
<el-form-item
:label="t('er.config.globalConfig.sync.label')"
label-position="left"
v-bind="utils.addTestId('configPanel:isSync')"
>
<el-switch
ref="buttonRef"
v-click-outside:[popperPaneRef]="onClickOutside"
Expand All @@ -168,6 +167,7 @@ const handleTypeListener = ({ property, data }) => {
:label="t('er.config.globalConfig.componentSize.label')"
:val="target[state.platform].size"
:nodes="options1"
v-bind="utils.addTestId('configPanel:size')"
/>
<PanelsConfigComponentsTypeComponent
@listener="handleTypeListener"
Expand All @@ -177,8 +177,13 @@ const handleTypeListener = ({ property, data }) => {
:fontSize="80"
:val="target[state.platform].labelPosition"
:nodes="options0"
v-bind="utils.addTestId('configPanel:labelPosition')"
/>
<el-form-item v-if="ER.props.isShowCompleteButton" :label="t('er.public.button')">
<el-form-item
v-if="ER.props.isShowCompleteButton"
:label="t('er.public.button')"
v-bind="utils.addTestId('configPanel:completeButton')"
>
<div style="width: 100%;">
<div>
<CompleteButton mode="preview"/>
Expand Down
20 changes: 16 additions & 4 deletions test/erFormConfig.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,22 @@ describe('Configuration options owned by the config panel', () => {
afterEach(() => {
wrapper.findComponent({ ref: 'EReditorRef' }).vm.switchPlatform('pc')
})
test('Root', () => {
// console.log(wrapper.html())
// console.log(erGeneratorData(erComponentsConfig.fieldsConfig[0].list[0], true, 'en'))
// expect(erGeneratorData(erComponentsConfig.fieldsConfig[0].list[0], true, 'en')).toMatchSnapshot()
test('Root:pc', async () => {
value0.value = 'root'
await nextTick()
expect(wrapper.find(utils.getTestId('configPanel:isSync')).exists()).toBe(true)
expect(wrapper.find(utils.getTestId('configPanel:size')).exists()).toBe(true)
expect(wrapper.find(utils.getTestId('configPanel:labelPosition')).exists()).toBe(true)
expect(wrapper.find(utils.getTestId('configPanel:completeButton')).exists()).toBe(true)
})
test('Root:mobile', async () => {
value0.value = 'root'
wrapper.findComponent({ ref: 'EReditorRef' }).vm.switchPlatform('mobile')
await nextTick()
expect(wrapper.find(utils.getTestId('configPanel:isSync')).exists()).toBe(true)
expect(wrapper.find(utils.getTestId('configPanel:size')).exists()).toBe(false)
expect(wrapper.find(utils.getTestId('configPanel:labelPosition')).exists()).toBe(true)
expect(wrapper.find(utils.getTestId('configPanel:completeButton')).exists()).toBe(true)
})
test('Email:pc', async () => {
value0.value = store.fields[0].id
Expand Down

0 comments on commit 14bd5f0

Please sign in to comment.