Files
tech-log-frontend/tests/features/tech-log/runtime-composition.test.ts
T
DongHyeonka c80320dfc7 chore: sync the frontend template from ebea300 to af3d8e6
Carries 359 template commits, tag v0.2.0 plus one documentation commit: the
generator-built feature index with its app, bounded-context and feature
declarations, the src/platform kernel and scale tooling, the 2026-09-24 src
review fixes, and the 2026-09-25 maturity review round with its CHANGELOG
[보안]/[계약] rows. 691 of the 824 template paths are applied, 85 of them
merged with product changes; 127 are not carried.

Product identity is unchanged: name, version 0.1.0, routes, design and the
TechLog domain.

Three decisions worth naming. TechLog stays composed directly, as the last
two syncs recorded; its directory carries a NOT_INSTALLED marker that says so,
and every installed-* composer takes the template's projection with TechLog
added on top. The reference sample is no longer installed: the template now
installs a feature only through feature-module.ts and context-routes.ts,
which load the screens this product deleted, so its three operations, six
schemas and one topic leave the registries, recorded as registry change
evidence. And AppRouter mounts the platform and TechLog routes only; the
template's bounded-context route gateway waits for a generator-installed
feature.

Required fixes: readSubject on the BFF session owner (without it every HTTP
Studio session would close as integration-failed), zod through the facade in
nine TechLog files, noUnusedLocals, and public/config.json written out to
match the local profile. Derived baselines were recomputed after reproducing
both sides' values: CI contract 101 commands / 106 references / 141
artifacts, gate shape c9adcf85; registry approval 2dc6c3a3; the runtime
config schema baseline equals the schema at 8210d48.

Verified here: types, lint, architecture, adapter inventory, CI contract,
i18n, design system, diagnostics, browser security, dev release manifest,
TechLog contract and build pass; 220 component, 155 integration, 15
contract, 418 TechLog, 43 reference-feature, 18 recipe and 46
release-coherence tests pass, and 2381 of 2383 unit tests. Reproduced at
8210d48 first and unchanged: check:registries (byte-identical),
test:runtime-schema, verify:documentation. Brought by the template and
escalated rather than suppressed: check:request-fanout on TechLog's cursor
pagination, check:remediation-ledger (fails upstream too), the shared-chunk
hash test, and the registry-dependent sample removal and second-feature
tests. Playwright suites were not run.

Full record, the five open questions and the follow-ups in
docs/operations/template-sync-2026-09-29.md.

(cherry picked from commit b2170cf265dea45dc9cc05d3c61e627e97f31cdb)
2026-11-12 08:28:54 +09:00

159 lines
6.1 KiB
TypeScript

import assert from "node:assert/strict";
import { test } from "vitest";
import type { ApplicationFeatureInputs } from "../../../src/application/ports/in/application-api.ts";
import { createInstalledFeatureInputs } from "../../../src/features/installed-feature-adapters.ts";
import { FIXTURE_IDS } from "../../../src/features/tech-log/adapters/mock/fixtures.ts";
import { createCsrfTokenProvider } from "../../../src/features/tech-log/adapters/http/studio-session-csrf.ts";
import type { TechLogFeatureInput } from "../../../src/features/tech-log/application/tech-log-feature-input.ts";
import type { WorkingCopy } from "../../../src/features/tech-log/contracts/studio/contract.ts";
import { studioAssetGatewayFromApplication, studioGatewayFromApplication } from "../../helpers/studio-application-gateway-adapter.ts";
type Equal<Left, Right> =
(<Value>() => Value extends Left ? 1 : 2) extends <Value>() =>
Value extends Right ? 1 : 2
? true
: false;
type Expect<Value extends true> = Value;
type RequiredKeys<Value> = {
[Key in keyof Value]-?: Record<never, never> extends Pick<Value, Key>
? never
: Key;
}[keyof Value];
type InstalledInputs = ReturnType<typeof createInstalledFeatureInputs>;
/**
* Template sync (ebea300). The composed map became
* `Partial<ApplicationFeatureInputs>` upstream, and the template's new
* local-draft demonstration feature declares a third key, so `keyof` no longer
* says which features a build installs — every declared feature is a key,
* present or not. What this product needs held is the split itself: TechLog is
* its own domain and is always composed, and a manifest-governed feature stays
* optional because a build may narrow it out.
*/
type _TechLogIsAlwaysInstalled = Expect<
Equal<RequiredKeys<InstalledInputs>, "tech-log">
>;
type _ReferenceFeatureStaysOptional = Expect<
Equal<
"reference-feature" extends RequiredKeys<InstalledInputs> ? true : false,
false
>
>;
type _TechLogRegistryValueIsExact = Expect<
Equal<ApplicationFeatureInputs["tech-log"], TechLogFeatureInput>
>;
void (0 as unknown as _TechLogIsAlwaysInstalled);
void (0 as unknown as _ReferenceFeatureStaysOptional);
void (0 as unknown as _TechLogRegistryValueIsExact);
function inputOf(document: WorkingCopy) {
const { id, version, updatedAt, ...input } = document;
void id;
void version;
void updatedAt;
return input;
}
function installedInputs(
studioSource: "MOCK" | "HTTP" = "MOCK",
publicSource: "MOCK" | "HTTP" = "MOCK",
): InstalledInputs {
return createInstalledFeatureInputs({
studioSource,
publicSource,
// Template sync (ebea300). The platform capability the manifest-governed
// contributions declare in `needs`. Composition never calls it here.
http: {
async execute() {
throw new Error("platform executor is not used by composition tests");
},
},
apiBaseUrl: "http://composition.test/",
requestTimeoutMs: 10_000,
csrf: createCsrfTokenProvider({
async execute() {
throw new Error("CSRF provider is not used by composition tests");
},
}),
});
}
test("installs TechLog through application-facing inputs", async () => {
const installed = installedInputs();
// Template sync (af3d8e6). The reference sample is no longer installed
// (src/features/reference-feature/NOT_INSTALLED), so TechLog is the only
// input; it is composed directly and cannot be narrowed out.
assert.deepEqual(Object.keys(installed), ["tech-log"]);
assert.deepEqual(Object.keys(installed["tech-log"]).sort(), [
"createStudioApplication",
"publicContent",
]);
assert.equal(Object.isFrozen(installed), true);
assert.equal(Object.isFrozen(installed["tech-log"]), true);
assert.equal(Object.isFrozen(installed["tech-log"].publicContent), true);
assert.equal(
(await installed["tech-log"].publicContent.getRelease("0.1.0"))?.title,
"TechLog Public·Studio 경계를 확정했습니다",
);
});
test("selects the mock gateway by default and the HTTP gateway when switched", async () => {
const mockGateway = studioGatewayFromApplication(installedInputs("MOCK")["tech-log"].createStudioApplication());
const httpGateway = studioGatewayFromApplication(installedInputs("HTTP")["tech-log"].createStudioApplication());
// The mock reads an in-memory fixture immediately. HTTP defers to the
// (here, throwing) contract executor, so it rejects instead.
await assert.doesNotReject(mockGateway.getDashboard());
await assert.rejects(httpGateway.getDashboard());
});
test("each createStudioGateway call owns an isolated mutable Studio session", async () => {
const installed = installedInputs();
const first = studioGatewayFromApplication(installed["tech-log"].createStudioApplication());
const second = studioGatewayFromApplication(installed["tech-log"].createStudioApplication());
assert.notEqual(first, second);
const firstBefore = await first.getDocument(FIXTURE_IDS.fetchJoinCase);
const secondBefore = await second.getDocument(FIXTURE_IDS.fetchJoinCase);
assert.equal(firstBefore.document.title, secondBefore.document.title);
const saved = await first.saveDocument(
firstBefore.document.id,
{
expectedVersion: firstBefore.document.version,
document: {
...inputOf(firstBefore.document),
title: "첫 번째 세션에서만 수정",
},
},
{ idempotencyKey: "session-isolation" },
);
assert.equal(saved.document.title, "첫 번째 세션에서만 수정");
assert.equal(
(await second.getDocument(FIXTURE_IDS.fetchJoinCase)).document.title,
secondBefore.document.title,
);
assert.equal(
(
await installed["tech-log"].publicContent.getRecord(
"CASE",
"collection-fetch-join-pagination",
)
)?.title,
"컬렉션 Fetch Join과 페이징은 왜 충돌하는가",
);
});
test("each Studio session gets its own asset gateway instance", () => {
const installed = installedInputs("HTTP");
assert.notEqual(
studioAssetGatewayFromApplication(installed["tech-log"].createStudioApplication()),
studioAssetGatewayFromApplication(installed["tech-log"].createStudioApplication()),
);
});