make kestrel a tak server, so that it can send and receive pois as cots data
Some checks failed
ci/woodpecker/pr/pr Pipeline failed
Some checks failed
ci/woodpecker/pr/pr Pipeline failed
This commit is contained in:
@@ -16,4 +16,22 @@ describe('members page', () => {
|
||||
const wrapper = await mountSuspended(Members)
|
||||
expect(wrapper.text()).toMatch(/Sign in to view members/)
|
||||
})
|
||||
|
||||
it('shows members list and Add user when user is admin', async () => {
|
||||
registerEndpoint('/api/me', () => ({ id: '1', identifier: 'admin', role: 'admin', avatar_url: null }), { method: 'GET' })
|
||||
registerEndpoint('/api/users', () => [])
|
||||
const wrapper = await mountSuspended(Members)
|
||||
await new Promise(r => setTimeout(r, 100))
|
||||
expect(wrapper.text()).toContain('Add user')
|
||||
expect(wrapper.text()).toMatch(/Only admins can change roles/)
|
||||
})
|
||||
|
||||
it('shows members content when user has canEditPois (leader)', async () => {
|
||||
registerEndpoint('/api/me', () => ({ id: '2', identifier: 'leader', role: 'leader', avatar_url: null }), { method: 'GET' })
|
||||
registerEndpoint('/api/users', () => [])
|
||||
const wrapper = await mountSuspended(Members)
|
||||
await new Promise(r => setTimeout(r, 150))
|
||||
expect(wrapper.text()).toContain('Members')
|
||||
expect(wrapper.text()).toContain('Identifier')
|
||||
})
|
||||
})
|
||||
|
||||
@@ -7,6 +7,7 @@ describe('useCameras', () => {
|
||||
registerEndpoint('/api/cameras', () => ({
|
||||
devices: [{ id: '1', name: 'Test', lat: 37.7, lng: -122.4, streamUrl: '', sourceType: 'mjpeg', device_type: 'feed' }],
|
||||
liveSessions: [],
|
||||
cotEntities: [],
|
||||
}))
|
||||
registerEndpoint('/api/pois', () => [])
|
||||
registerEndpoint('/api/me', () => null, { method: 'GET' })
|
||||
@@ -15,6 +16,22 @@ describe('useCameras', () => {
|
||||
expect(wrapper.findComponent({ name: 'KestrelMap' }).exists()).toBe(true)
|
||||
})
|
||||
|
||||
it('exposes cotEntities from API', async () => {
|
||||
const cotEntities = [{ id: 'cot-1', lat: 38, lng: -123, label: 'ATAK1' }]
|
||||
registerEndpoint('/api/cameras', () => ({
|
||||
devices: [],
|
||||
liveSessions: [],
|
||||
cotEntities,
|
||||
}))
|
||||
registerEndpoint('/api/pois', () => [])
|
||||
registerEndpoint('/api/me', () => null, { method: 'GET' })
|
||||
const wrapper = await mountSuspended(Index)
|
||||
await new Promise(r => setTimeout(r, 100))
|
||||
const map = wrapper.findComponent({ name: 'KestrelMap' })
|
||||
expect(map.exists()).toBe(true)
|
||||
expect(map.props('cotEntities')).toEqual(cotEntities)
|
||||
})
|
||||
|
||||
it('handles API error and falls back to empty devices and liveSessions', async () => {
|
||||
registerEndpoint('/api/cameras', () => {
|
||||
throw new Error('network')
|
||||
|
||||
@@ -37,4 +37,24 @@ describe('useLiveSessions', () => {
|
||||
expect(el.exists()).toBe(true)
|
||||
expect(JSON.parse(el.attributes('data-sessions'))).toEqual([])
|
||||
})
|
||||
|
||||
it('startPolling and stopPolling manage interval', async () => {
|
||||
registerEndpoint('/api/live', () => [])
|
||||
registerEndpoint('/api/me', () => ({ id: '1', identifier: 'u', role: 'member' }), { method: 'GET' })
|
||||
const TestComponent = defineComponent({
|
||||
setup() {
|
||||
const { startPolling, stopPolling } = useLiveSessions()
|
||||
return () => h('div', {
|
||||
onClick: () => {
|
||||
startPolling()
|
||||
startPolling()
|
||||
stopPolling()
|
||||
},
|
||||
})
|
||||
},
|
||||
})
|
||||
const wrapper = await mountSuspended(TestComponent)
|
||||
await wrapper.trigger('click')
|
||||
expect(wrapper.exists()).toBe(true)
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user