@tech4good/angular-schematics 21.1.0 → 21.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,21 @@
1
+ ## [21.3.0](https://github.com/tech4good-lab/angular-schematics/compare/v21.2.0...v21.3.0) (2026-07-03)
2
+
3
+ ### Features
4
+
5
+ * **ng-add:** add cdk-overrides partial ([0b754ec](https://github.com/tech4good-lab/angular-schematics/commit/0b754ec2e5852ac626bfabf95259cbfa53b55cc9))
6
+
7
+ ### Build System
8
+
9
+ * **ng-add:** bump template dependency for release ([6c21eb9](https://github.com/tech4good-lab/angular-schematics/commit/6c21eb969f98af4a762c477da460f408802b1def))
10
+ ## [21.2.0](https://github.com/tech4good-lab/angular-schematics/compare/v21.1.0...v21.2.0) (2026-07-02)
11
+
12
+ ### Features
13
+
14
+ * **ng-add:** support simulating read errors and loading states in firebase mock ([7f3ad7e](https://github.com/tech4good-lab/angular-schematics/commit/7f3ad7e665ec129fb7151c6ea4a02712068a1d0e))
15
+
16
+ ### Build System
17
+
18
+ * **ng-add:** bump template dependency for release ([f717736](https://github.com/tech4good-lab/angular-schematics/commit/f717736d4f349d9c09ed408055a36501a0b729cb))
1
19
  ## [21.1.0](https://github.com/tech4good-lab/angular-schematics/compare/v21.0.0...v21.1.0) (2026-07-01)
2
20
 
3
21
  ### Features
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tech4good/angular-schematics",
3
- "version": "21.1.0",
3
+ "version": "21.3.0",
4
4
  "description": "A set of schematics for generating modules, containers, components, and entities",
5
5
  "scripts": {
6
6
  "build": "tsc -p tsconfig.json",
@@ -53,7 +53,7 @@
53
53
  "@firebase/rules-unit-testing": "^5.0.1",
54
54
  "firebase-tools": "^14.27.0",
55
55
  "@ngx-env/builder": "^21.0.1",
56
- "@tech4good/angular-schematics": "^21.1.0",
56
+ "@tech4good/angular-schematics": "^21.3.0",
57
57
  "@types/estree": "^1.0.0",
58
58
  "@types/jest": "^30.0.0",
59
59
  "@types/node": "^18.19.47",
@@ -1,6 +1,6 @@
1
1
  import { Injectable, inject, Injector, computed, Provider } from '@angular/core';
2
2
  import { toObservable } from '@angular/core/rxjs-interop';
3
- import { Observable, combineLatest, merge, of, from, pipe, BehaviorSubject } from 'rxjs';
3
+ import { Observable, combineLatest, merge, of, from, pipe, BehaviorSubject, throwError, NEVER } from 'rxjs';
4
4
  import { tap, pluck, mergeMap, pairwise, delay, startWith, filter, takeUntil, skip, switchMap, map, take } from 'rxjs/operators';
5
5
  import { environment } from '../../../environments/environment';
6
6
  import { DocumentSnapshot, serverTimestamp, Timestamp, getDoc, getDocs, doc, setDoc, updateDoc, deleteDoc, docData, collection, collectionData, collectionChanges, query, where, orderBy, OrderByDirection, limit, startAt, startAfter, endAt, endBefore, DocumentChange, increment, AggregateQuerySnapshot, AggregateField, AggregateSpec, getAggregateFromServer, getCountFromServer } from '@angular/fire/firestore';
@@ -30,6 +30,20 @@ export class FirebaseMockService implements DatabaseService {
30
30
  GET_LATENCY_SIMULATION_DELAY = 100;
31
31
  PUT_LATENCY_SIMULATION_DELAY = 300;
32
32
 
33
+ /**
34
+ * Collections that throw/reject on any read operation.
35
+ * Set via `provideFirebaseMock({ failCollections: [...] })` or mutate mid-test
36
+ * via `db.failCollections = [...]` to simulate error → recovery flows.
37
+ */
38
+ failCollections: string[] = [];
39
+
40
+ /**
41
+ * Collections where reads never emit/resolve (simulates perpetual loading).
42
+ * Set via `provideFirebaseMock({ stallCollections: [...] })` or mutate mid-test
43
+ * via `db.stallCollections = [...]`.
44
+ */
45
+ stallCollections: string[] = [];
46
+
33
47
  constructor(
34
48
  private injector: Injector,
35
49
  ) {
@@ -77,6 +91,10 @@ export class FirebaseMockService implements DatabaseService {
77
91
  }
78
92
 
79
93
  streamEntity<T>(collectionName: string, id: string) {
94
+ if (this.stallCollections.includes(collectionName)) return NEVER;
95
+ if (this.failCollections.includes(collectionName)) {
96
+ return throwError(() => new Error(`Simulated read error for collection: ${collectionName}`));
97
+ }
80
98
  const store = this.DB[collectionName];
81
99
  const entity = computed(() => {
82
100
  return store.selectEntity(id);
@@ -87,6 +105,10 @@ export class FirebaseMockService implements DatabaseService {
87
105
  }
88
106
 
89
107
  streamEntities<T>(collectionName, queryParams, queryOptions) {
108
+ if (this.stallCollections.includes(collectionName)) return NEVER;
109
+ if (this.failCollections.includes(collectionName)) {
110
+ return throwError(() => new Error(`Simulated read error for collection: ${collectionName}`));
111
+ }
90
112
  const store = this.DB[collectionName];
91
113
  const entities = computed(() => {
92
114
  return store.selectEntities(queryParams, queryOptions);
@@ -98,6 +120,10 @@ export class FirebaseMockService implements DatabaseService {
98
120
  }
99
121
 
100
122
  streamEntitiesChanges<T>(collectionName, queryParams, queryOptions) {
123
+ if (this.stallCollections.includes(collectionName)) return NEVER;
124
+ if (this.failCollections.includes(collectionName)) {
125
+ return throwError(() => new Error(`Simulated read error for collection: ${collectionName}`));
126
+ }
101
127
  const store = this.DB[collectionName];
102
128
  const streamEntities = computed(() => {
103
129
  return store.selectEntities(queryParams, queryOptions);
@@ -148,6 +174,10 @@ export class FirebaseMockService implements DatabaseService {
148
174
  }
149
175
 
150
176
  async getEntity<T>(collectionName: string, id: string) {
177
+ if (this.stallCollections.includes(collectionName)) return new Promise(() => {});
178
+ if (this.failCollections.includes(collectionName)) {
179
+ throw new Error(`Simulated read error for collection: ${collectionName}`);
180
+ }
151
181
  const store = this.DB[collectionName];
152
182
  await new Promise((resolve) => setTimeout(resolve, this.GET_LATENCY_SIMULATION_DELAY));
153
183
  return store.selectEntity(id);
@@ -158,6 +188,10 @@ export class FirebaseMockService implements DatabaseService {
158
188
  queryParams: [string, string, any][],
159
189
  queryOptions?: { [index: string]: any },
160
190
  ): Promise<S[]> {
191
+ if (this.stallCollections.includes(collectionName)) return new Promise(() => {}) as Promise<S[]>;
192
+ if (this.failCollections.includes(collectionName)) {
193
+ throw new Error(`Simulated read error for collection: ${collectionName}`);
194
+ }
161
195
  const db = this.DB[collectionName];
162
196
  await new Promise((resolve) => setTimeout(resolve, this.GET_LATENCY_SIMULATION_DELAY));
163
197
  return db.selectEntities(queryParams, queryOptions);
@@ -278,19 +312,43 @@ export class FirebaseMockService implements DatabaseService {
278
312
 
279
313
  /**
280
314
  * Creates provider configuration for FirebaseMockService with custom DB collection seeding.
315
+ *
316
+ * @param options.disableLatency - When true, sets GET and PUT latency simulation delays to 0ms.
317
+ * Use this in spec files to avoid the `APP_INITIALIZER` boilerplate for zeroing latency.
318
+ * See TEST-AP-005 in testing-guide.md.
319
+ * @param options.failCollections - Collections that throw/reject on any read operation.
320
+ * The property is mutable mid-test via `db.failCollections = [...]` to simulate
321
+ * error → recovery flows (e.g., set failCollections, verify error banner,
322
+ * clear failCollections, click Retry, verify recovery).
323
+ * @param options.stallCollections - Collections where reads never emit/resolve, simulating
324
+ * perpetual loading. Mutable mid-test via `db.stallCollections = [...]`.
281
325
  */
282
326
  export function provideFirebaseMock({
283
327
  users,
284
328
  userContexts,
329
+ disableLatency,
330
+ failCollections,
331
+ stallCollections,
285
332
  }: {
286
333
  users?: any[];
287
334
  userContexts?: any[];
335
+ disableLatency?: boolean;
336
+ /** Collections that throw/reject on any read. Mutable mid-test via `db.failCollections`. */
337
+ failCollections?: string[];
338
+ /** Collections where reads never emit/resolve. Mutable mid-test via `db.stallCollections`. */
339
+ stallCollections?: string[];
288
340
  } = {}): Provider[] {
289
341
  return [
290
342
  {
291
343
  provide: FirebaseMockService,
292
344
  useFactory: (injector: Injector) => {
293
345
  const service = new FirebaseMockService(injector);
346
+ if (disableLatency) {
347
+ service.GET_LATENCY_SIMULATION_DELAY = 0;
348
+ service.PUT_LATENCY_SIMULATION_DELAY = 0;
349
+ }
350
+ if (failCollections) service.failCollections = failCollections;
351
+ if (stallCollections) service.stallCollections = stallCollections;
294
352
  if (users) service.DB['users'].init(users);
295
353
  if (userContexts) service.DB['userContexts'].init(userContexts);
296
354
  return service;
@@ -0,0 +1,50 @@
1
+ // ==========================================================================
2
+ // CDK Overlay Overrides
3
+ // ==========================================================================
4
+ // Styles for content rendered in the CDK overlay container, which lives
5
+ // outside component DOM trees. Component-scoped styles (ViewEncapsulation)
6
+ // cannot reach these elements, so they must be defined globally.
7
+ //
8
+ // This file is generated by the project's ng-add schematics.
9
+ // See angular-material-guide.md MAT-008 for details.
10
+ // ==========================================================================
11
+
12
+ // ---------------------------------------------------------------------------
13
+ // CDK Drag and Drop
14
+ // ---------------------------------------------------------------------------
15
+
16
+ // The drag preview is rendered in the CDK overlay during a drag operation.
17
+ // Without global styles, it appears as an unstyled clone of the original element.
18
+ .cdk-drag-preview {
19
+ box-sizing: border-box;
20
+ border-radius: 4px;
21
+ box-shadow: 0 5px 5px -3px rgba(0, 0, 0, 0.2),
22
+ 0 8px 10px 1px rgba(0, 0, 0, 0.14),
23
+ 0 3px 14px 2px rgba(0, 0, 0, 0.12);
24
+ }
25
+
26
+ // The placeholder is shown in the list where the dragged item was.
27
+ // Setting opacity to 0 hides it, making it look like the item was "picked up".
28
+ .cdk-drag-placeholder {
29
+ opacity: 0;
30
+ }
31
+
32
+ // Smooth animation when an item is dropped into its new position.
33
+ .cdk-drag-animating {
34
+ transition: transform 250ms cubic-bezier(0, 0, 0.2, 1);
35
+ }
36
+
37
+ // When a cdkDropList is receiving a dragged item, this class is applied.
38
+ // Use it to add a visual indicator (e.g., a subtle background highlight).
39
+ .cdk-drop-list-dragging .cdk-drag:not(.cdk-drag-placeholder) {
40
+ transition: transform 250ms cubic-bezier(0, 0, 0.2, 1);
41
+ }
42
+
43
+ // ---------------------------------------------------------------------------
44
+ // Add project-specific overlay overrides below
45
+ // ---------------------------------------------------------------------------
46
+ // Examples:
47
+ // - MatDialog custom panel classes
48
+ // - MatMenu custom styling
49
+ // - MatTooltip custom templates
50
+ // - MatSelect / MatAutocomplete dropdown panels
@@ -1,5 +1,6 @@
1
1
  /* You can add global styles to this file, and also import other style files */
2
2
  @use 'styles/variables' as *;
3
+ @use 'styles/cdk-overrides';
3
4
 
4
5
  html, body, app-root {
5
6
  height: 100%;