t65-card-interactions.mjs 2.6 KB

12345678910111213141516171819202122232425262728293031323334
  1. /** Issue 65 static interaction guard: card identity, handler, and nested button propagation stay aligned. */
  2. import assert from 'node:assert/strict'
  3. import fs from 'node:fs'
  4. const panel = fs.readFileSync(new URL('../src/modules/cockpit/components/PanelBlocks.vue', import.meta.url), 'utf8')
  5. const shell = fs.readFileSync(new URL('../src/modules/cockpit/CockpitShell.vue', import.meta.url), 'utf8')
  6. const drawer = fs.readFileSync(new URL('../src/modules/cockpit/components/EntityDetailDrawer.vue', import.meta.url), 'utf8')
  7. const warning = fs.readFileSync(new URL('../src/modules/cockpit/components/WarningResponsePane.vue', import.meta.url), 'utf8')
  8. assert.ok(panel.includes(`:class="{ 'panel-item--clickable': cardAction(row).kind !== CARD_ACTION.NONE }"`))
  9. assert.ok(panel.includes(`:tabindex="cardAction(row).kind !== CARD_ACTION.NONE ? 0 : null"`))
  10. assert.ok(panel.includes(`@click="cardAction(row).kind !== CARD_ACTION.NONE ? onCardClick(row, $event) : null"`))
  11. assert.ok(panel.includes(`@click.stop="emit('locate', point.pointCode)"`))
  12. assert.ok(panel.includes(`@keydown.enter.stop`))
  13. assert.ok(panel.includes(`@keydown.space.stop`))
  14. assert.ok(panel.includes(`event.target.closest('button')`))
  15. assert.ok(warning.includes(`const id = (action && action.code) || ''`))
  16. assert.ok(!warning.includes(`row.workOrderCode || row.code || (action && action.code)`))
  17. assert.ok(shell.includes(`@locate-device="locateDeviceFromDetail"`))
  18. assert.ok(shell.includes(`function locateDeviceFromDetail(deviceCode)`))
  19. assert.ok(shell.includes(`monitoringStore.locateCode(deviceCode)`), '关联设备定位必须复用设备台账的定位方法')
  20. assert.ok(drawer.includes(`position: absolute`))
  21. assert.ok(drawer.includes(`.entity-drawer.is-left { left: calc(var(--rail-w)`))
  22. assert.ok(drawer.includes(`.entity-drawer.is-right { right: calc(var(--rail-w)`))
  23. console.log('t65-card-interactions: 22/22')
  24. // 维护者 2026-10-29:详情面板必须与其他面板同一套磨砂语言(同一组 token + blur)。
  25. assert.ok(drawer.includes(`backdrop-filter: blur(16px) saturate(115%);`))
  26. assert.ok(drawer.includes(`var(--panel-top`))
  27. assert.ok(drawer.includes(`var(--panel-line`))
  28. // 左右判定只认目录单源,组件与外壳都不得硬编码 'left'/'right'。
  29. assert.ok(shell.includes(`panelSideFor(mode.value, panelId)`))
  30. assert.ok(shell.includes(`panelSideOf(panelId)`))
  31. assert.ok(!shell.includes(`handleCardAction(action, 'left')`))
  32. assert.ok(!shell.includes(`handleCardAction(action, 'right')`))
  33. assert.ok(warning.includes(`panelSideFor('warningResponse', props.panelId)`))
  34. assert.ok(!warning.includes(`{ side: 'right' }`))