From b72cd7d4a75ff4d565b05fa7007fb4ce9610d52e Mon Sep 17 00:00:00 2001 From: DongHyeonka Date: Sun, 8 Nov 2026 10:50:48 +0900 Subject: [PATCH] =?UTF-8?q?test(fixtures):=20local-draft=20=EC=83=98?= =?UTF-8?q?=ED=94=8C=EC=9D=84=20IndexedDB=20=EC=86=8C=EB=B9=84=EC=9E=90=20?= =?UTF-8?q?fixture=EB=A1=9C=20=EC=98=AE=EA=B8=B4=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 통과. --- README.md | 4 +-- .../capability-consumer-experience.md | 13 +++---- docs/architecture/starter-experience.md | 9 ++--- docs/manual/reference/errors.md | 3 +- docs/manual/reference/patterns.md | 2 +- .../indexeddb-feature-capability.ts | 7 ++-- scripts/generate-product-feature-index.ts | 34 +++++-------------- .../local-draft-feature/NOT_A_FEATURE | 6 ---- .../local-draft-composition.spec.ts | 6 ++-- .../indexeddb-local-draft.test.ts | 6 ++-- .../feature-adapter-composition.test.ts | 4 +-- .../create-local-draft-feature-input.ts | 17 ++++++++-- .../adapters/local-draft-indexeddb-store.ts | 4 +-- .../application/local-draft-api.ts | 8 ++--- .../contracts/local-draft-contract.ts | 0 .../indexeddb-consumer}/domain/local-draft.ts | 0 .../indexeddb-feature-capability.test.ts | 2 +- .../generate-product-feature-index.test.ts | 34 ++++--------------- tests/unit/local-draft-api.test.ts | 2 +- 19 files changed, 65 insertions(+), 96 deletions(-) delete mode 100644 src/features/local-draft-feature/NOT_A_FEATURE rename {src/features/local-draft-feature => tests/fixtures/indexeddb-consumer}/adapters/create-local-draft-feature-input.ts (53%) rename {src/features/local-draft-feature => tests/fixtures/indexeddb-consumer}/adapters/local-draft-indexeddb-store.ts (97%) rename {src/features/local-draft-feature => tests/fixtures/indexeddb-consumer}/application/local-draft-api.ts (88%) rename {src/features/local-draft-feature => tests/fixtures/indexeddb-consumer}/contracts/local-draft-contract.ts (100%) rename {src/features/local-draft-feature => tests/fixtures/indexeddb-consumer}/domain/local-draft.ts (100%) diff --git a/README.md b/README.md index b3ed6b05..f5e039ca 100644 --- a/README.md +++ b/README.md @@ -107,7 +107,7 @@ design documents use; the next table maps them. | --- | --- | --- | | Default | In the default build and covered by the merge gates: the application shell and example routes, the REST HTTP executor, TanStack Query server state, Local/Session Storage registries, cross-tab invalidation, runtime config profiles and the release manifest check, `AUTH_MODE=external` (`demo` only in local/development), the typed message catalog, and the removable reference feature. `dist/` is served by a static host ([`docs/architecture/static-delivery.md`](docs/architecture/static-delivery.md)) | `COMPOSED` | | Optional (recipe) | Not installed. A project copies one of the recipes in `config/recipes/frontend-capability-recipes.json` and narrows it ([`docs/architecture/optional-adapter-recipes.md`](docs/architecture/optional-adapter-recipes.md)). `realtime`, `offline-indexeddb`, `service-worker-pwa` and `file-transfer` also ship a tested reference runtime that the default build leaves out | `RECIPE_AVAILABLE`, `NOT_INSTALLED`, `AVAILABLE_NOT_COMPOSED` | -| Experimental | Designed and decided, but the runtime is missing or unfinished; finish it before building on it. GraphQL, gRPC-Web, Connect-Web and Protobuf adapters, Range resumable download, IndexedDB query persistence, the local preview decode-safety probe. `src/features/local-draft-feature` is an architecture sample, not installed | `DESIGNED_NOT_IMPLEMENTED` | +| Experimental | Designed and decided, but the runtime is missing or unfinished; finish it before building on it. GraphQL, gRPC-Web, Connect-Web and Protobuf adapters, Range resumable download, IndexedDB query persistence, the local preview decode-safety probe | `DESIGNED_NOT_IMPLEMENTED` | | Not supported | Deliberately not selected, or browsers cannot guarantee it: SSR, app-managed background upload and download, directory selection, persistent file handles, product query persistence, exactly-once delivery between tabs | `NOT_SELECTED`, `PLATFORM_LIMITED` | The rows come from @@ -121,7 +121,7 @@ and | `COMPOSED` | capability ledger, design documents | wired into the default production path | Default | | `INSTALLED` | a project's own recipe catalog (step 10 of the recipe procedure) | the project added the recipe | Default, for that project | | `RECIPE_AVAILABLE` | recipe catalog `status` | a recipe exists to copy; nothing is installed | Optional | -| `NOT_INSTALLED` | recipe catalog `defaultStatus`; a declared feature the build or `FEATURE_OVERRIDES` left out. A sample directory that is no feature at all carries a `src/features//NOT_A_FEATURE` marker file instead | not part of the build | Optional (recipe) or Experimental (feature) | +| `NOT_INSTALLED` | recipe catalog `defaultStatus`; a declared feature the build or `FEATURE_OVERRIDES` left out | not part of the build | Optional (recipe) or Experimental (feature) | | `AVAILABLE_NOT_COMPOSED` | capability ledger; recipe `referenceRuntime.status` | code and tests exist; the default build leaves it out | Optional | | `DESIGNED_NOT_IMPLEMENTED` | capability ledger, design documents | design approved, runtime missing | Experimental | | `NOT_SELECTED` | capability ledger, design documents | deliberately not chosen | Not supported | diff --git a/docs/architecture/capability-consumer-experience.md b/docs/architecture/capability-consumer-experience.md index 0d6761c0..18033b4d 100644 --- a/docs/architecture/capability-consumer-experience.md +++ b/docs/architecture/capability-consumer-experience.md @@ -53,13 +53,14 @@ The executable consumer probe is: `tests/contract/consumer-experience/indexeddb-local-draft.test.ts` -It runs and reads the one Local Draft implementation under -`src/features/local-draft-feature`; the isolated fixture copy it used to probe -had drifted from `src` and was removed (09-12). +It runs and reads the one Local Draft implementation, the test fixture +`tests/fixtures/indexeddb-consumer` (the template's former local-draft sample +under `src/features/`, moved there because it is no product feature). An +earlier isolated copy had drifted from it and was removed (09-12). -The feature owns the Local Draft domain/application API and declares the slice +The consumer owns the Local Draft domain/application API and declares the slice of the repository it calls (`LocalDraftRepository` in -`src/features/local-draft-feature/adapters/local-draft-indexeddb-store.ts`). The +`tests/fixtures/indexeddb-consumer/adapters/local-draft-indexeddb-store.ts`). The host hands in an `IndexedDbRepositoryPort` through the `indexedDb` capability; the port satisfies that slice structurally. The cross-capability composition contract lives at: @@ -80,7 +81,7 @@ It runs against native browser IndexedDB. The test creates the platform save/find/remove through the feature API. The Local Draft feature still does not import the IndexedDB runtime or native browser API. -Measured on `src/features/local-draft-feature` (09-12): +Measured on the Local Draft consumer, then under `src/features/` (09-12): | Metric | Result | | --- | ---: | diff --git a/docs/architecture/starter-experience.md b/docs/architecture/starter-experience.md index 01843825..14232136 100644 --- a/docs/architecture/starter-experience.md +++ b/docs/architecture/starter-experience.md @@ -151,9 +151,9 @@ installed catalogs import, the context index the router loads lazily, and the selected app. Every build and check script runs it first; run it yourself with `corepack pnpm generate:feature-index`. It fails, naming the file, when: -- a directory under `src/features/` has no `feature-module.ts` and no - `NOT_A_FEATURE` marker file (`src/features/local-draft-feature/NOT_A_FEATURE` - is the one intentional example), or has both; +- a directory under `src/features/` has no `feature-module.ts`. Code that + is no feature (the IndexedDB consumer the tests compose, + `tests/fixtures/indexeddb-consumer`) lives outside `src/features/`; - a feature names an undeclared context, or a context an undeclared app; - a context or app exceeds its declared budget; - `VITE_PRODUCT_FEATURES` names a feature the app does not declare. The @@ -207,7 +207,8 @@ selected app. Every build and check script runs it first; run it yourself with that takes over the platform home is the exception ("Product home and layouts"). 5. If the feature has application input, augment `ApplicationFeatureInputs` - from the feature (`src/features/local-draft-feature/application/local-draft-api.ts`). + from the feature (the IndexedDB consumer fixture does it in + `tests/fixtures/indexeddb-consumer/application/local-draft-api.ts`). 6. Run `corepack pnpm check:architecture`, `corepack pnpm check:types`, `corepack pnpm check:registries` and the tests. `tests/unit/two-feature-install-typecheck.test.ts` keeps the installed catalogs compiling with more than one feature. diff --git a/docs/manual/reference/errors.md b/docs/manual/reference/errors.md index 3595a75f..1c05e428 100644 --- a/docs/manual/reference/errors.md +++ b/docs/manual/reference/errors.md @@ -56,8 +56,7 @@ lint / check:architecture / check:i18n → FE-GATE-002, FE-GATE-010 | `Context belongs to undeclared app ` | `CONTEXT_APP_ID` 오타 | `src/contexts//context-module.ts` | | ` must export a literal ` | 헤더를 상수 참조나 식으로 썼다. 생성기는 글자로 읽는다 | 그 파일. `export const = "<값>";` 꼴 | | ` must export a positive integer ` | 예산 값이 정수 리터럴이 아니다 | 그 파일 | -| `src/features/ has no feature-module.ts; add one or mark the directory with NOT_A_FEATURE` | 기능 폴더에 선언 파일이 없다 | `feature-module.ts`를 만들거나, 기능이 아닌 샘플 폴더면 `NOT_A_FEATURE` 파일을 둔다 | -| `src/features/ has both feature-module.ts and NOT_A_FEATURE; …` | 기능이 아니라고 표시한 폴더에 선언 파일이 있다 | 기능으로 설치하려면 `NOT_A_FEATURE`를 지운다. 설치하지 않으려면 `feature-module.ts`를 지운다 | +| `src/features/ has no feature-module.ts; add one, or keep code that is no feature outside src/features` | 기능 폴더에 선언 파일이 없다 | `feature-module.ts`를 만든다. 기능이 아닌 코드(시험용 소비자 등)면 `src/features/` 밖으로 옮긴다 | | `Duplicate generated feature ids: ` | 두 폴더가 같은 `FEATURE_MODULE_ID` | 한쪽 `feature-module.ts` | | `Duplicate context id: ` | 두 폴더가 같은 `CONTEXT_MODULE_ID` | 한쪽 `context-module.ts` | | `Context feature cardinality exceeds budget ` | context의 기능 수가 예산을 넘었다 | `CONTEXT_MAX_FEATURES`, 또는 새 context | diff --git a/docs/manual/reference/patterns.md b/docs/manual/reference/patterns.md index cbcabd14..b133b745 100644 --- a/docs/manual/reference/patterns.md +++ b/docs/manual/reference/patterns.md @@ -100,7 +100,7 @@ const search = (q: string) => | 수정·삭제 명령 | 같은 V3 계약 (`PUT`, `PATCH`, `DELETE`) | 없음 (참조 기능은 생성 명령만 있다) | — | | 낙관적 갱신 | `useApplicationMutation`의 `optimistic` 옵션 (`application-query.ts`) | 없음 | 런타임 테스트만 | | 페이지 넘김 | `src/adapters/query-cache/index.ts`의 `createCursorPaginationRuntime` | 없음 (참조 기능은 커서 필터만, 다음 커서 없음) | 런타임 테스트만 | -| 로컬 저장(IndexedDB) | `recipes/frontend-capabilities/indexeddb-feature-capability.ts` + `product-composition.ts` | `src/features/local-draft-feature/` (`NOT_A_FEATURE`, 기능이 아닌 샘플) | 계약 테스트 | +| 로컬 저장(IndexedDB) | `recipes/frontend-capabilities/indexeddb-feature-capability.ts` + `product-composition.ts` | `tests/fixtures/indexeddb-consumer/` (시험이 조립하는 소비자 fixture, 기능 폴더 모양) | 계약 테스트 | ## 화면 diff --git a/recipes/frontend-capabilities/indexeddb-feature-capability.ts b/recipes/frontend-capabilities/indexeddb-feature-capability.ts index 380a3e94..3d8c076c 100644 --- a/recipes/frontend-capabilities/indexeddb-feature-capability.ts +++ b/recipes/frontend-capabilities/indexeddb-feature-capability.ts @@ -7,8 +7,8 @@ import { createIndexedDbRepositoryProvider, type IndexedDbRepositoryProvider, } from "../../src/features/feature-adapter-contribution.ts"; -import type {} from "../../src/features/local-draft-feature/adapters/create-local-draft-feature-input.ts"; -import type { LocalDraft } from "../../src/features/local-draft-feature/domain/local-draft.ts"; +import type {} from "../../tests/fixtures/indexeddb-consumer/adapters/create-local-draft-feature-input.ts"; +import type { LocalDraft } from "../../tests/fixtures/indexeddb-consumer/domain/local-draft.ts"; type LocalDraftRuntimeDependencies = IndexedDbRuntimeDependencies< LocalDraft, @@ -21,7 +21,8 @@ type LocalDraftRuntime = ReturnType< /** * 09-05. How a host builds the `indexedDb` feature capability, shown for the - * local-draft sample. IndexedDB is an opt-in reference runtime + * local-draft consumer the tests compose (tests/fixtures/indexeddb-consumer). + * IndexedDB is an opt-in reference runtime * (`offline-indexeddb` in config/recipes/frontend-capability-recipes.json, * `productionComposition: false`), so `src/bootstrap/runtime-adapters.ts` does * not build it. A product that installs a feature with `needs: ["indexedDb"]` diff --git a/scripts/generate-product-feature-index.ts b/scripts/generate-product-feature-index.ts index 26100243..352b1187 100644 --- a/scripts/generate-product-feature-index.ts +++ b/scripts/generate-product-feature-index.ts @@ -272,22 +272,15 @@ function requiredInteger(source: string, name: string, file: string): number { } /** - * 09-07 (D-10). A feature directory must declare itself or say it is not a - * feature. A missing or misspelt `feature-module.ts` used to drop the - * feature from the product without a word. - * - * 1103/09-09. The marker was named `NOT_INSTALLED`, the runtime state of a - * declared feature the build or the runtime document left out - * (`src/contracts/product-features.ts`). It marks something else, a directory - * that is no feature at all (an architecture sample), so it has its own name, - * and a directory may not carry both the marker and a declaration. + * 09-07 (D-10). A feature directory must declare itself. A missing or + * misspelt `feature-module.ts` used to drop the feature from the product + * without a word. Code that is no feature (a test's consumer fixture) lives + * outside src/features. */ -export const NOT_A_FEATURE_MARKER = "NOT_A_FEATURE"; - async function readDeclarations( directory: string, fileName: string, - requiredUnless?: string, + required = false, ): Promise[]> { const found: { directory: string; file: string; source: string }[] = []; let items; @@ -299,24 +292,13 @@ async function readDeclarations( for (const item of items) { if (!item.isDirectory()) continue; const file = resolve(directory, item.name, fileName); - const marker = - requiredUnless !== undefined && - (await readFile(resolve(directory, item.name, requiredUnless)).then( - () => true, - () => false, - )); let source: string; try { source = await readFile(file, "utf8"); } catch { - if (requiredUnless === undefined || marker) continue; + if (!required) continue; throw new Error( - `src/features/${item.name} has no ${fileName}; add one or mark the directory with ${requiredUnless}`, - ); - } - if (marker) { - throw new Error( - `src/features/${item.name} has both ${fileName} and ${requiredUnless}; delete ${requiredUnless} to install it, or ${fileName} to keep it out`, + `src/features/${item.name} has no ${fileName}; add one, or keep code that is no feature outside src/features`, ); } found.push({ directory: item.name, file, source }); @@ -368,7 +350,7 @@ export async function createFileSystemDeclarationSource( for (const declaration of await readDeclarations( resolve(root, "src/features"), "feature-module.ts", - NOT_A_FEATURE_MARKER, + true, )) { const feature: FeatureDeclaration = { id: requiredLiteral(declaration.source, "FEATURE_MODULE_ID", declaration.file), diff --git a/src/features/local-draft-feature/NOT_A_FEATURE b/src/features/local-draft-feature/NOT_A_FEATURE deleted file mode 100644 index 1c481d10..00000000 --- a/src/features/local-draft-feature/NOT_A_FEATURE +++ /dev/null @@ -1,6 +0,0 @@ -local-draft is an architecture sample for the indexedDb feature capability, not -a product feature. It has no feature-module.ts on purpose, so the index -generator (scripts/generate-product-feature-index.ts) leaves it out; its -composition is exercised by tests/contract/reusable-capability and -recipes/frontend-capabilities/indexeddb-feature-capability.ts. To install it, -add feature-module.ts and context-routes.ts and delete this file. diff --git a/tests/browser-capabilities/local-draft-composition.spec.ts b/tests/browser-capabilities/local-draft-composition.spec.ts index 6319ad6b..b2b284ed 100644 --- a/tests/browser-capabilities/local-draft-composition.spec.ts +++ b/tests/browser-capabilities/local-draft-composition.spec.ts @@ -1,7 +1,7 @@ import type { IndexedDbRuntimeDependencies, } from "../../src/adapters/storage/indexeddb/indexeddb-types.ts"; -import type { LocalDraft } from "../../src/features/local-draft-feature/domain/local-draft.ts"; +import type { LocalDraft } from "../fixtures/indexeddb-consumer/domain/local-draft.ts"; import { expect, test, @@ -21,7 +21,7 @@ test("composes the local-draft feature over the real browser IndexedDB runtime", const contributionModulePath = "/src/features/feature-adapter-contribution.ts"; const localDraftModulePath = - "/src/features/local-draft-feature/adapters/create-local-draft-feature-input.ts"; + "/tests/fixtures/indexeddb-consumer/adapters/create-local-draft-feature-input.ts"; const { createIndexedDbRuntime, @@ -39,7 +39,7 @@ test("composes the local-draft feature over the real browser IndexedDB runtime", LOCAL_DRAFT_FEATURE_ADAPTER_CONTRIBUTION, } = (await import( /* @vite-ignore */ localDraftModulePath - )) as typeof import("../../src/features/local-draft-feature/adapters/create-local-draft-feature-input.ts"); + )) as typeof import("../fixtures/indexeddb-consumer/adapters/create-local-draft-feature-input.ts"); const suffix = crypto.randomUUID().replaceAll("-", ""); const scope = Object.freeze({ diff --git a/tests/contract/consumer-experience/indexeddb-local-draft.test.ts b/tests/contract/consumer-experience/indexeddb-local-draft.test.ts index d2dc3975..e22094dd 100644 --- a/tests/contract/consumer-experience/indexeddb-local-draft.test.ts +++ b/tests/contract/consumer-experience/indexeddb-local-draft.test.ts @@ -7,13 +7,13 @@ import type { BrowserDataResult, IndexedDbRepositoryPort, } from "../../../src/application/ports/browser-file-storage/index.ts"; -import { createLocalDraftStore } from "../../../src/features/local-draft-feature/adapters/local-draft-indexeddb-store.ts"; -import type { LocalDraft } from "../../../src/features/local-draft-feature/domain/local-draft.ts"; +import { createLocalDraftStore } from "../../fixtures/indexeddb-consumer/adapters/local-draft-indexeddb-store.ts"; +import type { LocalDraft } from "../../fixtures/indexeddb-consumer/domain/local-draft.ts"; // 09-12. This probe used to exercise a copy of the feature under fixtures/, // which had drifted from src (it returned raw storage failures). It now reads // and runs the one implementation. -const FEATURE_ROOT = "src/features/local-draft-feature"; +const FEATURE_ROOT = "tests/fixtures/indexeddb-consumer"; async function featureSources(directory: string): Promise { const entries = await readdir(directory, { withFileTypes: true }); diff --git a/tests/contract/reusable-capability/feature-adapter-composition.test.ts b/tests/contract/reusable-capability/feature-adapter-composition.test.ts index c800940d..cc05be0e 100644 --- a/tests/contract/reusable-capability/feature-adapter-composition.test.ts +++ b/tests/contract/reusable-capability/feature-adapter-composition.test.ts @@ -13,8 +13,8 @@ import { } from "../../../src/features/feature-adapter-contribution.ts"; import { LOCAL_DRAFT_FEATURE_ADAPTER_CONTRIBUTION, -} from "../../../src/features/local-draft-feature/adapters/create-local-draft-feature-input.ts"; -import type { LocalDraft } from "../../../src/features/local-draft-feature/domain/local-draft.ts"; +} from "../../fixtures/indexeddb-consumer/adapters/create-local-draft-feature-input.ts"; +import type { LocalDraft } from "../../fixtures/indexeddb-consumer/domain/local-draft.ts"; type TestHttpFeatureInput = Readonly<{ ping(): Promise<"pong">; diff --git a/src/features/local-draft-feature/adapters/create-local-draft-feature-input.ts b/tests/fixtures/indexeddb-consumer/adapters/create-local-draft-feature-input.ts similarity index 53% rename from src/features/local-draft-feature/adapters/create-local-draft-feature-input.ts rename to tests/fixtures/indexeddb-consumer/adapters/create-local-draft-feature-input.ts index 9b7461cc..1fe0c005 100644 --- a/src/features/local-draft-feature/adapters/create-local-draft-feature-input.ts +++ b/tests/fixtures/indexeddb-consumer/adapters/create-local-draft-feature-input.ts @@ -1,7 +1,7 @@ import { defineFeatureAdapterContribution, -} from "../../feature-adapter-contribution.ts"; -import type {} from "../../feature-adapter-contribution.ts"; +} from "../../../../src/features/feature-adapter-contribution.ts"; +import type {} from "../../../../src/features/feature-adapter-contribution.ts"; import { createLocalDraftFeatureInput, } from "../application/local-draft-api.ts"; @@ -14,7 +14,18 @@ import { type LocalDraftRepository, } from "./local-draft-indexeddb-store.ts"; -declare module "../../feature-adapter-contribution.ts" { +/** + * The IndexedDB consumer the tests compose: a local-draft store shaped like a + * feature's adapters, application and domain folders, with + * `needs: ["indexedDb"]`. It was the template's local-draft sample under + * src/features, a folder the generator skipped; it is a test fixture now. Its users: + * tests/contract/reusable-capability/feature-adapter-composition.test.ts, + * tests/contract/consumer-experience/indexeddb-local-draft.test.ts, + * tests/unit/local-draft-api.test.ts, tests/recipes/indexeddb-feature-capability.test.ts, + * tests/browser-capabilities/local-draft-composition.spec.ts and the recipe + * recipes/frontend-capabilities/indexeddb-feature-capability.ts. + */ +declare module "../../../../src/features/feature-adapter-contribution.ts" { interface FeatureIndexedDbRepositories { "local-draft": LocalDraftRepository; } diff --git a/src/features/local-draft-feature/adapters/local-draft-indexeddb-store.ts b/tests/fixtures/indexeddb-consumer/adapters/local-draft-indexeddb-store.ts similarity index 97% rename from src/features/local-draft-feature/adapters/local-draft-indexeddb-store.ts rename to tests/fixtures/indexeddb-consumer/adapters/local-draft-indexeddb-store.ts index 9f0fd0a9..bba11a29 100644 --- a/src/features/local-draft-feature/adapters/local-draft-indexeddb-store.ts +++ b/tests/fixtures/indexeddb-consumer/adapters/local-draft-indexeddb-store.ts @@ -2,8 +2,8 @@ import { createFailure, type AppFailure, type FailureKind, -} from "../../../contracts/errors.ts"; -import type { Result } from "../../../contracts/result.ts"; +} from "../../../../src/contracts/errors.ts"; +import type { Result } from "../../../../src/contracts/result.ts"; import type { LocalDraftStore, LocalDraftRecord, diff --git a/src/features/local-draft-feature/application/local-draft-api.ts b/tests/fixtures/indexeddb-consumer/application/local-draft-api.ts similarity index 88% rename from src/features/local-draft-feature/application/local-draft-api.ts rename to tests/fixtures/indexeddb-consumer/application/local-draft-api.ts index 3b384b63..bcfb98fd 100644 --- a/src/features/local-draft-feature/application/local-draft-api.ts +++ b/tests/fixtures/indexeddb-consumer/application/local-draft-api.ts @@ -1,6 +1,6 @@ -import { createFailure } from "../../../contracts/errors.ts"; -import type { Result } from "../../../contracts/result.ts"; -import type {} from "../../../application/ports/in/application-api.ts"; +import { createFailure } from "../../../../src/contracts/errors.ts"; +import type { Result } from "../../../../src/contracts/result.ts"; +import type {} from "../../../../src/application/ports/in/application-api.ts"; import { createLocalDraft, type LocalDraft } from "../domain/local-draft.ts"; export type LocalDraftRecord = Readonly<{ @@ -51,7 +51,7 @@ export type LocalDraftFeatureInput = Readonly<{ ): Promise>; }>; -declare module "../../../application/ports/in/application-api.ts" { +declare module "../../../../src/application/ports/in/application-api.ts" { interface ApplicationFeatureInputs { "local-draft": LocalDraftFeatureInput; } diff --git a/src/features/local-draft-feature/contracts/local-draft-contract.ts b/tests/fixtures/indexeddb-consumer/contracts/local-draft-contract.ts similarity index 100% rename from src/features/local-draft-feature/contracts/local-draft-contract.ts rename to tests/fixtures/indexeddb-consumer/contracts/local-draft-contract.ts diff --git a/src/features/local-draft-feature/domain/local-draft.ts b/tests/fixtures/indexeddb-consumer/domain/local-draft.ts similarity index 100% rename from src/features/local-draft-feature/domain/local-draft.ts rename to tests/fixtures/indexeddb-consumer/domain/local-draft.ts diff --git a/tests/recipes/indexeddb-feature-capability.test.ts b/tests/recipes/indexeddb-feature-capability.test.ts index c386dd6b..5bece537 100644 --- a/tests/recipes/indexeddb-feature-capability.test.ts +++ b/tests/recipes/indexeddb-feature-capability.test.ts @@ -1,7 +1,7 @@ import { describe, expect, it } from "vitest"; import { composeFeatureAdapterInputs } from "../../src/features/feature-adapter-contribution.ts"; -import { LOCAL_DRAFT_FEATURE_ADAPTER_CONTRIBUTION } from "../../src/features/local-draft-feature/adapters/create-local-draft-feature-input.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"; diff --git a/tests/scripts/generate-product-feature-index.test.ts b/tests/scripts/generate-product-feature-index.test.ts index 53b305d6..9bf4026f 100644 --- a/tests/scripts/generate-product-feature-index.test.ts +++ b/tests/scripts/generate-product-feature-index.test.ts @@ -145,7 +145,7 @@ describe("app-scoped selection from ownership declarations", () => { await expect(generateAppIndexes(overContexts, "a")).rejects.toThrow(/App a context cardinality 2 exceeds budget 1/); }); - it("refuses a feature directory without a declaration or NOT_A_FEATURE marker (09-07)", async () => { + it("refuses a feature directory without a declaration (09-07)", async () => { const files = { "src/apps/a/app-module.ts": app("a"), "src/contexts/c/context-module.ts": context("c", "a"), @@ -154,40 +154,20 @@ describe("app-scoped selection from ownership declarations", () => { "src/features/typo/feature-modul.ts": feature("typo", "c"), }; await expect(generateAppIndexes(await repo(files), "a")).rejects.toThrow( - /src\/features\/typo has no feature-module\.ts/u, - ); - const marked = await repo({ - ...files, - "src/features/typo/NOT_A_FEATURE": "Composed only by tests.\n", - }); - const selected = await generateAppIndexes(marked, "a"); - expect(selected.entries.map((entry) => entry.id)).toEqual(["f"]); - }); - - it("no longer accepts the old NOT_INSTALLED marker name (1103/09-09)", async () => { - // The word is the runtime state "declared but not selected"; a marker - // under that name is read as a missing declaration, naming the new one. - const root = await repo({ - "src/apps/a/app-module.ts": app("a"), - "src/contexts/c/context-module.ts": context("c", "a"), - "src/features/sample/NOT_INSTALLED": "Composed only by tests.\n", - }); - await expect(generateAppIndexes(root, "a")).rejects.toThrow( - /src\/features\/sample has no feature-module\.ts; add one or mark the directory with NOT_A_FEATURE/u, + /src\/features\/typo has no feature-module\.ts; add one, or keep code that is no feature outside src\/features/u, ); }); - it("refuses a marked directory that also declares a feature (1103/09-09)", async () => { - // Graduating a sample means deleting the marker; keeping both used to - // install the feature silently while the marker said it was none. + it("reads a marker file as a missing declaration", async () => { + // The local-draft sample used to skip the check with a NOT_A_FEATURE + // file; it is a test fixture now and the marker is gone. const root = await repo({ "src/apps/a/app-module.ts": app("a"), "src/contexts/c/context-module.ts": context("c", "a"), - "src/features/f/feature-module.ts": feature("f", "c"), - "src/features/f/NOT_A_FEATURE": "Composed only by tests.\n", + "src/features/sample/NOT_A_FEATURE": "Composed only by tests.\n", }); await expect(generateAppIndexes(root, "a")).rejects.toThrow( - /src\/features\/f has both feature-module\.ts and NOT_A_FEATURE; delete NOT_A_FEATURE to install it, or feature-module\.ts to keep it out/u, + /src\/features\/sample has no feature-module\.ts/u, ); }); diff --git a/tests/unit/local-draft-api.test.ts b/tests/unit/local-draft-api.test.ts index 337f29db..b199a9bc 100644 --- a/tests/unit/local-draft-api.test.ts +++ b/tests/unit/local-draft-api.test.ts @@ -3,7 +3,7 @@ import { describe, expect, it, vi } from "vitest"; import { createLocalDraftFeatureInput, type LocalDraftStore, -} from "../../src/features/local-draft-feature/application/local-draft-api.ts"; +} from "../fixtures/indexeddb-consumer/application/local-draft-api.ts"; function recordingStore() { const save = vi.fn(async () =>