Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DO NOT MERGE - v7 API] Update device overall status #1413

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/types/device-overall-status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,7 @@ export enum DeviceOverallStatus {
ORDERED = 'ordered',
PREPARING = 'preparing',
SHIPPED = 'shipped',
OPERATIONAL = 'operational',
DISCONNECTED = 'disconnected',
REDUCED_FUNCTIONALITY = 'reduced-functionality',
}
6 changes: 5 additions & 1 deletion tests/integration/models/device.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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');
});
});
});
Expand Down Expand Up @@ -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,
Expand Down
14 changes: 14 additions & 0 deletions tests/integration/utils.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { DeviceOverallStatus } from '../..';
import type { Dictionary } from '../../typings/utils';
import { balena } from './setup';

Expand Down Expand Up @@ -44,3 +45,16 @@ export const getParam = <T>(

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;
}
};
Loading