diff --git a/generators/cli/changes/unreleased/fix-wire-test-no-pager.yml b/generators/cli/changes/unreleased/fix-wire-test-no-pager.yml new file mode 100644 index 000000000000..5bb056083616 --- /dev/null +++ b/generators/cli/changes/unreleased/fix-wire-test-no-pager.yml @@ -0,0 +1,12 @@ +- summary: | + `generateWireTests: true` no longer emits a suite in which every test + fails. The harness passed `--no-pager` on every invocation, but the CLI + registers that flag only on operations that declare pagination metadata, + so on a spec with no `x-fern-pagination` markers clap rejected the whole + command line with "unexpected argument" — 100% of cases, not a subset. + The flag was also inert there: the pager only spawns under `--page-all`, + which no case passes. Reproduced end to end on the + `query-parameters-openapi:with-wire-tests` fixture (0/2 passing before, + 2/2 after); that fixture also declares no pagination, which is why the + breakage was not caught when the registration gate landed. + type: fix diff --git a/generators/cli/src/__test__/wireTests.test.ts b/generators/cli/src/__test__/wireTests.test.ts index 4bac6ad207a2..eb1f0053d164 100644 --- a/generators/cli/src/__test__/wireTests.test.ts +++ b/generators/cli/src/__test__/wireTests.test.ts @@ -353,6 +353,31 @@ describe("renderWireTestHarness", () => { expect(rust).toContain("match_header_regex(h.name.as_str()"); }); + it("passes only flags the SDK registers on every operation", () => { + // A flag the SDK registers conditionally cannot be pushed + // unconditionally here: clap rejects the whole invocation with + // "unexpected argument", so one mismatched flag fails 100% of cases on + // any spec that misses the condition — not one case, the entire suite. + // + // This happened with --no-pager, which the SDK registers only inside + // `if method_has_pagination(...)`. Every generated suite for a spec + // without pagination metadata failed outright, and the seed fixture + // that would have caught it also has no pagination markers. + const rust = renderWireTestHarness({ binaryName: "acme-cli", cases: [searchCase] }); + const pushedFlags = [...rust.matchAll(/args\.push\("(--[a-z0-9-]+)"\.to_string\(\)\)/g)].map( + (match) => match[1] + ); + // Registered unconditionally in `commands::build_cli` for every method. + const alwaysRegistered = ["--base-url", "--params", "--json"]; + expect(pushedFlags.length).toBeGreaterThan(0); + for (const flag of pushedFlags) { + expect( + alwaysRegistered, + `${flag} is pushed unconditionally; confirm the SDK registers it on every operation` + ).toContain(flag); + } + }); + it("mirrors the SDK's namespace stutter-elision when resolving command chains", () => { const rust = renderWireTestHarness({ binaryName: "acme-cli", cases: [searchCase] }); // The harness must replicate `merge_into_path`'s stutter elision so a diff --git a/generators/cli/src/wireTests/harness.ts b/generators/cli/src/wireTests/harness.ts index bb5a61bf55cd..9254a8ac5602 100644 --- a/generators/cli/src/wireTests/harness.ts +++ b/generators/cli/src/wireTests/harness.ts @@ -908,7 +908,11 @@ async fn run_case(id: &str) { let mut args: Vec = command.chain.clone(); args.push("--base-url".to_string()); args.push(server.uri()); - args.push("--no-pager".to_string()); + // Deliberately no --no-pager: it is registered only on operations that + // declare pagination metadata, so pushing it unconditionally made clap + // reject every invocation ("unexpected argument '--no-pager'") on any spec + // without pagination markers — the whole suite, not one case. It was also + // inert here: the pager only spawns under --page-all, which no case passes. if !case.params.is_empty() { // The CLI reads path params off the baked spec by their wire name, which // can differ from the manifest's (IR-renamed) name — remap those keys so diff --git a/seed/cli/query-parameters-openapi/with-wire-tests/tests/wire_test.rs b/seed/cli/query-parameters-openapi/with-wire-tests/tests/wire_test.rs index ac14b070187f..bc57d3a3807c 100644 --- a/seed/cli/query-parameters-openapi/with-wire-tests/tests/wire_test.rs +++ b/seed/cli/query-parameters-openapi/with-wire-tests/tests/wire_test.rs @@ -874,7 +874,11 @@ async fn run_case(id: &str) { let mut args: Vec = command.chain.clone(); args.push("--base-url".to_string()); args.push(server.uri()); - args.push("--no-pager".to_string()); + // Deliberately no --no-pager: it is registered only on operations that + // declare pagination metadata, so pushing it unconditionally made clap + // reject every invocation ("unexpected argument '--no-pager'") on any spec + // without pagination markers — the whole suite, not one case. It was also + // inert here: the pager only spawns under --page-all, which no case passes. if !case.params.is_empty() { // The CLI reads path params off the baked spec by their wire name, which // can differ from the manifest's (IR-renamed) name — remap those keys so