`PublicContentQueries` returned arrays, not promises. That signature is only implementable by something already in memory, so the port could hold exactly one adapter — the bundled fixture — and no amount of configuration could put the public site on the backend. Turning it async is the change that makes a second adapter possible; the adapter itself follows. The markup is untouched. Every page reads a value and hands it to a presentational component, so the shape those components receive is mapped at the adapter boundary and nothing below the page changes. Screens load through one query, not one per read. Several pages read in a loop — the home timeline walks every project for its activity, the explore filter walks search results to resolve titles — and a hook per read would mean a variable number of hooks per render, which React forbids. `usePublicContent` takes the whole screen's reads as one loader, where a loop is a loop and `Promise.all` is available; the loops that used to be N sequential lookups now issue together. Two places deliberately do not show the loading surface. The explore filter sits inside a page that already renders one, so a second skeleton would move the layout under it — it keeps its structure and fills its options in when they arrive. The search dialog is a type-ahead: re-querying per keystroke would replace the results with a skeleton on every key, so it loads the catalog once and applies the same predicate locally. `usePublicContent` requires an object because `undefined` is how the query layer says "no result yet". A loader returning the record itself would make a missing slug indistinguishable from a request in flight, and the page would sit on a skeleton instead of rendering its not-found route. Studio's `resolvePublishedLabel` stays synchronous. It is called from inside the public renderer, so making it async would push awaits through the render tree; the shell loads the catalog once and the callback remains a lookup. The component tests now assemble the query providers the running app assembles. Without them the render throws "No QueryClient set" — not a harness quirk, but the same failure the app would produce if it were mounted without its query layer.
32 lines
1.4 KiB
TypeScript
32 lines
1.4 KiB
TypeScript
import { createCsrfTokenProvider } from "../../src/features/tech-log/adapters/http/studio-session-csrf.ts";
|
|
import type { TechLogInstallContext } from "../../src/features/tech-log/adapters/create-tech-log-feature-input.ts";
|
|
|
|
/**
|
|
* The install context the existing Studio test suite composes against. It
|
|
* always selects the mock adapter, so `contractOperations` is a throwing stub
|
|
* — `createTechLogFeatureInstalledInput` never reads it on the MOCK branch.
|
|
*
|
|
* `createStudioAssetGateway` also selects a mock adapter on `studioSource:
|
|
* "MOCK"` (Task 10 fix round 1, I2) that shares its Asset store with
|
|
* `createStudioGateway`'s mock, so `contractOperations`/`csrf` still never
|
|
* see real use here. `apiBaseUrl`/`requestTimeoutMs` stay well-formed anyway
|
|
* — they are read on the HTTP branch only, but this context is a plain
|
|
* value, not a conditional one.
|
|
*/
|
|
export const MOCK_STUDIO_INSTALL_CONTEXT: TechLogInstallContext = Object.freeze({
|
|
studioSource: "MOCK",
|
|
publicSource: "MOCK",
|
|
contractOperations: Object.freeze({
|
|
async execute() {
|
|
throw new Error("contract executor is not used by the mock Studio gateway");
|
|
},
|
|
}),
|
|
apiBaseUrl: "http://mock-studio.test/",
|
|
requestTimeoutMs: 10_000,
|
|
csrf: createCsrfTokenProvider({
|
|
async execute() {
|
|
throw new Error("CSRF provider is not used by the mock Studio gateway");
|
|
},
|
|
}),
|
|
});
|