@arsedizioni/ars-utils 22.0.25 → 22.0.31
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.
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# Clipper common — Vitest test suite
|
|
2
|
+
|
|
3
|
+
Effective unit-test suite for the `clipper.common` library: the 6 feature services,
|
|
4
|
+
the shared `ClipperCoreService`, the `ClipperService` facade and `ClipperAuthInterceptor`.
|
|
5
|
+
|
|
6
|
+
## What is covered
|
|
7
|
+
|
|
8
|
+
| Spec | Focus |
|
|
9
|
+
| --- | --- |
|
|
10
|
+
| `core.service.spec.ts` | state mutators (`ensureLoginInfo`, `setLoggedIn`, `setTeams`, `updateContext`, `initializeChannels`, `reset`, `clear`), lazy `loginInfo` load, `initialize` (serviceUri/appUri/flags, client-id / embedded, F5 branch), broadcast handlers (`LOGIN_CHANGED`, `LOGOUT` logged-in/out), `ping` |
|
|
11
|
+
| `login.service.spec.ts` | credential + OAuth login, MFA pending, failure, temporary context, `autoLogin`/`autoLogout`, `confirmIdentity`, `logout` (clears session on success **and** error), `newOTP` |
|
|
12
|
+
| `documents.service.spec.ts` | every endpoint, `references`/`referencesFacets` mode routing + `null`, default taxonomy body, dashboard counters, bag parsing (`loadBag`/`addToBag`/`removeFromBag`/`clearBag`) |
|
|
13
|
+
| `account.service.spec.ts` | password/settings, `updateSettings`→`setChannels`, `updateChannelsState`→`setChannelsState`, the moved channel helpers, `updateTrialInfo` guards + both result branches, links |
|
|
14
|
+
| `archive.service.spec.ts` | folders/files endpoints, `exportArchiveFolders` URL building, multipart `importArchiveFolders`/`saveArchiveFile` form data, blob download |
|
|
15
|
+
| `calendar.service.spec.ts` | all deadline endpoints + team storage + ICS export |
|
|
16
|
+
| `collaboration.service.spec.ts` | teams (incl. `adminsOnly` team-storage rule), contacts, notes |
|
|
17
|
+
| `clipper.service.spec.ts` | facade exposes/forwards feature services, re-exports core signals by identity, delegates `initialize`/`ping` |
|
|
18
|
+
| `auth.interceptor.spec.ts` | header decoration, passthrough of non-Clipper URLs, error mapping (0/403/405/410/5xx), `NotifySystemErrors` flag, 5s debounce |
|
|
19
|
+
|
|
20
|
+
## File placement
|
|
21
|
+
|
|
22
|
+
Drop the files into the library mirroring its structure (import paths assume this):
|
|
23
|
+
|
|
24
|
+
```
|
|
25
|
+
common/
|
|
26
|
+
services/ ← *.service.spec.ts + clipper.service.spec.ts
|
|
27
|
+
interceptors/ auth.interceptor.spec.ts
|
|
28
|
+
testing/ ← clipper-test-helpers.ts (shared TestBed harness + fakes)
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
`vitest.config.ts` goes at the package root and `src/test-setup.ts` wherever your
|
|
32
|
+
setup lives — adjust `setupFiles` accordingly. If you already have a Vitest config,
|
|
33
|
+
just merge the `test` block.
|
|
34
|
+
|
|
35
|
+
## Running
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
npm i -D vitest @analogjs/vite-plugin-angular @analogjs/vitest-angular jsdom
|
|
39
|
+
npx vitest run # single run
|
|
40
|
+
npx vitest # watch
|
|
41
|
+
npx vitest run --coverage # coverage
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
`@angular/*` and `@arsedizioni/ars-utils/*` are the library's own dependencies and
|
|
45
|
+
are used as-is (no mocking). Only `BroadcastService` and `SplashService` are replaced
|
|
46
|
+
by controllable test doubles via TestBed providers.
|
|
47
|
+
|
|
48
|
+
## How it works
|
|
49
|
+
|
|
50
|
+
`createHarness()` (in `testing/clipper-test-helpers.ts`) wires a `TestBed` with the
|
|
51
|
+
HTTP testing backend (`HttpTestingController`), all services and the fakes, resets
|
|
52
|
+
storage, and (unless `skipInitialize`) calls `core.initialize()`. It returns every
|
|
53
|
+
service plus the fakes, so a spec reads like:
|
|
54
|
+
|
|
55
|
+
```ts
|
|
56
|
+
const h = createHarness();
|
|
57
|
+
h.documents.query({ text: 'iva' }).subscribe();
|
|
58
|
+
h.http.expectOne(`${h.serviceUri}/documents`).flush(ok({ items: [] }));
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
`FakeBroadcastService.emit(id, data)` pushes inbound bus messages (for the core
|
|
62
|
+
broadcast handler), while `sendMessage` is a spy recording outbound broadcasts —
|
|
63
|
+
the two are decoupled to avoid feedback loops.
|
|
64
|
+
|
|
65
|
+
## Assumptions / notes
|
|
66
|
+
|
|
67
|
+
- `@Service()` is treated as `@Injectable()`-compatible (it is provided through TestBed).
|
|
68
|
+
- The suite was authored against the library sources but **not executed here**, because
|
|
69
|
+
the private `@arsedizioni` packages and the Angular toolchain aren't installed in the
|
|
70
|
+
authoring environment. Run `vitest` in the repo; if `@Service`/zoneless setup needs a
|
|
71
|
+
tweak, it will be in `src/test-setup.ts` only.
|
|
72
|
+
- `initializeChannels`/`updateChannels` mutate the shared `ClipperChannels` constant
|
|
73
|
+
objects (existing library behaviour) — assertions check the produced channel, not
|
|
74
|
+
object identity, to stay robust.
|
|
@@ -56,8 +56,6 @@ class DateFnsAdapter extends DateAdapter {
|
|
|
56
56
|
constructor() {
|
|
57
57
|
super();
|
|
58
58
|
const matDateLocale = inject(MAT_DATE_LOCALE, { optional: true });
|
|
59
|
-
// MAT_DATE_LOCALE defaults to LOCALE_ID (a string): only a date-fns
|
|
60
|
-
// Locale OBJECT is usable here, a string would break format()/parse().
|
|
61
59
|
if (matDateLocale && typeof matDateLocale === 'object') {
|
|
62
60
|
this.setLocale(matDateLocale);
|
|
63
61
|
}
|
|
@@ -310,22 +308,21 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.1", ngImpor
|
|
|
310
308
|
type: Injectable
|
|
311
309
|
}], ctorParameters: () => [] });
|
|
312
310
|
/**
|
|
313
|
-
* Standalone providers for the
|
|
311
|
+
* Standalone providers for the ars-utils date-fns adapter.
|
|
314
312
|
*
|
|
315
313
|
* Configures Angular Material to use {@link DateFnsAdapter} (Europe/Rome timezone)
|
|
316
314
|
* and the matching {@link MAT_DATE_FNS_FORMATS}.
|
|
317
315
|
*
|
|
318
316
|
* @example
|
|
319
317
|
* bootstrapApplication(AppComponent, {
|
|
320
|
-
* providers: [
|
|
318
|
+
* providers: [provideArsDateFns()]
|
|
321
319
|
* });
|
|
322
320
|
*/
|
|
323
|
-
function
|
|
321
|
+
function provideArsDateFns() {
|
|
324
322
|
return makeEnvironmentProviders([
|
|
325
323
|
{
|
|
326
324
|
provide: DateAdapter,
|
|
327
|
-
useClass: DateFnsAdapter
|
|
328
|
-
deps: [MAT_DATE_LOCALE],
|
|
325
|
+
useClass: DateFnsAdapter
|
|
329
326
|
},
|
|
330
327
|
{ provide: MAT_DATE_FORMATS, useValue: MAT_DATE_FNS_FORMATS }
|
|
331
328
|
]);
|
|
@@ -3796,5 +3793,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.1", ngImpor
|
|
|
3796
3793
|
* Generated bundle index. Do not edit.
|
|
3797
3794
|
*/
|
|
3798
3795
|
|
|
3799
|
-
export { AutoFocusDirective, BroadcastChannelManager, BroadcastService, CHANNEL_NAME, CopyClipboardDirective, DateFnsAdapter, DateFormat, DateInterval, DateIntervalChangeDirective, DeleteModel, EmailsValidatorDirective, EnvironmentService, EqualsValidatorDirective, FileInfo, FileSizeValidatorDirective, FormatHtmlPipe, FormatMarkdownPipe, FormatPipe, GroupModel, GuidValidatorDirective, IDModel, ImportModel, MAT_DATE_FNS_FORMATS, MaxTermsValidatorDirective, NotEmptyValidatorDirective, NotEqualValidatorDirective, NotFutureValidatorDirective, PasswordValidatorDirective, QueryModel, RelationModel, RemoveFocusDirective, ReplacePipe, SafeHtmlPipe, SafeUrlPipe, ScreenService, SearchCallbackPipe, SearchFilterPipe, SelectableModel, SplashService, SqlDateValidatorDirective, SystemUtils, ThemeService, TimeValidatorDirective, UpdateRelationsModel, UrlValidatorDirective, UtilsMessages, ValidIfDirective, ValidatorDirective, ValueModel,
|
|
3796
|
+
export { AutoFocusDirective, BroadcastChannelManager, BroadcastService, CHANNEL_NAME, CopyClipboardDirective, DateFnsAdapter, DateFormat, DateInterval, DateIntervalChangeDirective, DeleteModel, EmailsValidatorDirective, EnvironmentService, EqualsValidatorDirective, FileInfo, FileSizeValidatorDirective, FormatHtmlPipe, FormatMarkdownPipe, FormatPipe, GroupModel, GuidValidatorDirective, IDModel, ImportModel, MAT_DATE_FNS_FORMATS, MaxTermsValidatorDirective, NotEmptyValidatorDirective, NotEqualValidatorDirective, NotFutureValidatorDirective, PasswordValidatorDirective, QueryModel, RelationModel, RemoveFocusDirective, ReplacePipe, SafeHtmlPipe, SafeUrlPipe, ScreenService, SearchCallbackPipe, SearchFilterPipe, SelectableModel, SplashService, SqlDateValidatorDirective, SystemUtils, ThemeService, TimeValidatorDirective, UpdateRelationsModel, UrlValidatorDirective, UtilsMessages, ValidIfDirective, ValidatorDirective, ValueModel, provideArsDateFns };
|
|
3800
3797
|
//# sourceMappingURL=arsedizioni-ars-utils-core.mjs.map
|