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