waterFacilityImportCoordinates.test.mjs 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. import assert from 'node:assert/strict'
  2. import fs from 'node:fs'
  3. import test from 'node:test'
  4. const facilities = [
  5. {
  6. path: 'src/views/subSystem/basic/waterSource/index.vue',
  7. fields: ['longitude', 'latitude']
  8. },
  9. {
  10. path: 'src/views/subSystem/basic/waterPlant/index.vue',
  11. fields: ['longitude', 'latitude']
  12. },
  13. {
  14. path: 'src/views/subSystem/basic/pumpStation/index.vue',
  15. fields: ['longitude', 'latitude']
  16. },
  17. {
  18. path: 'src/views/subSystem/basic/pipeInfo/index.vue',
  19. fields: ['startLongitude', 'startLatitude', 'endLongitude', 'endLatitude']
  20. },
  21. {
  22. path: 'src/views/subSystem/basic/waterUserInfo/index.vue',
  23. fields: ['longitude', 'latitude']
  24. }
  25. ]
  26. test('all T1 facility pages expose Excel import through the shared dialog', () => {
  27. for (const facility of facilities) {
  28. const source = fs.readFileSync(facility.path, 'utf8')
  29. assert.match(source, /WaterFacilityImportDialog/u, facility.path)
  30. assert.match(source, />导入<\/el-button>/u, facility.path)
  31. assert.match(source, /@imported="getList"/u, facility.path)
  32. }
  33. const dialog = fs.readFileSync('src/views/subSystem/waterSupply/components/WaterFacilityImportDialog.vue', 'utf8')
  34. assert.match(dialog, /accept="\.xlsx, \.xls"/u)
  35. assert.match(dialog, /:before-upload="validateFile"/u)
  36. assert.match(dialog, /function validateFile/u)
  37. assert.match(dialog, /\(xlsx\|xls\)/u)
  38. assert.match(dialog, /updateSupport/u)
  39. assert.match(dialog, /下载模板/u)
  40. assert.match(dialog, /VITE_APP_BASE_API/u)
  41. assert.match(dialog, /download\(props\.templateUrl/u)
  42. assert.match(dialog, /response\.code !== 200/u)
  43. })
  44. test('all T1 facility pages expose coordinates in list, edit drawer, and detail drawer', () => {
  45. for (const facility of facilities) {
  46. const source = fs.readFileSync(facility.path, 'utf8')
  47. for (const field of facility.fields) {
  48. const occurrences = source.match(new RegExp(field, 'gu')) || []
  49. assert.ok(occurrences.length >= 3, `${facility.path} must expose ${field} for list, form, and detail`)
  50. assert.match(source, new RegExp(`v-model="form\\.${field}"`, 'u'), `${facility.path} must edit ${field}`)
  51. assert.match(source, new RegExp(`detailData\\.${field}`, 'u'), `${facility.path} must show ${field} in details`)
  52. }
  53. }
  54. })