Commit Graph

2 Commits

Author SHA1 Message Date
riyadhafraa 84398de390 Task #511: Fully remove Chat feature
Destructive removal per user confirmation ("حذف نهائي ما يرجع").

Removed:
- API: routes/conversations.ts, schema/conversations.ts, all chat
  socket handlers in src/index.ts, /admin/users/:id/dependents/
  conversations+messages endpoints, conversation/message dependency
  counts in users/stats routes.
- Web: pages/chat.tsx, /chat route, dock chat filter, MessageSquare
  icon and messages StatCard on home, all chat-related UI in
  notifications + admin (dependency badges, delete-dialog rows,
  UserDependentConversations/Messages sections, count map keys).
- Locales: nav.chat, home.stats.messages, full chat.* block,
  admin.deleteUser conv/msgCount, admin.users.counts.conv/msg,
  admin.audit.unit.conversation_*/message_*, admin.dependents.user*.
- OpenAPI spec: tags, all /conversations/* paths, conv/msg dependent
  paths, related schemas (ConversationWithDetails, MessageWithSender,
  UserDependentConversation/MessageItem+Page, etc.), UserProfile and
  UserDeletionConflict conv/msg fields, HomeStats.unreadMessages.
  Regenerated client via orval.
- Database: dropped message_reads, messages,
  conversation_participants, conversations (CASCADE); deleted
  notifications with related_type='conversation' or type='chat';
  deleted apps row with slug='chat'; ran drizzle push-force.
- Seed: removed chat:access permission + user-role assignment +
  seeded chat app entry from scripts/src/seed.ts.
- Tests: deleted conversations-leave.test.mjs; cleaned chat refs from
  list-dependency-counts, delete-force-warnings, audit-log-coverage,
  and admin-inline-dependency-counts (e2e) — replaced chat dependents
  with note dependents where needed for force-delete coverage.

Notes preserved: notes.tsx noConversationsYet/conversationWith refer
to NOTE THREADS (not chat) and were intentionally NOT touched.

executive-meetings.ts not modified per replit.md restriction.
Pre-existing flaky test failures in executive-meetings/group/etc
suites remain unrelated to this task.
2026-05-12 10:51:31 +00:00
riyadhafraa 53d13a5939 Add browser tests for the inline dependency counts on the admin lists
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
2026-05-01 08:40:42 +00:00