@thepalaceproject/circulation-admin 1.43.0-post.2 → 1.43.0-post.4
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/CLAUDE.md +14 -12
- package/dist/circulation-admin.js +1 -1
- package/jest.config.js +48 -16
- package/package.json +4 -17
- package/tests/jest/editorAdapter.test.ts +245 -0
- package/tests/jest/legacy-setup.ts +13 -0
- package/tests/jest/legacyJsdomEnvironment.js +49 -0
- package/tests/jest/models/Admin.test.ts +206 -0
- package/tests/jest/reducers/bookCoverPreview.test.ts +81 -0
- package/tests/jest/reducers/classifications.test.ts +161 -0
- package/tests/jest/reducers/collections.test.ts +96 -0
- package/tests/jest/reducers/complaints.test.ts +166 -0
- package/tests/jest/reducers/createFetchEditReducer.test.ts +220 -0
- package/tests/jest/reducers/createRegisterLibraryReducer.test.ts +51 -0
- package/tests/jest/reducers/customListDetails.test.ts +120 -0
- package/tests/jest/reducers/customListEditor.test.ts +2823 -0
- package/tests/jest/reducers/managePatrons.test.ts +71 -0
- package/tests/jest/utils/sharedFunctions.test.ts +121 -0
- package/tsconfig.json +3 -4
- package/.nycrc.json +0 -8
- package/testReporter.js +0 -29
package/CLAUDE.md
CHANGED
|
@@ -16,16 +16,16 @@ npm run dev-server -- --env=backend=https://your-cm-url # Dev server against re
|
|
|
16
16
|
npm run prod # Production build
|
|
17
17
|
npm run lint # Run ESLint (lint:js) + sass-lint
|
|
18
18
|
npm run lint:js # Run ESLint over the whole tree (eslint . --max-warnings 0)
|
|
19
|
-
npm test # Full test suite (
|
|
20
|
-
npm run test-jest
|
|
21
|
-
npm run
|
|
22
|
-
npm run test-file-ts <path> # Single mocha test: npm run test-file-ts src/components/__tests__/MyTest-test.tsx
|
|
23
|
-
npm run coverage # Both suites with coverage (what CI runs); writes coverage/{mocha,jest}/lcov.info
|
|
24
|
-
npm run coverage-ts # Mocha suite coverage only (nyc)
|
|
25
|
-
npm run coverage-jest # Jest suite coverage only
|
|
19
|
+
npm test # Full test suite (both jest projects)
|
|
20
|
+
npm run test-jest-file <path> # Single test: npm run test-jest-file tests/jest/components/MyTest.test.tsx
|
|
21
|
+
npm run coverage # Test suite with coverage (what CI runs); writes coverage/jest/lcov.info
|
|
26
22
|
npm run dev-test-axe # Dev build with react-axe accessibility checking (output in browser console)
|
|
27
23
|
```
|
|
28
24
|
|
|
25
|
+
Run one jest project at a time with `npx jest --selectProjects=unit` (or `=legacy`). Note
|
|
26
|
+
`--selectProjects` is variadic, so put file paths behind `--testPathPattern` rather than
|
|
27
|
+
after it as positional arguments.
|
|
28
|
+
|
|
29
29
|
The dev server can also read the backend URL from `.env` or `.env.local` with `BACKEND=https://...`.
|
|
30
30
|
|
|
31
31
|
## Architecture
|
|
@@ -65,15 +65,17 @@ The dev server can also read the backend URL from `.env` or `.env.local` with `B
|
|
|
65
65
|
|
|
66
66
|
## Testing
|
|
67
67
|
|
|
68
|
-
**
|
|
68
|
+
Everything runs under jest, split into **two jest `projects`** (see `jest.config.js`):
|
|
69
|
+
|
|
70
|
+
1. **`unit`** (for all new tests): Tests in `tests/jest/` mirroring `src/` structure. Uses React Testing Library, jest-dom, and MSW for API mocking. Test utilities in `tests/jest/testUtils/withProviders.tsx` provide `renderWithProviders()` and `componentWithProviders()` to wrap components with Redux, Context, and QueryClient. Runs on `jest-fixed-jsdom` so MSW can intercept `fetch`.
|
|
69
71
|
|
|
70
|
-
|
|
72
|
+
2. **`legacy`**: Tests in `src/*/__tests__/` directories, still written with Enzyme, chai, and sinon. Being rewritten as `unit` tests; **do not add new ones**. Runs on `tests/jest/legacyJsdomEnvironment.js` — plain jsdom, because `jest-fixed-jsdom` substitutes undici's `FormData`, which rejects `new FormData(formElement)`. That environment also restores `global.jsdom` and tolerates unhandled promise rejections; both are documented in the file. Delete the project, the environment, and `tests/jest/legacy-setup.ts` along with the last enzyme test — that is what unblocks React 17+, since enzyme has no adapter beyond React 16.
|
|
71
73
|
|
|
72
|
-
|
|
74
|
+
Both projects need `testEnvironmentOptions.customExportConditions: [""]`. Without it, jsdom's default `["browser"]` condition resolves **sinon** to its ESM bundle and every suite that imports it fails to parse.
|
|
73
75
|
|
|
74
|
-
**Coverage:**
|
|
76
|
+
**Coverage:** Reported to Codecov under the `jest` flag. `collectCoverageFrom` must stay at the _top level_ of `jest.config.js`, not inside `projects` — jest reads it off the global config, and setting it per-project leaves it globally undefined, so every executed file gets instrumented (including `tests/` helpers).
|
|
75
77
|
|
|
76
|
-
Jest's `roots` must keep `<rootDir>/src` so `collectCoverageFrom` can discover source files no
|
|
78
|
+
Jest's `roots` must keep `<rootDir>/src` so `collectCoverageFrom` can discover source files no test imports; otherwise they are silently omitted rather than counted as uncovered, and the reported percentage rises while real coverage is unchanged.
|
|
77
79
|
|
|
78
80
|
## Code Style
|
|
79
81
|
|