|
|
@@ -19,7 +19,9 @@ const point = { pointCode: 'P-FIXED', pointName: '无位置摄像机监测点',
|
|
|
const camera = { deviceCode: cameraCode, deviceName: '无位置现场摄像机', deviceType: '20', deviceTypeName: '视频监控设备',
|
|
|
deviceStatus: 'NORMAL', industry: 'DRAINAGE', longitude: null, latitude: null, coordinateValidation: coordinate }
|
|
|
const device = { deviceCode: cameraCode, deviceName: camera.deviceName, typeCode: '20', bound: true,
|
|
|
- capabilities: { live: true, records: true, playback: true, playbackControl: false } }
|
|
|
+ businessCode: cameraCode, sourceType: 'GB28181', gbDeviceId: '34020000002000000001',
|
|
|
+ gbChannelId: '34020000001320000001', manufacturer: 'Dahua', location: '测试安装位置',
|
|
|
+ capabilities: { live: true, records: true, playback: true, playbackControl: true } }
|
|
|
const aggregate = { deviceCode: cameraCode, aggregateState: 'READY',
|
|
|
archive: { state: 'SUCCESS', data: camera }, metrics: { state: 'EMPTY', data: null },
|
|
|
warnings: { state: 'EMPTY', data: [] }, alarms: { state: 'EMPTY', data: [] }, workOrders: { state: 'EMPTY', data: null },
|
|
|
@@ -95,7 +97,7 @@ async function mountRoot({ positioned = false, underground = false } = {}) {
|
|
|
const selectedCamera = { ...camera, longitude: selectedPoint.longitude, latitude: selectedPoint.latitude, coordinateValidation: location }
|
|
|
const requests = [], unexpected = [], errors = []
|
|
|
const server = { snapshotGate: null, pointGate: null, pointFails: false, cameraPresent: true, liveFailures: 0,
|
|
|
- recordings: [], recordsFail: false, playbackBusy: false }
|
|
|
+ recordings: [], recordsFail: false, playbackBusy: false, playbackControls: undefined }
|
|
|
const fetchImpl = async (address, options = {}) => {
|
|
|
const url = new URL(address), path = url.pathname.replace('/api/cockpit/v1', '')
|
|
|
const body = options.body ? JSON.parse(options.body) : null
|
|
|
@@ -147,7 +149,8 @@ async function mountRoot({ positioned = false, underground = false } = {}) {
|
|
|
return envelope({ deviceCode: cameraCode, deviceName: device.deviceName,
|
|
|
sessionId: 'session-pb', sessionToken: 'owner-pb', mode: 'PLAYBACK',
|
|
|
startTime: body.startTime, endTime: body.endTime,
|
|
|
- media: { native: true, url: 'https://media.invalid/playback.mp4' } })
|
|
|
+ media: { native: true, url: 'https://media.invalid/playback.mp4' },
|
|
|
+ ...(server.playbackControls ? { controls: server.playbackControls } : {}) })
|
|
|
}
|
|
|
if (path === '/video/sessions/prepare') {
|
|
|
assert.deepEqual(body, { deviceCode: cameraCode })
|
|
|
@@ -167,6 +170,10 @@ async function mountRoot({ positioned = false, underground = false } = {}) {
|
|
|
assert.deepEqual(body, { sessionToken: 'owner-host' })
|
|
|
return envelope({ sessionId: 'session-host', deviceCode: cameraCode, mode: 'LIVE', status: 'STOPPED' })
|
|
|
}
|
|
|
+ if (path === '/video/sessions/session-pb/control') {
|
|
|
+ assert.deepEqual(body.sessionToken, 'owner-pb')
|
|
|
+ return envelope({ sessionId: 'session-pb', status: 'ACTIVE' })
|
|
|
+ }
|
|
|
if (path === '/video/sessions/session-pb/stop' || path === '/video/sessions/session-pb/status') {
|
|
|
assert.deepEqual(body, { sessionToken: 'owner-pb' })
|
|
|
return envelope({ sessionId: 'session-pb', deviceCode: cameraCode, mode: 'PLAYBACK', status: 'STOPPED' })
|
|
|
@@ -317,6 +324,84 @@ test('历史录像TAB不关闭面板,列片后才起流,占用不抢停别
|
|
|
} finally { await page.dispose() }
|
|
|
})
|
|
|
|
|
|
+test('确认过的回放控制可用,且跳转上限等于所选录像时长', async () => {
|
|
|
+ const page = await mountRoot()
|
|
|
+ try {
|
|
|
+ page.server.recordings = [{ name: 'CAM/03', startTime: '2026-11-10 01:00:00', endTime: '2026-11-10 01:30:00', type: 'time' }]
|
|
|
+ // A confirmed session advertises the controls the playback seam really implements.
|
|
|
+ page.server.playbackControls = { pause: true, resume: true, speed: true, seek: true }
|
|
|
+ const detail = await openMainDetail(page)
|
|
|
+ detail.querySelector('[data-video-open]').click(); await settle()
|
|
|
+ const dialog = () => document.querySelector('[data-video-monitor]')
|
|
|
+ const tabs = [...dialog().querySelectorAll('button')].filter((button) => ['实时视频', '历史录像'].includes(button.textContent.trim()))
|
|
|
+ tabs[1].click(); await settle()
|
|
|
+ const play = [...dialog().querySelectorAll('button')].find((button) => button.textContent.trim() === '播放')
|
|
|
+ play.click(); await settle()
|
|
|
+ const controls = [...dialog().querySelectorAll('[data-playback-control]')]
|
|
|
+ assert.ok(controls.length >= 6, 'pause/resume and 0.25/0.5/1/2/4x plus seek must all be rendered')
|
|
|
+ for (const control of controls) {
|
|
|
+ assert.equal(control.disabled, false, `${control.dataset.playbackControl} 确认后必须可用`)
|
|
|
+ }
|
|
|
+ // The seek input is bounded by the chosen recording (30 minutes), not by the whole day.
|
|
|
+ const position = dialog().querySelector('[data-playback-position]')
|
|
|
+ assert.ok(position, '确认 seek 后必须出现位置输入')
|
|
|
+ assert.equal(position.getAttribute('max'), '1800')
|
|
|
+ // Pressing a confirmed control reaches the owned session.
|
|
|
+ const pause = controls.find((control) => control.getAttribute('data-playback-control') === 'pause')
|
|
|
+ pause.click(); await settle()
|
|
|
+ assert.equal(page.requests.filter((request) => request.path.endsWith('/control')).length, 1)
|
|
|
+ // A seek beyond the chosen recording is refused locally and never reaches the server.
|
|
|
+ const setPosition = (value) => {
|
|
|
+ position.value = value
|
|
|
+ position.dispatchEvent(new Event('input'))
|
|
|
+ }
|
|
|
+ setPosition('1801')
|
|
|
+ controls.find((control) => control.getAttribute('data-playback-control') === 'seek').click(); await settle()
|
|
|
+ assert.equal(page.requests.filter((request) => request.path.endsWith('/control')).length, 1,
|
|
|
+ '越界跳转不得发出控制请求')
|
|
|
+ // A position inside the recording is forwarded.
|
|
|
+ setPosition('900')
|
|
|
+ controls.find((control) => control.getAttribute('data-playback-control') === 'seek').click(); await settle()
|
|
|
+ assert.equal(page.requests.filter((request) => request.path.endsWith('/control')).length, 2)
|
|
|
+ assert.deepEqual(page.errors, [])
|
|
|
+ assert.deepEqual(page.unexpected, [])
|
|
|
+ } finally { await page.dispose() }
|
|
|
+})
|
|
|
+
|
|
|
+test('监控面板展示六项设备基础信息,缺值显示为破折号', async () => {
|
|
|
+ const page = await mountRoot()
|
|
|
+ try {
|
|
|
+ const open = async () => {
|
|
|
+ const detail = await openMainDetail(page)
|
|
|
+ detail.querySelector('[data-video-open]').click(); await settle()
|
|
|
+ return document.querySelector('[data-video-meta]')
|
|
|
+ }
|
|
|
+ const field = (meta, key) => meta.querySelector(`[data-video-meta-field="${key}"]`).textContent.trim()
|
|
|
+ let meta = await open()
|
|
|
+ assert.ok(meta, '监控面板必须展示设备基础信息')
|
|
|
+ assert.equal(field(meta, 'deviceName'), '无位置现场摄像机')
|
|
|
+ assert.equal(field(meta, 'businessCode'), cameraCode)
|
|
|
+ assert.equal(field(meta, 'accessType'), '国标接入')
|
|
|
+ assert.equal(field(meta, 'gb'), '34020000002000000001 / 34020000001320000001')
|
|
|
+ assert.equal(field(meta, 'location'), '测试安装位置')
|
|
|
+ assert.equal(field(meta, 'manufacturer'), 'Dahua')
|
|
|
+ document.querySelector('[data-video-monitor] [aria-label="关闭监控"]').click(); await settle()
|
|
|
+ // Missing values must read as an em dash, never as "undefined" or a blank cell.
|
|
|
+ const savedLocation = device.location, savedManufacturer = device.manufacturer
|
|
|
+ try {
|
|
|
+ device.location = null; delete device.manufacturer
|
|
|
+ meta = await open()
|
|
|
+ assert.equal(field(meta, 'location'), '—')
|
|
|
+ assert.equal(field(meta, 'manufacturer'), '—')
|
|
|
+ } finally {
|
|
|
+ device.location = savedLocation; device.manufacturer = savedManufacturer
|
|
|
+ }
|
|
|
+ document.querySelector('[data-video-monitor] [aria-label="关闭监控"]').click(); await settle()
|
|
|
+ assert.deepEqual(page.errors, [])
|
|
|
+ assert.deepEqual(page.unexpected, [])
|
|
|
+ } finally { await page.dispose() }
|
|
|
+})
|
|
|
+
|
|
|
test('历史回放占用时提示占用且不释放他人回放', async () => {
|
|
|
const page = await mountRoot()
|
|
|
try {
|
|
|
@@ -589,4 +674,4 @@ test('地下管线详情:真实Root列表点设备经Latest TAB打开唯一监
|
|
|
assert.deepEqual(page.unexpected, [])
|
|
|
assert.deepEqual(page.errors, [])
|
|
|
} finally { await page.dispose() }
|
|
|
-})
|
|
|
+})
|