|
|
@@ -8,6 +8,7 @@ import { createPinia, setActivePinia } from 'pinia'
|
|
|
|
|
|
import { usePointLocateStore } from '../src/modules/cockpit/stores/pointLocateStore.js'
|
|
|
import { workOrderRows } from '../src/modules/cockpit/domain/equipmentDetailView.js'
|
|
|
+import { planModeLayers } from '../src/modules/cockpit/domain/modeLayerPlan.js'
|
|
|
|
|
|
const coordinate = { state: 'VALID', reason: null, renderable: true, crs: 'WGS84' }
|
|
|
const device = {
|
|
|
@@ -46,23 +47,35 @@ test('设备定位:走完整视角、打开设备详情并写揭示目标', as
|
|
|
assert.deepEqual(calls.openDevice[0], { code: 'DEV-131', options: { locateTarget: { code: 'DEV-131', deviceCode: '' } } })
|
|
|
})
|
|
|
|
|
|
-test('关联设备定位:先开宿主点位、再进设备级,揭示宿主点位', async () => {
|
|
|
+test('关联设备定位:越过宿主点位飞到设备自身坐标,再进设备级', async () => {
|
|
|
setActivePinia(createPinia())
|
|
|
const locator = usePointLocateStore()
|
|
|
- const calls = { openPoint: [], selectDevice: [] }
|
|
|
+ const calls = { fly: [], openPoint: [], selectDevice: [] }
|
|
|
+ const deviceTarget = {
|
|
|
+ kind: 'monitoring-device',
|
|
|
+ code: 'DEV-131',
|
|
|
+ name: '测试设备',
|
|
|
+ status: 'NORMAL',
|
|
|
+ longitude: device.longitude,
|
|
|
+ latitude: device.latitude,
|
|
|
+ coordinate,
|
|
|
+ }
|
|
|
const result = await locator.locateTarget({ kind: 'map-object', code: 'DEV-131' }, {
|
|
|
objects: [point],
|
|
|
mapReady: true,
|
|
|
- flyPoint: async () => true,
|
|
|
+ device: deviceTarget,
|
|
|
+ flyPoint: async (object, options) => { calls.fly.push({ object, options }); return true },
|
|
|
openPoint: async (code, options) => { calls.openPoint.push({ code, options }) },
|
|
|
selectDevice: async (code, options) => { calls.selectDevice.push({ code, options }) },
|
|
|
})
|
|
|
assert.equal(result.result, 'ok')
|
|
|
+ assert.equal(calls.fly[0].object.code, 'DEV-131', '应飞设备自身坐标,而不是宿主点位')
|
|
|
+ assert.equal(calls.fly[0].options.tier, 'device')
|
|
|
assert.deepEqual(calls.openPoint[0], { code: 'MP-131', options: undefined })
|
|
|
- assert.deepEqual(calls.selectDevice[0], {
|
|
|
- code: 'DEV-131',
|
|
|
- options: { locateTarget: { code: 'MP-131', deviceCode: 'DEV-131' } },
|
|
|
- })
|
|
|
+ assert.equal(calls.selectDevice[0].code, 'DEV-131')
|
|
|
+ assert.equal(calls.selectDevice[0].options.locateTarget.code, 'MP-131')
|
|
|
+ assert.equal(calls.selectDevice[0].options.locateTarget.deviceCode, 'DEV-131')
|
|
|
+ assert.deepEqual(calls.selectDevice[0].options.locateTarget.device, deviceTarget)
|
|
|
})
|
|
|
|
|
|
test('事件回联:走完整视角飞行 + 高亮,不再只换中心', async () => {
|
|
|
@@ -86,4 +99,32 @@ test('工单行保留设备编码,供工单卡定位按钮使用', () => {
|
|
|
const rows = workOrderRows([{ code: 'WO-131', deviceName: '测试设备', deviceCode: 'DEV-131', stateCode: 3 }])
|
|
|
assert.equal(rows[0].deviceCode, 'DEV-131')
|
|
|
assert.ok(rows[0].deviceLabel.includes('DEV-131'))
|
|
|
+})
|
|
|
+
|
|
|
+test('关联设备 NORMAL:定位揭示必须让详情越过模式暂停', () => {
|
|
|
+ const host = {
|
|
|
+ kind: 'monitoring-point',
|
|
|
+ code: 'MP-131',
|
|
|
+ name: '测试点位',
|
|
|
+ status: 'NORMAL',
|
|
|
+ deviceCodes: ['DEV-131'],
|
|
|
+ longitude: device.longitude,
|
|
|
+ latitude: device.latitude,
|
|
|
+ coordinate,
|
|
|
+ }
|
|
|
+ const row = { code: 'DEV-131', pointCode: 'MP-131', status: 'NORMAL', placement: 'drawn' }
|
|
|
+ const selection = { level: 'equipment', pointCode: 'MP-131', deviceCode: 'DEV-131' }
|
|
|
+ const base = {
|
|
|
+ mode: 'warningResponse',
|
|
|
+ objects: [host],
|
|
|
+ abnormalDevices: [],
|
|
|
+ deviceFacts: [{ deviceCode: 'DEV-131', base: 'NORMAL', tags: [] }],
|
|
|
+ associatedDevices: [row],
|
|
|
+ selection,
|
|
|
+ entered: true,
|
|
|
+ }
|
|
|
+ assert.equal(planModeLayers(base).selection.visible, false, '未定位时 NORMAL 关联设备在预警处置应暂停')
|
|
|
+ const located = planModeLayers({ ...base, locateTarget: { code: 'MP-131', deviceCode: 'DEV-131' } })
|
|
|
+ assert.ok(located.markers.some((marker) => marker.code === 'MP-131'), '定位揭示应把宿主点位标记临时放行')
|
|
|
+ assert.equal(located.selection.visible, true, '定位揭示必须让 NORMAL 关联设备的详情可见')
|
|
|
})
|