Files
ocis/web/tests
Matteo 75d9af7d92 fix(web): break web-pkg/web-test-helpers/design-system dep cycle without changing the published API
The workspace package graph had one strongly connected component:
{web-pkg, web-test-helpers, design-system}. web-pkg and design-system
depend on web-test-helpers for testing; web-test-helpers depended back
on both (design-system for the real DesignSystem Vue plugin, web-pkg
for types used by its own mocks). pnpm already warned about this
("cyclic workspace dependencies"); it also blocks giving these
packages a cached Nx build target with dependsOn: ["^build"].

An earlier attempt at this fix moved the web-pkg-coupled mocks out of
@ownclouders/web-test-helpers and into a new @ownclouders/web-pkg/src
subpath, removing them from web-test-helpers' public exports. That is
a breaking change for the 17 published web-extensions packages that
depend on @ownclouders/web-test-helpers (^12.5.0) - and a silent one,
since defaultPlugins() would only throw at test-run time.

This does the same structural fix without touching the public API:

- New @ownclouders/web-test-helpers-core: everything generic (mount,
  shallowMount, getComposableWrapper, defaultStubs, httpResponse,
  createRouter, writable, ...) plus an injectable defaultPlugins that
  reads the real DesignSystem plugin and pinia store factory from a
  small registry instead of importing them. Depends on nothing in the
  cycle.
- web-pkg/src/testing: the mocks that need web-pkg's own types
  (defaultComponentMocks, createMockStore/PiniaMockOptions,
  useAppDefaultsMock, useGetMatchingSpaceMock) move here, published as
  a new "./src/testing" subpath so the facade can still reach them.
  web-pkg's own specs use this locally; nothing else needed to change.
- @ownclouders/web-test-helpers is now a thin facade: it registers the
  real DesignSystem plugin and pinia factory (import side effect) and
  re-exports web-test-helpers-core + web-pkg/src/testing under the
  exact same names. External consumers see zero difference.
- design-system's and web-pkg's own specs (only ones inside the former
  cycle) import straight from web-test-helpers-core / ../testing
  instead of the facade; every other package keeps importing
  @ownclouders/web-test-helpers unchanged.
- Shared vitest setup (tests/unit/config/vitest.init.ts) registers the
  same real plugin/factory for those two packages' own test runs,
  since they bypass the facade's registration.

Verified: pnpm install no longer warns about a workspace cycle;
vue-tsc, eslint and prettier all pass; all 16 vitest projects pass
individually (380 files / 3130 tests, 0 failures, matching pre-change
coverage exactly).
2026-09-21 17:45:42 +02:00
..