t23-popup-placement.mjs 2.0 KB

123456789101112131415161718192021222324252627282930313233343536
  1. import assert from 'node:assert/strict'
  2. import { readFileSync } from 'node:fs'
  3. import { parse } from '@vue/compiler-sfc'
  4. import { baseParse } from '@vue/compiler-dom'
  5. // Layout regression: a popup inside the map stacking context cannot rise above
  6. // the sibling columns. Inspect the real SFC tree, not a copied fixture.
  7. const file = new URL('../../../src/modules/cockpit/CockpitShell.vue', import.meta.url)
  8. const { descriptor } = parse(readFileSync(file, 'utf8'))
  9. const root = baseParse(descriptor.template.content)
  10. function find(node, predicate) {
  11. if (predicate(node)) return node
  12. for (const child of node.children || []) {
  13. const result = find(child, predicate)
  14. if (result) return result
  15. }
  16. return null
  17. }
  18. const main = find(root, (n) => n.type === 1 && n.tag === 'main')
  19. const map = find(main, (n) => n.type === 1 && n.tag === 'section')
  20. const popup = find(main, (n) => n.type === 1 && n.tag === 'PipeEnhancement')
  21. assert.ok(popup, 'selection must have a popup consumer')
  22. assert.equal(find(map, (n) => n === popup), null,
  23. '局部增强窗不能放在 z-map=0 内,否则被右侧 z-columns=2 面板遮挡')
  24. assert.ok(main.children.includes(popup), 'popup must share the main overlay stacking context with the columns')
  25. const styles = descriptor.styles.map((s) => s.content).join('\n')
  26. assert.match(styles, /\.cockpit-shell__enhancement\s*\{[^}]*width:\s*min\(1100px/,
  27. 'enhancement popup should use the larger map overlay width')
  28. assert.match(styles, /\.cockpit-shell__enhancement\s*\{[^}]*z-index:\s*calc\(var\(--z-columns\) \+ 1\)/,
  29. 'enhancement overlay must remain above the columns')
  30. const panelFile = new URL('../../../src/modules/cockpit/components/PipeEnhancement.vue', import.meta.url)
  31. const panel = parse(readFileSync(panelFile, 'utf8')).descriptor.styles.map((s) => s.content).join('\n')
  32. assert.match(panel, /left: 50%/)
  33. assert.match(panel, /top: 50%/)
  34. assert.match(panel, /grid-template-rows: auto auto minmax\(0, 1fr\) auto auto/)
  35. console.log('PASS 局部增强窗居中放大、画布自适应,脱离地图低层级并高于业务栏')