From d73c8b7b9cbf296cc6d841fdaf12da8572e76a7d Mon Sep 17 00:00:00 2001 From: Robert DeLuca Date: Sun, 8 Feb 2026 22:00:39 -0600 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix=20comparisons=20and=20builds?= =?UTF-8?q?=20passing=20object=20instead=20of=20string=20to=20getBuild?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit getBuild() expects a string for the include param, but both commands were passing { include: 'comparisons' } which serialized to [object Object] in the query string — causing the API to return empty comparisons. --- src/commands/builds.js | 2 +- src/commands/comparisons.js | 4 +-- tests/commands/builds.test.js | 44 ++++++++++++++++++++++++++++++ tests/commands/comparisons.test.js | 22 +++++++++++++++ 4 files changed, 68 insertions(+), 4 deletions(-) diff --git a/src/commands/builds.js b/src/commands/builds.js index 13ed731..137541d 100644 --- a/src/commands/builds.js +++ b/src/commands/builds.js @@ -60,7 +60,7 @@ export async function buildsCommand( if (options.build) { output.startSpinner('Fetching build...'); let include = options.comparisons ? 'comparisons' : undefined; - let response = await getBuild(client, options.build, { include }); + let response = await getBuild(client, options.build, include); output.stopSpinner(); let build = response.build || response; diff --git a/src/commands/comparisons.js b/src/commands/comparisons.js index ecdfd8b..e734c4b 100644 --- a/src/commands/comparisons.js +++ b/src/commands/comparisons.js @@ -78,9 +78,7 @@ export async function comparisonsCommand( // Get comparisons for a specific build if (options.build) { output.startSpinner('Fetching comparisons for build...'); - let response = await getBuild(client, options.build, { - include: 'comparisons', - }); + let response = await getBuild(client, options.build, 'comparisons'); output.stopSpinner(); let build = response.build || response; diff --git a/tests/commands/builds.test.js b/tests/commands/builds.test.js index 6d6bf1b..678192d 100644 --- a/tests/commands/builds.test.js +++ b/tests/commands/builds.test.js @@ -144,6 +144,50 @@ describe('commands/builds', () => { assert.strictEqual(dataCall.args[0].id, 'build-1'); }); + it('passes include as a string to getBuild when --comparisons is set', async () => { + let output = createMockOutput(); + let capturedInclude = null; + + await buildsCommand( + { build: 'build-1', comparisons: true }, + { json: true }, + { + loadConfig: async () => ({ apiKey: 'test-token' }), + createApiClient: () => ({}), + getBuild: async (_client, _buildId, include) => { + capturedInclude = include; + return { build: { id: 'build-1', status: 'completed' } }; + }, + output, + exit: () => {}, + } + ); + + assert.strictEqual(capturedInclude, 'comparisons'); + }); + + it('passes undefined include to getBuild when --comparisons is not set', async () => { + let output = createMockOutput(); + let capturedInclude = 'NOT_CALLED'; + + await buildsCommand( + { build: 'build-1' }, + { json: true }, + { + loadConfig: async () => ({ apiKey: 'test-token' }), + createApiClient: () => ({}), + getBuild: async (_client, _buildId, include) => { + capturedInclude = include; + return { build: { id: 'build-1', status: 'completed' } }; + }, + output, + exit: () => {}, + } + ); + + assert.strictEqual(capturedInclude, undefined); + }); + it('passes filters to API', async () => { let output = createMockOutput(); let capturedFilters = null; diff --git a/tests/commands/comparisons.test.js b/tests/commands/comparisons.test.js index 6c6f56a..a5430bd 100644 --- a/tests/commands/comparisons.test.js +++ b/tests/commands/comparisons.test.js @@ -137,6 +137,28 @@ describe('commands/comparisons', () => { assert.strictEqual(dataCall.args[0].summary.failed, 1); }); + it('passes include as a string to getBuild, not an object', async () => { + let output = createMockOutput(); + let capturedInclude = null; + + await comparisonsCommand( + { build: 'build-1' }, + { json: true }, + { + loadConfig: async () => ({ apiKey: 'test-token' }), + createApiClient: () => ({}), + getBuild: async (_client, _buildId, include) => { + capturedInclude = include; + return { build: { id: 'build-1', comparisons: [] } }; + }, + output, + exit: () => {}, + } + ); + + assert.strictEqual(capturedInclude, 'comparisons'); + }); + it('searches comparisons by name', async () => { let output = createMockOutput(); let capturedName = null;