|
| 1 | +# AGENTS Notes — ngrx-hateoas workspace |
| 2 | + |
| 3 | +Purpose |
| 4 | +- This workspace contains an Angular library, `@angular-architects/ngrx-hateoas`, built on top of the NgRx Signal Store. The library helps load hypermedia JSON resources into a reactive signal-based store, mutate state locally and execute hypermedia-driven actions. |
| 5 | + |
| 6 | +Key locations |
| 7 | +- Library source: `libs/ngrx-hateoas` |
| 8 | +- Documentation (user guide): `doc/docs/guide` (see Getting Started, Concept, Pipes, Configuration, Loading Features, State Mutation Features, Action Features) |
| 9 | +- Playground app (demo + local server): `apps/playground` (contains `server.js` and `db.json` for local demonstration) |
| 10 | + |
| 11 | +How tests are written (libs/ngrx-hateoas) |
| 12 | +- Location: `libs/ngrx-hateoas/src/lib/**/*.spec.ts`. |
| 13 | +- Framework / runner: Angular unit tests using Jasmine (see `tsconfig.spec.json` types: `jasmine`) and Angular TestBed utilities. |
| 14 | +- Common patterns: |
| 15 | + - Use `TestBed.configureTestingModule(...)` with providers such as `provideZonelessChangeDetection()`, `provideHttpClient()` and `provideHttpClientTesting()` where needed. |
| 16 | + - Services that call HTTP use `HttpTestingController` and `expectOne(...).flush(...)` to simulate server responses and assert request properties (method, body, headers). |
| 17 | + - Many tests assert metastate signals (e.g., `isLoading`, `isLoaded`, `isAvailable`) and verify reactive behavior (cancellation of previous requests, reactive reloads when a `Signal` changes) via `signalStore`, `signal()` and `TestBed.flushEffects()` where applicable. |
| 18 | + - Tests use `async/await` or `expectAsync` for promise-based operations and standard Jasmine matchers (`toBeTrue`, `toBeFalse`, `toEqual`, `toBe`, `toBeDefined`, etc.). |
| 19 | + - Tests cover pipes, services (request/hateoas), and store-features (loading, writable copies, actions), focusing on isolated unit behavior. |
| 20 | + |
| 21 | +Playground / local demo |
| 22 | +- `apps/playground` contains a minimal Angular app and local server artifacts (`db.json`, `server.js`) useful to run the library locally against a fake REST API for manual testing and demos. |
| 23 | + |
| 24 | +Rules for agents (editing / extending) |
| 25 | +- When changing features, update matching docs in `doc/docs/guide/*` and add/adjust unit tests under `libs/ngrx-hateoas/src/lib/**`. |
| 26 | +- For HTTP-related behavior, follow existing test patterns using `provideHttpClientTesting()` and `HttpTestingController`. |
| 27 | +- Use `provideZonelessChangeDetection()` in TestBed providers to match existing test environment. |
| 28 | + |
| 29 | +References |
| 30 | +- See `doc/docs/guide/01-getting-started.md` and `doc/docs/guide/02-concept.md` for conceptual details and examples. |
0 commit comments