feat: select the TechLog Studio adapter from runtime configuration
Adds TECH_LOG_STUDIO_SOURCE (MOCK | HTTP, default MOCK) to the V2 runtime
config schema so a build can switch createTechLogFeatureInstalledInput
between the mock and HTTP Studio gateways without a rebuild. V1 documents
predate the key and always normalize to MOCK. The HTTP gateway is
constructed with only { operations } per Task 4's actual signature -
no CSRF provider is wired here; that lands with attachCredentials at a
later composition-root task.
Updates every existing Studio test call site to the new required
createTechLogFeatureInstalledInput(context) signature via a shared
tests/helpers/studio-install-context.ts MOCK fixture, so the whole
existing Studio suite keeps exercising the mock adapter unchanged.
This commit is contained in:
@@ -6,6 +6,7 @@ import { MemoryRouter } from "react-router-dom";
|
||||
import { afterAll, afterEach, beforeAll, describe, expect, it, vi } from "vitest";
|
||||
|
||||
import { createTechLogFeatureInstalledInput } from "../../../src/features/tech-log/adapters/create-tech-log-feature-input.ts";
|
||||
import { MOCK_STUDIO_INSTALL_CONTEXT } from "../../helpers/studio-install-context.ts";
|
||||
import { FIXTURE_IDS } from "../../../src/features/tech-log/adapters/mock/fixtures.ts";
|
||||
import type { StudioGateway } from "../../../src/features/tech-log/application/ports/studio-gateway.ts";
|
||||
import { DocumentEditorScreen } from "../../../src/features/tech-log/presentation/studio/components/document-editor-screen.tsx";
|
||||
@@ -39,7 +40,7 @@ afterEach(() => vi.restoreAllMocks());
|
||||
|
||||
function renderStudio(
|
||||
child: React.ReactNode,
|
||||
gateway: StudioGateway = createTechLogFeatureInstalledInput().input.createStudioGateway(),
|
||||
gateway: StudioGateway = createTechLogFeatureInstalledInput(MOCK_STUDIO_INSTALL_CONTEXT).input.createStudioGateway(),
|
||||
) {
|
||||
return render(
|
||||
<MemoryRouter initialEntries={["/studio"]}>
|
||||
@@ -51,7 +52,7 @@ function renderStudio(
|
||||
describe("TechLog Studio validation workflow", () => {
|
||||
it("reruns stale saved validation, reports exact freshness copy, and creates a new key per command", async () => {
|
||||
const user = userEvent.setup();
|
||||
const base = createTechLogFeatureInstalledInput().input.createStudioGateway();
|
||||
const base = createTechLogFeatureInstalledInput(MOCK_STUDIO_INSTALL_CONTEXT).input.createStudioGateway();
|
||||
const keys: string[] = [];
|
||||
const gateway = {
|
||||
...base,
|
||||
@@ -80,7 +81,7 @@ describe("TechLog Studio validation workflow", () => {
|
||||
|
||||
it("orders validation issues and links each JSON pointer to the affected editor field", async () => {
|
||||
const user = userEvent.setup();
|
||||
const gateway = createTechLogFeatureInstalledInput().input.createStudioGateway();
|
||||
const gateway = createTechLogFeatureInstalledInput(MOCK_STUDIO_INSTALL_CONTEXT).input.createStudioGateway();
|
||||
const view = renderStudio(
|
||||
<ValidationScreen documentId={FIXTURE_IDS.edgeTokenQuestion} />,
|
||||
gateway,
|
||||
@@ -109,7 +110,7 @@ describe("TechLog Studio validation workflow", () => {
|
||||
});
|
||||
|
||||
it("aborts a route-obsolete validation read without surfacing an abort error", async () => {
|
||||
const base = createTechLogFeatureInstalledInput().input.createStudioGateway();
|
||||
const base = createTechLogFeatureInstalledInput(MOCK_STUDIO_INSTALL_CONTEXT).input.createStudioGateway();
|
||||
let firstSignal: AbortSignal | undefined;
|
||||
const getDocument = vi
|
||||
.fn<StudioGateway["getDocument"]>()
|
||||
@@ -144,7 +145,7 @@ describe("TechLog Studio validation workflow", () => {
|
||||
describe("TechLog Studio Public Preview workflow", () => {
|
||||
it("creates a missing preview, shows the current state, and renders the shared Public document", async () => {
|
||||
const user = userEvent.setup();
|
||||
const base = createTechLogFeatureInstalledInput().input.createStudioGateway();
|
||||
const base = createTechLogFeatureInstalledInput(MOCK_STUDIO_INSTALL_CONTEXT).input.createStudioGateway();
|
||||
const keys: string[] = [];
|
||||
const gateway = {
|
||||
...base,
|
||||
@@ -200,7 +201,7 @@ describe("TechLog Studio Public Preview workflow", () => {
|
||||
});
|
||||
|
||||
it("shows retryable preview-load errors and retries the read", async () => {
|
||||
const base = createTechLogFeatureInstalledInput().input.createStudioGateway();
|
||||
const base = createTechLogFeatureInstalledInput(MOCK_STUDIO_INSTALL_CONTEXT).input.createStudioGateway();
|
||||
const getDocument = vi
|
||||
.fn<StudioGateway["getDocument"]>()
|
||||
.mockRejectedValueOnce(new Error("offline"))
|
||||
|
||||
Reference in New Issue
Block a user