/** * 功能:检查合同附件控件保持独立单一文件输入、键盘可访问及事件转发契约。 * 版本:v1.0.0 */ import assert from 'node:assert/strict'; import { readFile } from 'node:fs/promises'; const componentPath = new URL( '../src/views/resource/ContractAttachmentField.vue', import.meta.url, ); const formPath = new URL( '../src/views/resource/ResourceFieldForm.vue', import.meta.url, ); const [component, form] = await Promise.all([ readFile(componentPath, 'utf8'), readFile(formPath, 'utf8'), ]); assert.equal( component.includes('v-for='), false, '合同附件组件不得在 v-for 中持有模板引用', ); assert.match(component, /ref="fileInput"/u, '组件必须持有唯一文件输入引用'); assert.match( component, /fileInput\.value\?\.click\(\)/u, '点击区域必须调用单一文件输入元素', ); assert.match(component, /@keydown\.enter\.prevent="openPicker"/u); assert.match(component, /@keydown\.space\.prevent="openPicker"/u); assert.match(component, /@drop\.prevent="selectDroppedFile"/u); assert.match(component, /:tabindex="disabled \? -1 : 0"/u); assert.match(component, //u); assert.match(form, /