t22-t45-baseline.mjs 1.5 KB

12345678910111213141516171819202122
  1. import { readFileSync } from 'node:fs'
  2. import vm from 'node:vm'
  3. import { MAP_LABEL_STYLE, mapLabelText } from '../../../src/modules/cockpit/domain/mapLabelStyle.js'
  4. // Read the pre-edit snapshot; reproduce the existing T45 harness failure without rewriting source.
  5. const source = readFileSync(new URL('../implementation/t22/before/src__modules__cockpit__services__cesiumEngine.js', import.meta.url), 'utf8')
  6. const extract = (name) => source.match(new RegExp(`(?:export )?function ${name}\\([^]*?\\n\\}`))[0].replace(/^export /, '')
  7. const context = vm.createContext({
  8. pointMarkerSource: () => ({ entities: { removeAll() {}, add() {} } }),
  9. Cartesian3: { fromDegrees() {} }, Cartesian2: class {}, HeightReference: {}, VerticalOrigin: {},
  10. Color: { WHITE: {}, BLACK: { withAlpha: (alpha) => ({ alpha }) }, fromCssColorString: () => ({ withAlpha: (alpha) => ({ alpha }) }) },
  11. LabelStyle: {}, viewer: {}, MAP_LABEL_STYLE, mapLabelText,
  12. })
  13. vm.runInContext(extract('mapTextLabel'), context)
  14. vm.runInContext(extract('syncPointMarkers'), context)
  15. try {
  16. vm.runInContext("syncPointMarkers(viewer,[{key:'monitoring-point|P',code:'P',kind:'monitoring-point',name:'城南监测点',longitude:1,latitude:2}],()=>'color',()=>'image')", context)
  17. throw new Error('Expected the pre-existing T45 harness failure')
  18. } catch (error) {
  19. if (error.message !== 'markerEntityIndex is not defined') throw error
  20. console.log(`Confirmed pre-edit T45 harness failure: ${error.message}`)
  21. }