import { describe, it, expect } from 'vitest' import { Device, OnboardingStatus } from '../../../../app/domain/device/device.js' import { DeviceId } from '../../../../app/domain/device/device_id.js' import { DeviceParameter, DeviceProperty } from '../../../../app/domain/device/device_parameter.js' import { ParameterType } from '../../../../app/domain/shared/types.js' function makeDevice(): Device { return new Device(new DeviceId('Sagemcom', '10:6f:3f', 'Fast5360', 'SN123')) } describe('Device.gpnStatus', () => { it('defaults to "unknown"', () => { expect(makeDevice().gpnStatus).toBe('unknown') }) it('can be set to "supported"', () => { const device = makeDevice() device.setGpnStatus('supported') expect(device.gpnStatus).toBe('supported') }) it('can be set to "unsupported"', () => { const device = makeDevice() device.setGpnStatus('unsupported') expect(device.gpnStatus).toBe('unsupported') }) it('can be changed back to "unknown"', () => { const device = makeDevice() device.setGpnStatus('supported') device.setGpnStatus('unknown') expect(device.gpnStatus).toBe('unknown') }) it('is included in the snapshot', () => { const device = makeDevice() device.setGpnStatus('unsupported') expect(device.toSnapshot().gpnStatus).toBe('unsupported') }) it('snapshot reflects the latest status', () => { const device = makeDevice() device.setGpnStatus('supported') device.setGpnStatus('unsupported') expect(device.toSnapshot().gpnStatus).toBe('unsupported') }) }) describe('Device.toSnapshot', () => { it('includes gpnStatus alongside other fields', () => { const device = makeDevice() device.setGpnStatus('supported') const snapshot = device.toSnapshot() expect(snapshot).toMatchObject({ gpnStatus: 'supported', onboardingStatus: OnboardingStatus.PENDING, isOnline: false, parameters: [], properties: [], }) }) it('snapshot parameters/properties are consistent with gpnStatus semantics', () => { const device = makeDevice() device.setGpnStatus('supported') device.setParameter(new DeviceParameter('Device.ManagementServer.URL', 'http://acs', ParameterType.STRING)) device.setProperty(new DeviceProperty('Device.DeviceInfo.Manufacturer', 'Sagemcom', ParameterType.STRING)) const snapshot = device.toSnapshot() expect(snapshot.gpnStatus).toBe('supported') expect(snapshot.parameters.map((p) => p.name)).toContain('Device.ManagementServer.URL') expect(snapshot.properties.map((p) => p.name)).toContain('Device.DeviceInfo.Manufacturer') }) })