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 통과.
This commit is contained in:
@@ -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/<dir>/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 |
|
||||
|
||||
@@ -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<LocalDraft, never>` 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 |
|
||||
| --- | ---: |
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -56,8 +56,7 @@ lint / check:architecture / check:i18n → FE-GATE-002, FE-GATE-010
|
||||
| `Context <context> belongs to undeclared app <app>` | `CONTEXT_APP_ID` 오타 | `src/contexts/<context>/context-module.ts` |
|
||||
| `<file> must export a literal <NAME>` | 헤더를 상수 참조나 식으로 썼다. 생성기는 글자로 읽는다 | 그 파일. `export const <NAME> = "<값>";` 꼴 |
|
||||
| `<file> must export a positive integer <NAME>` | 예산 값이 정수 리터럴이 아니다 | 그 파일 |
|
||||
| `src/features/<dir> has no feature-module.ts; add one or mark the directory with NOT_A_FEATURE` | 기능 폴더에 선언 파일이 없다 | `feature-module.ts`를 만들거나, 기능이 아닌 샘플 폴더면 `NOT_A_FEATURE` 파일을 둔다 |
|
||||
| `src/features/<dir> has both feature-module.ts and NOT_A_FEATURE; …` | 기능이 아니라고 표시한 폴더에 선언 파일이 있다 | 기능으로 설치하려면 `NOT_A_FEATURE`를 지운다. 설치하지 않으려면 `feature-module.ts`를 지운다 |
|
||||
| `src/features/<dir> 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: <id>` | 두 폴더가 같은 `FEATURE_MODULE_ID` | 한쪽 `feature-module.ts` |
|
||||
| `Duplicate context id: <id>` | 두 폴더가 같은 `CONTEXT_MODULE_ID` | 한쪽 `context-module.ts` |
|
||||
| `Context <context> feature cardinality <n> exceeds budget <max>` | context의 기능 수가 예산을 넘었다 | `CONTEXT_MAX_FEATURES`, 또는 새 context |
|
||||
|
||||
@@ -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, 기능 폴더 모양) | 계약 테스트 |
|
||||
|
||||
## 화면
|
||||
|
||||
|
||||
@@ -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"]`
|
||||
|
||||
@@ -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<readonly Readonly<{ directory: string; file: string; source: string }>[]> {
|
||||
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),
|
||||
|
||||
@@ -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.
|
||||
@@ -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({
|
||||
|
||||
@@ -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<string[]> {
|
||||
const entries = await readdir(directory, { withFileTypes: true });
|
||||
|
||||
@@ -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">;
|
||||
|
||||
+14
-3
@@ -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;
|
||||
}
|
||||
+2
-2
@@ -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,
|
||||
+4
-4
@@ -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<Result<void>>;
|
||||
}>;
|
||||
|
||||
declare module "../../../application/ports/in/application-api.ts" {
|
||||
declare module "../../../../src/application/ports/in/application-api.ts" {
|
||||
interface ApplicationFeatureInputs {
|
||||
"local-draft": LocalDraftFeatureInput;
|
||||
}
|
||||
@@ -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";
|
||||
|
||||
|
||||
@@ -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,
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
@@ -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<LocalDraftStore["save"]>(async () =>
|
||||
|
||||
Reference in New Issue
Block a user