waterGisShell.test.mjs 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import test from 'node:test'
  2. import assert from 'node:assert/strict'
  3. import { readFile } from 'node:fs/promises'
  4. const pageSources = [
  5. 'src/views/subSystem/waterSupply/facility/gis.vue',
  6. 'src/views/subSystem/waterSupply/components/WaterDeviceGisMap.vue',
  7. 'src/views/subSystem/waterSupply/components/WaterAlarmPage.vue'
  8. ]
  9. test('water supply GIS pages use the shared page shell', async () => {
  10. for (const path of pageSources) {
  11. const source = await readFile(path, 'utf8')
  12. assert.match(source, /<WaterGisPageShell/u, `${path} should use the shared shell`)
  13. assert.match(source, /#metrics/u, `${path} should provide metrics`)
  14. assert.match(source, /#controls/u, `${path} should provide filters`)
  15. assert.match(source, /#legend/u, `${path} should provide legend`)
  16. assert.match(source, /#results/u, `${path} should provide search results`)
  17. assert.match(source, /#map/u, `${path} should provide the map`)
  18. assert.match(source, /<el-drawer/u, `${path} should keep the right drawer`)
  19. }
  20. })
  21. test('shared shell keeps the side panel and map equal height with one bounded scroll', async () => {
  22. const source = await readFile('src/components/WaterGisPageShell.vue', 'utf8')
  23. assert.match(source, /<header class="gis-header"/u)
  24. assert.match(source, /<div class="gis-layout"/u)
  25. assert.match(source, /<aside class="side-panel"/u)
  26. assert.match(source, /<main class="map-panel"/u)
  27. assert.match(source, /class="side-panel-body"/u)
  28. assert.match(source, /height: calc\(100vh - 132px\)/u)
  29. assert.match(source, /overflow: hidden/u)
  30. assert.match(source, /overflow-y: auto/u)
  31. assert.doesNotMatch(source, /grid-template-columns:\s*1fr\s+310px/u)
  32. })
  33. test('alarm GIS keeps map mode inside the common panel contract', async () => {
  34. const source = await readFile('src/views/subSystem/waterSupply/components/WaterAlarmPage.vue', 'utf8')
  35. assert.match(source, /<WaterGisPageShell[\s\S]*?embedded/u)
  36. assert.match(source, /报警图层与图例/u)
  37. assert.match(source, /选中报警/u)
  38. assert.match(source, /@point-click="openDetail"/u)
  39. })