Task #184. The admin Apps / Services / Users panels render small
testid'd chips under each row that summarize how many dependent
records reference the entity. Until now, that behavior had no
regression coverage, which made it easy to silently drop the chips
in a future refactor.
Adds artifacts/tx-os/tests/admin-inline-dependency-counts.spec.mjs.
The spec seeds, per locale (en + ar):
- One app with every dep kind populated (groups + restrictions +
opens) and one app with none.
- One service with orders and one service with none.
- One user with notes / orders / conversations / messages and one
bare user.
Asserts that:
- The container `[data-testid="<entity>-counts-<id>"]` and each
populated child chip render with the localized count text.
- The container is omitted entirely (count = 0 in DOM) when the
entity has zero dependents — anchored by the row's delete button
so we know the row itself rendered.
- <html dir> matches the locale (rtl in Arabic, ltr in English) and
the chip row's computed flex direction follows it, so a future
hard-coded LTR regression would fail.
Two implementation notes worth flagging:
- Switching admin sections via `page.goto` only changes the URL
hash on the same path, which does NOT trigger a reload, and the
admin page only reads `?section=` once on mount. The spec pairs
each goto with `page.reload()` so the section actually re-applies.
- The userWithDeps order rides on serviceWithOrders (instead of
serviceNoOrders) so the bare service truly has zero orders. As a
side effect serviceWithOrders has 2 orders, so the chip text
assertion only checks the localized noun and a non-zero digit
rather than pinning the exact count.
Cleanup runs in afterAll: deletes messages / conversations / notes /
service_orders before users (sender_id and created_by have no ON
DELETE rule) and service_orders before services (RESTRICT on
service_id), matching the constraints in lib/db/src/schema.
Verified locally: both new tests pass and the existing admin specs
(admin-create-group-app-visibility, admin-user-edit-review en/ar)
still pass.
Cleanup vs the previous attempt: removed an ad-hoc tests/_debug.mjs
that was used to reproduce the hash-only-navigation bug and reverted
artifacts/tx-os/public/opengraph.jpg, which had been touched by an
unrelated incidental rebuild during local testing.
Replit-Task-Id: 8a1f407d-2a22-4e70-b8ad-25ff7d9b0dae