diff --git a/web/src/components/ScSelect.vue b/web/src/components/ScSelect.vue new file mode 100644 index 00000000..293c17b6 --- /dev/null +++ b/web/src/components/ScSelect.vue @@ -0,0 +1,56 @@ + + + + diff --git a/web/src/views/sms/downlink-detail/index.vue b/web/src/views/sms/downlink-detail/index.vue index 268739d4..468744f1 100644 --- a/web/src/views/sms/downlink-detail/index.vue +++ b/web/src/views/sms/downlink-detail/index.vue @@ -28,9 +28,7 @@ - - - + @@ -38,9 +36,7 @@ - - - + @@ -126,6 +122,7 @@ import { onMounted, reactive, ref } from 'vue' import { useRoute, useRouter } from 'vue-router' import { ArrowDown } from '@element-plus/icons-vue' import { ElMessage } from 'element-plus' +import ScSelect from '@/components/ScSelect.vue' import { accountApi } from '@/api/account' import { channelApi } from '@/api/channel' import { diff --git a/web/tests/sc-select.spec.ts b/web/tests/sc-select.spec.ts new file mode 100644 index 00000000..e55156b6 --- /dev/null +++ b/web/tests/sc-select.spec.ts @@ -0,0 +1,27 @@ +// Issue#6·F3:ScSelect auto>5 搜索阈值(sub2api Select searchable='auto' 契约) +import { describe, expect, it } from 'vitest' +import { mount } from '@vue/test-utils' +import ScSelect from '@/components/ScSelect.vue' + +const opts = (n: number) => Array.from({ length: n }, (_, i) => ({ value: i, label: `选项${i}` })) + +describe('ScSelect auto 阈值', () => { + it('options>5 → filterable 生效(trigger 内可输入)', () => { + const w = mount(ScSelect, { props: { modelValue: '', options: opts(6) }, global: { stubs: { 'el-select': { template: '
', props: ['filterable','modelValue'] } } } }) + expect(w.find('[data-testid="f"]').exists()).toBe(true) + }) + it('options≤5 → 无 filterable', () => { + const w = mount(ScSelect, { props: { modelValue: '', options: opts(5) }, global: { stubs: { 'el-select': { template: '
', props: ['filterable','modelValue'] } } } }) + expect(w.find('[data-testid="f"]').exists()).toBe(false) + }) + it('searchable=false 关闭 auto;filterable 显式覆盖', () => { + const off = mount(ScSelect, { props: { modelValue: '', options: opts(9), searchable: false }, global: { stubs: { 'el-select': { template: '
', props: ['filterable'] } } } }) + expect(off.find('[data-testid="f"]').exists()).toBe(false) + const on = mount(ScSelect, { props: { modelValue: '', options: opts(2), filterable: true }, global: { stubs: { 'el-select': { template: '
', props: ['filterable'] } } } }) + expect(on.find('[data-testid="f"]').exists()).toBe(true) + }) + it('options 渲染到默认 slot(el-option 数=传入数)', () => { + const w = mount(ScSelect, { props: { modelValue: '', options: opts(4) }, global: { stubs: { 'el-select': { template: '
', props: ['modelValue'] }, 'el-option': { template: '
' } } } }) + expect(w.findAll('.opt').length).toBe(4) + }) +})