diff --git a/packages/client/tests/integration/01-discovery.test.ts b/packages/client/tests/integration/01-discovery.test.ts index 699784287a..3a9e171ca2 100644 --- a/packages/client/tests/integration/01-discovery.test.ts +++ b/packages/client/tests/integration/01-discovery.test.ts @@ -36,9 +36,13 @@ describe('Discovery & Connection', () => { // Version should be a semantic version or API version string expect(discovery.version).toMatch(/^v?\d+/); - - // API name should be non-empty - expect(discovery.apiName.length).toBeGreaterThan(0); + + // API name should be non-empty. `apiName` is optional on the discovery + // payload (spec `protocol.zod.ts` keeps it as the deprecated alias for + // `name`), so it is reached optionally and asserted — a missing value + // fails `toBeGreaterThan` rather than being waved through by a `!` or a + // `?? ''` default (#5449). + expect(discovery.apiName?.length).toBeGreaterThan(0); }); }); @@ -56,13 +60,23 @@ describe('Discovery & Connection', () => { test('should resolve API routes from discovery info', async () => { const client = new ObjectStackClient({ baseUrl: TEST_SERVER_URL }); await client.connect(); - - // After connection, client should have discovery info - expect(client.discovery).toBeDefined(); - expect(client.discovery?.version).toBeDefined(); - - // Verify that subsequent API calls can be made (routes are resolved) - // This implicitly tests route resolution + + // After connection, the client should have retained the discovery info. + // `ObjectStackClient` has no public `discovery` property — the one this + // case asserted until #5544 never existed on the class; the payload is + // held on the private `discoveryInfo` field (`src/index.ts`), which is + // what `getRoute()` steers every subsequent call with. It is read here + // through the bracket-notation escape hatch, exactly as this package's + // `src/client.hono.test.ts` already reads the same field — no public API + // is invented on behalf of a suite no type checker had ever compiled. + const discoveryInfo = client['discoveryInfo']; + expect(discoveryInfo).toBeDefined(); + expect(discoveryInfo?.version).toBeDefined(); + + // Route resolution is what this case is named for: the routes map + // `getRoute()` reads has to be populated for subsequent API calls to be + // steered at all. + expect(discoveryInfo?.routes).toBeDefined(); }); }); }); diff --git a/packages/client/tsconfig.test.json b/packages/client/tsconfig.test.json index 2ec76f91f8..f9df0f8d54 100644 --- a/packages/client/tsconfig.test.json +++ b/packages/client/tsconfig.test.json @@ -24,14 +24,16 @@ // Nothing here may loosen a type rule; if a test does not compile, that is // the finding. // -// `include` deliberately stops at `src`, matching the build config's root, and -// none of the files it leaves out carries a `@ts-expect-error`, so no pin is -// hiding there. `tests/integration/` — the suite `vitest.integration.config.ts` -// runs against a live server — is in no tsconfig at all: a second, -// differently-shaped hole (1 file / 3 errors, one of them a real API drift, the -// suite reading a `client.discovery` property `ObjectStackClient` does not -// have) that wants its own change rather than a rider on this one. Filed as -// #5544. +// `include` covers BOTH test roots this package has. `src/**/*` is the layer +// the build config excludes; `tests/**/*` is `tests/integration/`, the suite +// `vitest.integration.config.ts` runs against a live server and the regular +// `vitest.config.ts` excludes. Until #5544 it was named by no `include` and no +// `exclude` anywhere — the #5476 shape, outside every program rather than +// inside an excluded region — so neither vitest's regular run nor tsc ever read +// it, and it had drifted onto a `client.discovery` property `ObjectStackClient` +// does not have. Compiling it does NOT run it: the vitest split is unchanged, +// the suite still needs a server. tsc reading a file is the cheaper of the two +// gates and the only one that works without one. // // The per-file ledger beside this config (`test-typecheck-debt.json`) is small // on purpose. Under the repaired config the whole test layer came to 13 errors; @@ -57,6 +59,6 @@ "lib": ["ES2022", "DOM", "DOM.Iterable"], "types": ["node"] }, - "include": ["src/**/*"], + "include": ["src/**/*", "tests/**/*"], "exclude": ["node_modules", "dist"] }