Files
clean-architecture-frontend…/tests/recipes/indexeddb-feature-capability.test.ts
T
DongHyeonka b72cd7d4a7 test(fixtures): local-draft 샘플을 IndexedDB 소비자 fixture로 옮긴다
src/features/local-draft-feature는 기능이 아니라 IndexedDB recipe의
소비자다. 시험 5개와 recipe가 쓰고, 그래서 생성기에 NOT_A_FEATURE
예외가 있었다(S4 3.1절 S-3).

코드를 tests/fixtures/indexeddb-consumer/로 옮기고 import만 고쳤다.
NOT_A_FEATURE 표식은 이 폴더만 썼고 다운스트림 둘에도 없어 생성기에서
지웠다. 선언 없는 폴더는 밖으로 옮기라는 메시지로 실패한다. 매뉴얼
오류표, README, starter-experience, capability-consumer-experience,
patterns를 고쳤다.

위험: fixture는 기능 폴더 밖이라 기능 계층 규칙(dependency-cruiser)이
걸리지 않는다. recipe가 tests/ 아래 파일을 type import한다.

검증(desktop): test:contract, test:recipes, test:browser-capabilities,
test:unit 통과.
2026-11-08 13:51:55 +09:00

55 lines
2.1 KiB
TypeScript

import { describe, expect, it } from "vitest";
import { composeFeatureAdapterInputs } from "../../src/features/feature-adapter-contribution.ts";
import { LOCAL_DRAFT_FEATURE_ADAPTER_CONTRIBUTION } from "../fixtures/indexeddb-consumer/adapters/create-local-draft-feature-input.ts";
import { createLocalDraftIndexedDbCapability } from "../../recipes/frontend-capabilities/indexeddb-feature-capability.ts";
import { MemoryIndexedDbFactory } from "../helpers/memory-indexeddb.ts";
describe("IndexedDB feature capability recipe (09-05)", () => {
it("composes local-draft over the recipe's IndexedDB capability", async () => {
const memory = new MemoryIndexedDbFactory();
const capability = createLocalDraftIndexedDbCapability({
scope: Object.freeze({
authorityToken: "a1b2c3d4e5f60718293a4b5c6d7e8f90",
namespaceToken: "n1b2c3d4e5f60718293a4b5c6d7e8f90",
partitionToken: "p1b2c3d4e5f60718293a4b5c6d7e8f90",
accountScope: "ORIGIN_SHARED" as const,
}),
authorizeLifecycle: () => ({ authorized: false }),
factory: memory.factory,
});
try {
await expect(capability.open()).resolves.toEqual({
ok: true,
value: undefined,
});
const inputs = composeFeatureAdapterInputs(
Object.freeze([LOCAL_DRAFT_FEATURE_ADAPTER_CONTRIBUTION] as const),
Object.freeze(["local-draft"]),
Object.freeze({ indexedDb: capability.indexedDb }),
);
const localDraft = inputs["local-draft"];
if (!localDraft) throw new Error("local-draft input was not composed");
const draft = Object.freeze({
draftId: "draft-1",
title: "Architecture notes",
body: "Stored through the recipe capability.",
});
await expect(
localDraft.saveDraft({
draft,
expectedRevision: null,
idempotencyKey: "local-draft-create-1",
}),
).resolves.toEqual({ ok: true, value: { revision: 1 } });
await expect(localDraft.findDraft("draft-1")).resolves.toEqual({
ok: true,
value: { draft, revision: 1 },
});
} finally {
capability.close();
}
});
});