diff --git a/src/types/device-overall-status.ts b/src/types/device-overall-status.ts index 30825fc05..82c0aed38 100644 --- a/src/types/device-overall-status.ts +++ b/src/types/device-overall-status.ts @@ -8,4 +8,7 @@ export enum DeviceOverallStatus { ORDERED = 'ordered', PREPARING = 'preparing', SHIPPED = 'shipped', + OPERATIONAL = 'operational', + DISCONNECTED = 'disconnected', + REDUCED_FUNCTIONALITY = 'reduced-functionality', } diff --git a/tests/integration/models/device.spec.ts b/tests/integration/models/device.spec.ts index 2d0198bd4..9f6c02609 100644 --- a/tests/integration/models/device.spec.ts +++ b/tests/integration/models/device.spec.ts @@ -29,6 +29,7 @@ import { } from './tags'; import type * as tagsHelper from './tags'; import type * as BalenaSdk from '../../..'; +import { deviceStatusAdapter } from '../utils'; const makeRequest = async (url) => { try { @@ -2129,7 +2130,7 @@ describe('Device Model', function () { const status = await balena.models.device.getStatus( this.device[prop], ); - expect(status).to.equal('idle'); + expect(deviceStatusAdapter(status)).to.equal('idle'); }); }); }); @@ -2168,6 +2169,9 @@ describe('Device Model', function () { const device = await balena.models.device.get(this.device.uuid, { $select: ['overall_status', 'overall_progress'], }); + device.overall_status = deviceStatusAdapter( + device.overall_status, + ) as BalenaSdk.DeviceOverallStatus; return expect(device).to.deep.match({ overall_status: 'idle', overall_progress: null, diff --git a/tests/integration/utils.ts b/tests/integration/utils.ts index d6f70b22c..72cb9635c 100644 --- a/tests/integration/utils.ts +++ b/tests/integration/utils.ts @@ -1,3 +1,4 @@ +import type { DeviceOverallStatus } from '../..'; import type { Dictionary } from '../../typings/utils'; import { balena } from './setup'; @@ -44,3 +45,16 @@ export const getParam = ( return resource[field]; }; + +export const deviceStatusAdapter = (status: DeviceOverallStatus | string) => { + switch (status) { + case 'operational': + return 'idle'; + case 'reduced-functionality': + return 'idle'; + case 'disconnected': + return 'offline'; + default: + return status; + } +};