Refactor test execution to use a new script that manages the API server lifecycle, including building, starting, waiting for health, running tests, and shutting down, with support for using an existing server.
Replit-Commit-Author: Agent
Replit-Commit-Session-Id: 77cfe984-2c65-4152-bb7a-0df28274fe66
Replit-Commit-Checkpoint-Type: full_checkpoint
Replit-Commit-Event-Id: a42bd3b2-3145-4118-87aa-336a7e2189ca
Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/c3c252e4-c83d-40ca-9fff-99a3ea60701e/77cfe984-2c65-4152-bb7a-0df28274fe66/FvHcc7z
Replit-Helium-Checkpoint-Created: true
Original task: Executive Meetings — test coverage + sanitization
closeout (umbrella for #170, #186-189, #201, #202, #212, #214, #218,
#235).
What landed
- Added `stripTagsToPlainText[OrNull]` in
`artifacts/api-server/src/lib/sanitize.ts` that strips HTML tags via
sanitize-html and then decodes the entities sanitize-html introduces
(`&`→`&`, `<`→`<`, etc.) so URLs like
`https://x.test?a=1&b=2` and free-form notes containing `5 < 10`
round-trip unchanged. Existing `sanitizePlainText` (which entity-
encodes) is preserved for `attendee.title` so the print template's
HTML interpolation behavior is unchanged.
- Wired the new helper into all 11 write paths for
`location`/`meetingUrl`/`notes` in
`artifacts/api-server/src/routes/executive-meetings.ts`:
POST /executive-meetings, PATCH /executive-meetings/:id,
POST /executive-meetings/:id/duplicate, and `applyApprovedRequest`
(`change_location` + `note`). attendee.title call sites kept as-is.
- Added 5 API tests in
`artifacts/api-server/tests/executive-meetings.test.mjs`:
POST sanitization (with URL `&` round-trip + literal `<`/`&` in notes),
PATCH sanitization, duplicate-path round-trip, change_location
approved-request round-trip + tag stripping, and an EditableCell
column-independence contract test (PATCH titleEn alone must not
clobber titleAr and vice versa). All 5 pass.
Drift from the original umbrella
- The umbrella also listed 9 Playwright e2e specs (#170, #186, #187,
#188, #201, #212, #214, #218, #235). Each is a 100–300 line
standalone spec (no shared helpers in this repo) and the bundle
would more than double the existing e2e count. Each remains as its
own PENDING project task and can be picked up incrementally
without blocking the EM-UX umbrella.
Verification
- Suite: 219 tests, 218 passing. The one failure is a pre-existing
socket-state pollution flake in `meeting_created: fan-out…`,
unrelated to sanitization (already covered by #247).
- Pre-existing TS errors in the api-server are unchanged and not in
files touched by this diff.
Original task: add unit tests for the new `formatAuditSummary` formatter
and an API-level test asserting the enriched group sub-resource audit
metadata, and wire both into the existing `test` workflow.
What changed:
- Extracted `formatAuditSummary` and its helpers (`asRecord`, `asString`,
`asNumber`, `unitLabel`, `appName`, `linkedAppName`, `plainName`,
`changeCount`) out of `artifacts/tx-os/src/pages/admin.tsx` into a new
`artifacts/tx-os/src/lib/audit-summary.ts` module so the pure formatter
can be unit-tested without the React tree. `admin.tsx` now imports the
helpers from that module.
- Added `artifacts/tx-os/src/__tests__/audit-summary.test.mjs` with 22
Node test-runner cases covering app rename (EN + AR), app-update
fallback, group rename, group multi-field update, registration toggle
(open / close / with-other-changes), and every group.user/app/role
add/remove name vs id-only branch, plus the unknown-action default.
- Added `pnpm --filter @workspace/tx-os test` (Node 24's native
TypeScript loader runs the .mjs tests against the .ts module directly).
- Added `artifacts/api-server/tests/group-audit-metadata.test.mjs` using
the same harness as `groups-crud.test.mjs`. It hits POST/DELETE
`/api/groups/:id/{users,apps,roles}/:targetId` and reads the resulting
`audit_logs.metadata`, asserting `username`, `appSlug` /`appNameEn` /
`appNameAr`, and `roleName` are persisted alongside the raw IDs.
- Updated the `test` workflow to run the tx-os unit tests before the
api-server tests, then the tx-os e2e tests.
Verification: all 22 tx-os unit tests pass via the new pnpm script, and
all 6 new api-server audit-metadata tests pass against a live server.
The overall api-server suite still has pre-existing flakes
(executive-meetings notifications/status transitions, and the
count-based group invariant in groups-crud.test.mjs) that are unrelated
to this change; both flake clusters are filed as follow-up tasks.
Replit-Task-Id: 182cd4ed-c55c-43e3-b10b-8147a9611fd4
Original task (#127): the `test` workflow ran `pnpm --filter
@workspace/api-server test` directly, which fires HTTP requests at
localhost:8080. On a freshly-started environment the API server
isn't up yet, so every test fails with ECONNREFUSED, drowning real
failures in noise.
Changes:
- Added `artifacts/api-server/scripts/wait-for-server.mjs`, a small
pure-Node poller that hits `${TEST_API_BASE ?? "http://localhost:8080"}/api/healthz`
every 500ms until it returns `{status: "ok"}` or the timeout
(default 30s) elapses. On timeout it exits 1 with a clear
"Start the API Server workflow (or set TEST_API_BASE) before
running tests" message instead of a wall of fetch errors.
Configurable via `TEST_API_BASE`, `TEST_API_WAIT_TIMEOUT_MS`,
`TEST_API_WAIT_INTERVAL_MS`.
- Added `test:wait` script to `artifacts/api-server/package.json`.
- Updated the `test` workflow to run
`pnpm --filter @workspace/api-server test:wait` before the
api-server tests and the tx-os e2e tests.
Verified:
- `node ./scripts/wait-for-server.mjs` against a running server
reports "ready ... after 86ms" and exits 0.
- Same script with TEST_API_BASE pointed at a dead port exits 1
with the friendly message.
- The full `test` workflow now flows past the readiness gate and
runs all 158 tests; 153 pass, 3 skip, and 2 fail for real reasons
(PDF export endpoints returning 500). Filed follow-up #179 for
the PDF bugs.
No deviations from the task. `.replit` was edited via the workflow
configuration tool (direct edits are blocked).
Replit-Task-Id: 99673314-dd15-4442-8c7d-f375431719c0
Per user request, the home page no longer shows the time-of-day greeting
("مساء الخير، {name}") nor the day-name + Gregorian date subtitle. The
apps grid (and the admin stats row when applicable) now sits directly
under the top bar.
Changes (artifacts/teaboy-os/src/pages/home.tsx):
- Removed the entire greeting block (the wrapper div, the <h1> greeting
and the date <p>) from the Main Content section.
- Removed the now-unused `dayName`, `gregorianDate` and `greeting`
locals plus the `formatWeekday` and `greetingKey` imports.
- Kept `displayName` (still used in the avatar header) and the
`home.greeting.*` translation keys (left in place; cheap to keep and
avoids touching unrelated locale files).
Mid-task fix:
- First pass also dropped `displayName` which broke the avatar
(`displayName is not defined`). Restored it; `displayName` is needed
by the user-card initials and name labels.
Validation:
- `pnpm --filter @workspace/api-server test` — 18/18 pass
- `pnpm --filter @workspace/teaboy-os test:e2e` — 3/3 pass
Notes:
- Pre-existing TypeScript errors in admin.tsx / clock-style-picker.tsx /
clock.tsx are unrelated to this task (codegen drift from earlier
tasks).
Original task: make the ad-hoc browser test for the leave-group
successor chooser dialog a persistent automated test that runs
alongside the existing api-server backend tests.
Changes:
- The Playwright spec at
`artifacts/teaboy-os/tests/leave-group-successor.spec.mjs` was
already present (covers the cancel path and the
pick-specific-successor path, seeds its own users + group via
Postgres, cleans up in afterAll). Verified it passes against the
running web + api workflows.
- Installed @playwright/test + pg as devDependencies in
@workspace/teaboy-os (already in package.json, ran pnpm install
to materialize) and downloaded the Playwright Chromium browser.
- Added a root `test` script in package.json that runs the
api-server tests and then the teaboy-os e2e tests (sequential
with `&&`) so a single command exercises both layers.
- Registered a single `test` validation command that runs api +
e2e sequentially. Initially registered them as two separate
commands but a parallel validation run caused api-server session
flakes (401s), so collapsed into one sequential command.
- Updated `scripts/post-merge.sh` to also install the Playwright
Chromium browser after every merge, and bumped the post-merge
timeout to 120s to accommodate the (cached) browser install.
Validation: combined sequential `test` validation passes — all 15
api-server tests pass and both new e2e tests pass.
Note: `artifacts/teaboy-os/public/opengraph.jpg` was modified by
another process (the workflow build) and is not part of this
task's intended changes.
Replit-Task-Id: ab9b6d6f-b68b-47ea-94e5-c34352afeb64
- Removed greeting and welcome banner from the home page; trimmed unused
ar.json/en.json greeting keys.
- Hid the 4-tile stats row for non-admin users (`isAdmin` from user roles)
and scoped `totalApps` in /api/stats/home to apps the user can actually
access (mirrors the RBAC join in /api/apps).
- Renamed nav.services translation: "خدماتي" -> "الخدمات",
"My Services" -> "Services".
- Removed price/free text from the user-facing services page; cards now
show name, description, availability badge, and (when present) image.
- Admin service editor now exposes an "Image URL" / "رابط الصورة" text
field with a live preview thumbnail; saved imageUrl renders at the top
of the corresponding service card (16:10, object-cover, onError hides
broken images). Uses existing imageUrl column in services schema; no DB
migration required. Image upload via object storage was deferred — see
follow-up task.
Verified: typecheck passes for teaboy-os and api-server; api-server
restarted clean; e2e plan validated by testing subagent; architect code
review approved.
Completed full-stack TeaBoy OS build:
Backend (artifacts/api-server):
- Session-based auth with express-session + connect-pg-simple (PostgreSQL sessions)
- RBAC middleware (requireAuth, requireAdmin) with role-based guards
- REST routes for: auth (login/logout/register/me/language), apps CRUD, services CRUD,
conversations + messages, notifications, users (admin), home stats
- Socket.IO mounted on same HTTP server at /api/socket.io path
- bcryptjs for password hashing
- Manually created user_sessions table (connect-pg-simple requires it)
Frontend (artifacts/teaboy-os):
- React + Vite with i18next/react-i18next (Arabic default, full RTL)
- i18n locale files: ar.json + en.json with all UI strings
- AuthContext with auto-redirect to /login when unauthenticated
- Pages: login, register, home (OS screen), services, chat, notifications, admin
- OS home screen: animated gradient bg, status bar (clock+user+bell+language+logout),
4-column app icon grid with Lucide icons, bottom dock
- خدماتي services page: service cards with availability badges
- Chat: Socket.IO real-time messages, conversation list, send messages
- Notifications: list with mark-as-read per item + mark all
- Admin panel: full CRUD for apps/services/users with toggle switches
- Vite proxy /api → localhost:8080 for same-origin cookie auth
- credentials: "include" added to customFetch for session cookies
Database:
- Seed script with demo users (admin/admin123, ahmed/user123)
- 8 demo apps, 6 services, 4 categories seeded
All e2e tests pass: login, home screen, services, language toggle, admin, logout