test(cli): share fresh providers filter fixtures (#17020)

This commit is contained in:
Vincent Koc authored and GitHub committed 2026-12-05 18:12:14 +08:00
1 parent 57a33161a3
commit a86d043048
1 file changed
+14 -27
+14 -27
View File
@@ -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,