diff --git a/tests/boundary/cli/cliOutput.test.ts b/tests/boundary/cli/cliOutput.test.ts index 61dfdf19e52..d6b64546c9e 100644 --- a/tests/boundary/cli/cliOutput.test.ts +++ b/tests/boundary/cli/cliOutput.test.ts @@ -273,6 +273,11 @@ describe("CLI output flag value forms", () => { }); describe("CLI output filter slice validation", () => { + const freshProviderFilter = (filter: string) => ({ + freshProcess: true, + arguments: ["providers", "--json", "--filter-output", filter], + }); + it.each([ "providers[", "providers[0,1].name[", @@ -342,15 +347,9 @@ describe("CLI output filter slice validation", () => { workspaceCliTest( "refuses extra slice bounds instead of returning a partial selection", async ({ cli }) => { - const result = await cli.run({ - freshProcess: true, - arguments: [ - "providers", - "--json", - "--filter-output", - "capabilities[0,1,2].provider.id", - ], - }); + const result = await cli.run( + freshProviderFilter("capabilities[0,1,2].provider.id"), + ); expect(result.exitCode).toBe(1); expect(result.json).toMatchObject({ ok: false, @@ -366,15 +365,9 @@ describe("CLI output filter slice validation", () => { workspaceCliTest( "rejects a nonnumeric slice bound instead of returning no rows", async ({ cli }) => { - const result = await cli.run({ - freshProcess: true, - arguments: [ - "providers", - "--json", - "--filter-output", - "capabilities[0,2x].provider.id", - ], - }); + const result = await cli.run( + freshProviderFilter("capabilities[0,2x].provider.id"), + ); expect(result.exitCode).toBe(1); expect(result.json).toMatchObject({ ok: false, @@ -390,15 +383,9 @@ describe("CLI output filter slice validation", () => { "rejects non-integer array indices with a CLI filter error", async ({ cli }) => { for (const index of ["1.75", "-1.75", "Infinity"]) { - const result = await cli.run({ - freshProcess: true, - arguments: [ - "providers", - "--json", - "--filter-output", - `capabilities[${index}].provider.id`, - ], - }); + const result = await cli.run( + freshProviderFilter(`capabilities[${index}].provider.id`), + ); expect(result.exitCode).toBe(1); expect(result.json).toMatchObject({ ok: false,