From 89e5662dd7202a4a027a9e9755816428548eccf1 Mon Sep 17 00:00:00 2001 From: Rhett Trappman Date: Wed, 2 Sep 2026 14:40:05 -0600 Subject: [PATCH 1/3] fix: use documented box selector for devices --- cli/src/commands/devices.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cli/src/commands/devices.js b/cli/src/commands/devices.js index 21d3c3c..4974b47 100644 --- a/cli/src/commands/devices.js +++ b/cli/src/commands/devices.js @@ -4,7 +4,7 @@ const { getClient, resolveBoxGid } = require('../api/client'); * Fetch all devices for a box (API returns a flat array, no pagination). */ async function fetchAll(client, gid) { - const { data } = await client.get('/devices', { params: { gid } }); + const { data } = await client.get('/devices', { params: { box: gid } }); return Array.isArray(data) ? data : (data.results || []); } From da5f94debeea9110f8f96d7080908287319192f9 Mon Sep 17 00:00:00 2001 From: Rhett Trappman Date: Wed, 2 Sep 2026 14:40:10 -0600 Subject: [PATCH 2/3] test: verify device box selector --- test/devices.test.js | 48 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 test/devices.test.js diff --git a/test/devices.test.js b/test/devices.test.js new file mode 100644 index 0000000..22b050c --- /dev/null +++ b/test/devices.test.js @@ -0,0 +1,48 @@ +const test = require('node:test'); +const assert = require('node:assert/strict'); + +test('devices fetch uses the API box selector', async () => { + const originalLoad = require.cache[require.resolve('../cli/src/commands/devices')]; + delete require.cache[require.resolve('../cli/src/commands/devices')]; + + const clientPath = require.resolve('../cli/src/api/client'); + const originalClient = require.cache[clientPath]; + delete require.cache[clientPath]; + + try { + const apiClient = require('../cli/src/api/client'); + const calls = []; + const fakeClient = { + get: async (path, config) => { + calls.push({ path, config }); + return { data: [] }; + } + }; + const originalGetClient = apiClient.getClient; + const originalResolveBoxGid = apiClient.resolveBoxGid; + apiClient.getClient = () => fakeClient; + apiClient.resolveBoxGid = async () => 'box-a'; + + delete require.cache[require.resolve('../cli/src/commands/devices')]; + const Devices = require('../cli/src/commands/devices'); + const originalLog = console.log; + console.log = () => {}; + + try { + await Devices.list({ box: 'box-a' }); + } finally { + console.log = originalLog; + apiClient.getClient = originalGetClient; + apiClient.resolveBoxGid = originalResolveBoxGid; + } + + assert.deepEqual(calls, [ + { path: '/devices', config: { params: { box: 'box-a' } } }, + ]); + } finally { + if (originalClient) require.cache[clientPath] = originalClient; + else delete require.cache[clientPath]; + if (originalLoad) require.cache[require.resolve('../cli/src/commands/devices')] = originalLoad; + else delete require.cache[require.resolve('../cli/src/commands/devices')]; + } +}); From e0a879bd50eee91e8311912d6789db8b87cdaf86 Mon Sep 17 00:00:00 2001 From: Rhett Trappman Date: Wed, 2 Sep 2026 14:40:14 -0600 Subject: [PATCH 3/3] test: enable Node test runner --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 6bbf6ac..2de1b1c 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "fw": "./src/index.js" }, "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" + "test": "node --test" }, "dependencies": { "axios": "^1.6.0",