Compare commits
16
Commits
c66e65d718
...
dev/safe
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
843fc38f12
|
||
|
|
4fde9c31a0
|
||
|
|
ba5bb21961
|
||
|
|
bf3a7782c5
|
||
|
|
f95957bd75
|
||
|
|
691e0113ec
|
||
|
|
4b656921f7
|
||
|
|
bf57305a33
|
||
|
|
44eb97ec0f
|
||
|
|
5a895db74a
|
||
|
|
f11288d0e0
|
||
|
|
8bf4c04f0b
|
||
|
|
9255533215
|
||
|
|
0e034e0da3
|
||
|
|
96dd20e06b
|
||
|
|
b289382747
|
@@ -1,6 +1,12 @@
|
|||||||
**/node_modules
|
**/node_modules
|
||||||
.git
|
.git
|
||||||
|
.github
|
||||||
|
.gitea
|
||||||
.env
|
.env
|
||||||
|
.env.*
|
||||||
*.log
|
*.log
|
||||||
|
logs
|
||||||
|
coverage
|
||||||
|
**/coverage
|
||||||
docker-compose.yml
|
docker-compose.yml
|
||||||
.dockerignore
|
.dockerignore
|
||||||
|
|||||||
@@ -0,0 +1,51 @@
|
|||||||
|
## Summary
|
||||||
|
|
||||||
|
<!-- Ano ang ginawa mo tell us walang fluff. -->
|
||||||
|
|
||||||
|
## Type of change
|
||||||
|
|
||||||
|
- [ ] Feature
|
||||||
|
- [ ] Bug fix
|
||||||
|
- [ ] Refactor / chore
|
||||||
|
- [ ] Docs
|
||||||
|
- [ ] Hotfix
|
||||||
|
|
||||||
|
## Related issue / ticket
|
||||||
|
|
||||||
|
Closes #
|
||||||
|
|
||||||
|
## Changes
|
||||||
|
|
||||||
|
<!-- Bullet list ng mga actual changes. Kung malaki ang PR, group by area (backend, frontend, db, infra). -->
|
||||||
|
|
||||||
|
-
|
||||||
|
-
|
||||||
|
|
||||||
|
## How to test
|
||||||
|
|
||||||
|
<!-- Steps para ma-verify ng reviewer. Kung may env vars / migrations / seed data na kailangan, isulat dito. -->
|
||||||
|
|
||||||
|
1.
|
||||||
|
2.
|
||||||
|
|
||||||
|
## Screenshots / recordings
|
||||||
|
|
||||||
|
<!-- Kung may UI change. Delete section kung wala. -->
|
||||||
|
|
||||||
|
## Database changes
|
||||||
|
|
||||||
|
- [ ] No schema changes
|
||||||
|
- [ ] Migration included and tested on QAS
|
||||||
|
- [ ] Backward compatible (safe to rollback)
|
||||||
|
|
||||||
|
## Checklist before requesting review
|
||||||
|
|
||||||
|
- [ ] Branch is up to date with `main` / `develop`
|
||||||
|
- [ ] No leftover `console.log`, commented-out code, or debug flags
|
||||||
|
- [ ] Env vars / secrets documented (not committed)
|
||||||
|
- [ ] Tested locally (and on QAS if applicable)
|
||||||
|
- [ ] No unrelated files included in diff
|
||||||
|
|
||||||
|
## Notes for reviewer
|
||||||
|
|
||||||
|
<!-- Anything tricky, known limitations, or follow-up work na hindi kasama dito. -->
|
||||||
@@ -97,4 +97,7 @@ jobs:
|
|||||||
cp "$HOME/new_starr/.env" .env
|
cp "$HOME/new_starr/.env" .env
|
||||||
docker compose -p new_starr up -d --build --remove-orphans
|
docker compose -p new_starr up -d --build --remove-orphans
|
||||||
docker compose -p new_starr ps
|
docker compose -p new_starr ps
|
||||||
|
# Reclaim space: superseded image layers and build cache older than 3 days.
|
||||||
|
docker image prune -f
|
||||||
|
docker builder prune -f --filter until=72h
|
||||||
REMOTE
|
REMOTE
|
||||||
|
|||||||
@@ -1,34 +0,0 @@
|
|||||||
name: E2E tests
|
|
||||||
|
|
||||||
on:
|
|
||||||
pull_request: {}
|
|
||||||
push:
|
|
||||||
branches: [main, qas]
|
|
||||||
workflow_dispatch: {}
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
e2e:
|
|
||||||
runs-on: [self-hosted, ux]
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Install dependencies
|
|
||||||
run: pnpm install --frozen-lockfile=false
|
|
||||||
|
|
||||||
- name: Install Playwright Firefox
|
|
||||||
run: pnpm --filter e2e exec playwright install firefox --with-deps
|
|
||||||
|
|
||||||
- name: Run e2e suite
|
|
||||||
run: pnpm --filter e2e test
|
|
||||||
|
|
||||||
- name: Upload Playwright report
|
|
||||||
if: failure()
|
|
||||||
uses: actions/upload-artifact@v4
|
|
||||||
with:
|
|
||||||
name: playwright-report
|
|
||||||
path: apps/e2e/playwright-report/
|
|
||||||
retention-days: 14
|
|
||||||
|
|
||||||
- name: Sweep QA-TEST fixtures
|
|
||||||
if: always()
|
|
||||||
run: node -e "require('./apps/e2e/helpers/cleanup').cleanupQaTestFixtures().then(r => console.log('Removed:', r)).catch(e => { console.error(e); process.exit(0); })"
|
|
||||||
@@ -30,9 +30,6 @@ coverage/
|
|||||||
|
|
||||||
# ── Testing ───────────────────────────────────────────────────────────────────
|
# ── Testing ───────────────────────────────────────────────────────────────────
|
||||||
test-results/
|
test-results/
|
||||||
playwright-report/
|
|
||||||
blob-report/
|
|
||||||
.last-run.json
|
|
||||||
|
|
||||||
# ── Uploads / Temp ────────────────────────────────────────────────────────────
|
# ── Uploads / Temp ────────────────────────────────────────────────────────────
|
||||||
uploads/
|
uploads/
|
||||||
|
|||||||
@@ -55,7 +55,28 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
{$CDN_DOMAIN:cdn.yourdomain.com} {
|
{$CDN_DOMAIN:cdn.yourdomain.com} {
|
||||||
|
# Browser-direct presigned PUT uploads need a storage CORS preflight.
|
||||||
|
# Garage's default bucket policy only advertises GET, so handle the
|
||||||
|
# browser preflight at the public edge and expose multipart ETags.
|
||||||
|
@storage_preflight method OPTIONS
|
||||||
|
header @storage_preflight {
|
||||||
|
Access-Control-Allow-Origin "{http.request.header.Origin}"
|
||||||
|
Access-Control-Allow-Methods "GET, HEAD, PUT, POST, DELETE, OPTIONS"
|
||||||
|
Access-Control-Allow-Headers "{http.request.header.Access-Control-Request-Headers}"
|
||||||
|
Access-Control-Max-Age "86400"
|
||||||
|
}
|
||||||
|
respond @storage_preflight 204
|
||||||
|
|
||||||
|
header {
|
||||||
|
Access-Control-Allow-Origin "*"
|
||||||
|
Access-Control-Expose-Headers "ETag, Content-Length, Content-Range, Accept-Ranges, Content-Disposition"
|
||||||
|
}
|
||||||
|
|
||||||
reverse_proxy localhost:3900 {
|
reverse_proxy localhost:3900 {
|
||||||
header_up X-Real-IP {http.request.header.X-Real-IP}
|
header_up X-Real-IP {http.request.header.X-Real-IP}
|
||||||
|
header_down -Access-Control-Allow-Origin
|
||||||
|
header_down -Access-Control-Allow-Methods
|
||||||
|
header_down -Access-Control-Allow-Headers
|
||||||
|
header_down -Access-Control-Expose-Headers
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,21 +1,21 @@
|
|||||||
# STAR Phase 1 — Tier 1 Auth System
|
# STARR Project by Philproperties
|
||||||
## Technical Documentation
|
|
||||||
|
|
||||||
**Version:** 1.0.0
|
**Version:** 1.0.0
|
||||||
**Date:** October 6, 2025
|
**Date:** October 6, 2025
|
||||||
**Stack:** Node.js · Express · Sequelize (PostgreSQL) · JWT · Google OAuth 2.0 · Nodemailer
|
**Stack:** Node.js · Express · Sequelize (PostgreSQL) · Google OAuth 2.0 · Nodemailer
|
||||||
**Deployment** DigitalOcean Droplet (3 Droplets for API + S3 and Postgres)
|
**Features:** Courses, Units, Lessons, Training, Subscriptionss)
|
||||||
|
|
||||||
|
## Contributing
|
||||||
|
Every contributors must take note that we have [Gitea](https://gitea.orij.space/kennethscoffee/starr-philproperties) owned by us independently so create your account here, We expect that you are in `dev/safe` branch so we recommend to have your own forked repository in Gitea here's summary:
|
||||||
|
|
||||||
|
```
|
||||||
|
BRANCH_NAME | DESCRIPTION
|
||||||
|
-------------------------
|
||||||
|
main - A protected branch maintain by creators (Any commits from other will be automatically rejected)
|
||||||
|
staging-qa - Everytime na may Pull Requests (PR) from your forked repository dito mismo
|
||||||
|
sa branch na ito kami mag-check per feature, per modification and also bug.
|
||||||
|
staging-uat - Working in progress so I will tell more about it.
|
||||||
|
dev/safe - With your forked repository this is default branch
|
||||||
|
```
|
||||||
|
|
||||||
## Self-hosting
|
## Self-hosting
|
||||||
See [SELF_HOSTING.md](./SELF_HOSTING.md) for the full Docker Compose setup guide.
|
See [Wiki](https://gitea.orij.space/kennethscoffee/starr-philproperties/wiki/Self-hosting-%28Docker%29)
|
||||||
|
|
||||||
## TODO
|
|
||||||
Branchings and Tags (Backups)
|
|
||||||
```
|
|
||||||
main (protected) → prod
|
|
||||||
qas (protected) → staging
|
|
||||||
dev (protected*) → integration/playground
|
|
||||||
feature/xyz → short-lived, deleted after merge
|
|
||||||
hotfix/xyz → for urgent prod patches
|
|
||||||
+ tags (v1.0.9...) → released snapshots
|
|
||||||
```
|
|
||||||
|
|||||||
-226
@@ -1,226 +0,0 @@
|
|||||||
# Self-Hosting `new_starr` (Docker Compose) — Step-by-Step
|
|
||||||
|
|
||||||
### ***Video tutorial soon***
|
|
||||||
|
|
||||||
This stack bundles everything: PostgreSQL, Valkey (Redis), Garage (S3), the API, and the
|
|
||||||
frontend. Battle-tested end-to-end on a completely fresh Debian machine on 2026-08-29
|
|
||||||
every gotcha below actually happened once and is now fixed or documented.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 0. What you need
|
|
||||||
|
|
||||||
- Docker Engine + Compose plugin
|
|
||||||
- Node.js 22 + pnpm (only needed once, to build the frontend bundle)
|
|
||||||
- Git access to this repo
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 1. Install Docker
|
|
||||||
|
|
||||||
This block auto-detects `debian` vs `ubuntu` from `/etc/os-release` **and** probes
|
|
||||||
Docker's repo for your codename before adding it — if your codename is too new and 404s
|
|
||||||
(interim/dev releases lag Docker's repo by months), it automatically falls back to the
|
|
||||||
latest codename Docker actually publishes for your distro. No manual edits needed:
|
|
||||||
```bash
|
|
||||||
sudo apt-get update
|
|
||||||
sudo apt-get install -y ca-certificates curl gnupg
|
|
||||||
sudo install -m 0755 -d /etc/apt/keyrings
|
|
||||||
|
|
||||||
. /etc/os-release
|
|
||||||
DOCKER_DISTRO="$ID" # debian or ubuntu
|
|
||||||
DOCKER_CODENAME="$VERSION_CODENAME"
|
|
||||||
|
|
||||||
# Fallback list, newest first, per distro — used only if the detected codename 404s
|
|
||||||
case "$DOCKER_DISTRO" in
|
|
||||||
ubuntu) FALLBACKS="noble jammy focal" ;;
|
|
||||||
debian) FALLBACKS="bookworm bullseye" ;;
|
|
||||||
*) echo "Unsupported distro '$DOCKER_DISTRO' — Docker only publishes debian/ubuntu repos." >&2; exit 1 ;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
if ! curl -fsSL -o /dev/null "https://download.docker.com/linux/${DOCKER_DISTRO}/dists/${DOCKER_CODENAME}/Release"; then
|
|
||||||
echo "Docker has no repo for ${DOCKER_DISTRO} ${DOCKER_CODENAME} yet, falling back..." >&2
|
|
||||||
for fb in $FALLBACKS; do
|
|
||||||
if curl -fsSL -o /dev/null "https://download.docker.com/linux/${DOCKER_DISTRO}/dists/${fb}/Release"; then
|
|
||||||
DOCKER_CODENAME="$fb"
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
echo "Using ${DOCKER_DISTRO} ${DOCKER_CODENAME}" >&2
|
|
||||||
fi
|
|
||||||
|
|
||||||
curl -fsSL "https://download.docker.com/linux/${DOCKER_DISTRO}/gpg" | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
|
|
||||||
sudo chmod a+r /etc/apt/keyrings/docker.gpg
|
|
||||||
|
|
||||||
echo \
|
|
||||||
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/${DOCKER_DISTRO} \
|
|
||||||
${DOCKER_CODENAME} stable" | \
|
|
||||||
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
|
|
||||||
|
|
||||||
sudo apt-get update
|
|
||||||
sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
|
|
||||||
```
|
|
||||||
(The `FALLBACKS` lists above are current as of 2026-08 — bump them if Docker ships a
|
|
||||||
newer stable codename by the time you read this.)
|
|
||||||
|
|
||||||
Let your user run Docker without `sudo`:
|
|
||||||
```bash
|
|
||||||
sudo usermod -aG docker $USER
|
|
||||||
newgrp docker
|
|
||||||
docker compose version # sanity check
|
|
||||||
```
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 2. Clone & install
|
|
||||||
|
|
||||||
```bash
|
|
||||||
git clone git@github.com:rgrgogu/new_starr.git
|
|
||||||
cd new_starr
|
|
||||||
corepack enable && corepack prepare pnpm@11.3.0 --activate
|
|
||||||
pnpm install
|
|
||||||
```
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 3. Configure environment — **three** files, not two
|
|
||||||
|
|
||||||
### `apps/api/.env`
|
|
||||||
```bash
|
|
||||||
cp apps/api/.env-production apps/api/.env
|
|
||||||
```
|
|
||||||
Fill in every `CHANGE_ME`. For a **local bundled stack** (as opposed to CockroachDB
|
|
||||||
Cloud / managed S3), these specific values matter:
|
|
||||||
```env
|
|
||||||
DB_HOST=postgres
|
|
||||||
DB_PORT=5432
|
|
||||||
DB_SSL=false # bundled Postgres has no TLS
|
|
||||||
CACHE_DRIVER=redis
|
|
||||||
REDIS_URL=redis://valkey:6379
|
|
||||||
S3_ENDPOINT=http://garage:3900
|
|
||||||
GARAGE_RPC_SECRET=<openssl rand -hex 32>
|
|
||||||
```
|
|
||||||
Generate every secret independently:
|
|
||||||
```bash
|
|
||||||
node -e "console.log(require('crypto').randomBytes(32).toString('hex'))"
|
|
||||||
```
|
|
||||||
|
|
||||||
### `apps/web/.env`
|
|
||||||
```bash
|
|
||||||
cd apps/web && cp .env.example .env
|
|
||||||
```
|
|
||||||
Fill in `VITE_API_URL`, `VITE_APP_URL`, etc., then `cd ../..`.
|
|
||||||
|
|
||||||
### Root `new_starr/.env` — easy to miss, causes silent failures
|
|
||||||
`docker-compose.yml`'s bundled `postgres` service reads `${DB_NAME}`, `${DB_USER}`,
|
|
||||||
`${DB_PASSWORD}` from a **root-level** `.env` — NOT from `apps/api/.env`. Create it
|
|
||||||
separately, with **exactly the same values** as the DB block you just put in
|
|
||||||
`apps/api/.env`:
|
|
||||||
```env
|
|
||||||
DB_NAME=starr
|
|
||||||
DB_USER=starr
|
|
||||||
DB_PASSWORD=<same password as apps/api/.env>
|
|
||||||
```
|
|
||||||
⚠️ Postgres only reads these once, at first-ever container start, and bakes them into
|
|
||||||
its data volume. If the two files ever drift apart afterward, you'll get
|
|
||||||
`password authentication failed` even though everything "looks" configured — fix by
|
|
||||||
making `apps/api/.env` match what's actually in the volume (the root `.env` value at
|
|
||||||
the time Postgres first started), not the other way around.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 4. Build the frontend bundle *before* building images
|
|
||||||
|
|
||||||
`apps/web/Dockerfile` only copies a pre-built `dist/` — it does not run the build itself:
|
|
||||||
```bash
|
|
||||||
pnpm --filter web build
|
|
||||||
```
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 5. Bring the stack up
|
|
||||||
|
|
||||||
```bash
|
|
||||||
docker compose up -d --build
|
|
||||||
docker compose ps # all 5 services should show Up/healthy
|
|
||||||
```
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 6. One-time Garage (S3) cluster init
|
|
||||||
|
|
||||||
Garage's image ships only a static binary — no shell — so this can't be scripted as a
|
|
||||||
container entrypoint; it's a manual one-time step:
|
|
||||||
```bash
|
|
||||||
docker compose exec garage /garage node id
|
|
||||||
```
|
|
||||||
Copy the ID (the part **before** the `@host:port`), then:
|
|
||||||
```bash
|
|
||||||
docker compose exec garage /garage layout assign <NODE_ID> -z dc1 -c 100G
|
|
||||||
docker compose exec garage /garage layout apply --version 1
|
|
||||||
docker compose exec garage /garage bucket create <S3_BUCKET>
|
|
||||||
docker compose exec garage /garage key import <S3_ACCESS_KEY> <S3_SECRET_KEY> -n starr-app --yes
|
|
||||||
docker compose exec garage /garage bucket allow <S3_BUCKET> --read --write --owner --key <S3_ACCESS_KEY>
|
|
||||||
```
|
|
||||||
(`S3_BUCKET`/`S3_ACCESS_KEY`/`S3_SECRET_KEY` are whatever you set in `apps/api/.env`.)
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 7. Run database migrations
|
|
||||||
|
|
||||||
```bash
|
|
||||||
docker compose exec backend sequelize-cli db:migrate
|
|
||||||
```
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 8. Verify
|
|
||||||
|
|
||||||
```bash
|
|
||||||
docker compose ps
|
|
||||||
```
|
|
||||||
- Frontend: **http://localhost:4650**
|
|
||||||
- Backend: http://localhost:3024/api
|
|
||||||
|
|
||||||
If both respond, you're done with local testing.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 9. (Optional) Put a real domain + HTTPS in front
|
|
||||||
|
|
||||||
For actually deploying this somewhere reachable, use the `Caddyfile` at the repo root
|
|
||||||
as a template. It's a standalone Caddy install on the host (not part of
|
|
||||||
`docker-compose.yml`) that reverse-proxies 3 domains to the 3 ports already published
|
|
||||||
above (`:4650`, `:3024`, `:3900`) and handles Let's Encrypt certificates automatically.
|
|
||||||
See the comments at the top of `Caddyfile` for exact steps. Not needed for local
|
|
||||||
`localhost:4650` testing — skip this until you're pointing a real domain at the
|
|
||||||
machine.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## Troubleshooting — real errors hit while writing this guide
|
|
||||||
|
|
||||||
| Symptom | Cause | Fix |
|
|
||||||
|---|---|---|
|
|
||||||
| `apt` 404: `.../linux/<distro> <codename> Release` not found | Step 1's install block already auto-detects and falls back — this only happens if you ran the old manual commands, or your codename is newer than every entry in `FALLBACKS` | Re-run Step 1's block as-is, or add your distro's actual latest stable codename to `FALLBACKS` |
|
|
||||||
| `permission denied ... docker.sock` | User not in the `docker` group | `sudo usermod -aG docker $USER && newgrp docker` |
|
|
||||||
| `WARN: "DB_NAME" variable is not set` (and similar) | Root `new_starr/.env` missing | Create it (see step 3) |
|
|
||||||
| `postgres` container stuck `Restarting` | `POSTGRES_PASSWORD` blank (same root `.env` issue) | Same fix as above |
|
|
||||||
| `exec: "/bin/sh": stat /bin/sh: no such file or directory` | Some images (like Garage's) ship no shell at all — never wrap their entrypoint in `/bin/sh` | Use the image's default command; do cluster setup via `docker exec <container> <binary>` directly (no shell needed) |
|
|
||||||
| Garage crash-loops: `rpc_secret value is missing` | `GARAGE_RPC_SECRET` not set in `apps/api/.env` | Set it, then `docker compose up -d --force-recreate garage` |
|
|
||||||
| `password authentication failed for user ...` | `apps/api/.env` and root `.env` DB passwords don't match exactly | Make them match; Postgres only honors whatever was set at first boot |
|
|
||||||
| Fixed a file but the same error keeps happening | Images bake in code at **build** time — there's no live volume mount | `docker compose up -d --build <service>` after any source change |
|
|
||||||
| `ERROR: Unknown constraint error` during migrate | Sequelize hides the real Postgres error behind this generic message | Run the raw SQL directly via `docker compose exec postgres psql -U <user> -d <db>` to see the actual cause |
|
|
||||||
| Migration uses `STRING` as a raw SQL type | CockroachDB alias, not valid in real Postgres | Already fixed in this repo (swapped to `TEXT`, which works on both) |
|
|
||||||
| A service vanishes from `docker compose ps` | A previous `up` was scoped to one service (e.g. `up -d --build backend`), which doesn't touch others | Run a plain `docker compose up -d` (no service name) to restore everything |
|
|
||||||
| Browser: "Unable to connect" | Either the container isn't actually running, or you're browsing from a different machine than the one running Docker | Check `docker compose ps` first; `localhost` only resolves to the machine Docker is on |
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## Notes
|
|
||||||
|
|
||||||
- Frontend is served on **`:4650`**, not `:80` — change `frontend.ports` in
|
|
||||||
`docker-compose.yml` if you want a different port.
|
|
||||||
- Cluster init for Garage is intentionally manual (step 6) — the old automated
|
|
||||||
`garage-init.sh` approach was removed because it depended on a shell that doesn't
|
|
||||||
exist in the Garage image.
|
|
||||||
+53
-12
@@ -1,29 +1,70 @@
|
|||||||
FROM pandoc/typst:latest-alpine AS typst
|
# syntax=docker/dockerfile:1
|
||||||
|
|
||||||
FROM node:22-alpine
|
# ─────────────────────────────────────────────────────────────────────────────
|
||||||
|
# api — production image
|
||||||
# Enable corepack and activate pnpm
|
#
|
||||||
RUN corepack enable && corepack prepare pnpm@11.3.0 --activate
|
# Two stages. `deps` installs production dependencies only, then the final
|
||||||
|
# stage receives just the runtime artifacts. Everything pnpm keeps for
|
||||||
# pm2 manages the process; sequelize-cli runs migrations on startup
|
# itself (content-addressable store, metadata cache, npm cache) stays behind
|
||||||
RUN npm install -g pm2 sequelize-cli
|
# in the build stage, so it never inflates the shipped image.
|
||||||
|
# ─────────────────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
# Typst — compiles certificate.typ into the downloadable PDF certificate.
|
# Typst — compiles certificate.typ into the downloadable PDF certificate.
|
||||||
# Not available as an apk package, so lift the binary out of pandoc/typst.
|
# Not available as an apk package, so lift the binary out of pandoc/typst.
|
||||||
COPY --from=typst /usr/local/bin/typst /usr/local/bin/typst
|
FROM pandoc/typst:latest-alpine AS typst
|
||||||
|
|
||||||
|
# ── Stage 1: dependencies (production only) ──────────────────────────────────
|
||||||
|
FROM node:22-alpine AS deps
|
||||||
|
|
||||||
|
RUN corepack enable && corepack prepare pnpm@11.3.0 --activate
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# Workspace manifests first (cache-friendly), then a filtered install —
|
# Workspace manifests first (cache-friendly), then a filtered install —
|
||||||
# pnpm needs every workspace package's manifest present to resolve the
|
# pnpm needs every workspace package's manifest present to resolve the
|
||||||
# graph even though only apps/api's deps get installed here. pnpm-lock.yaml
|
# graph even though only apps/api's deps get installed here. pnpm-lock.yaml
|
||||||
# is gitignored (not committed), so this resolves fresh on every build
|
# is gitignored (not committed), so this resolves fresh rather than
|
||||||
# rather than installing from a frozen lockfile.
|
# installing from a frozen lockfile.
|
||||||
COPY package.json pnpm-workspace.yaml ./
|
COPY package.json pnpm-workspace.yaml ./
|
||||||
COPY apps/api/package.json ./apps/api/package.json
|
COPY apps/api/package.json ./apps/api/package.json
|
||||||
COPY apps/web/package.json ./apps/web/package.json
|
COPY apps/web/package.json ./apps/web/package.json
|
||||||
RUN pnpm install --filter api...
|
|
||||||
|
|
||||||
|
# --prod skips jest / nodemon / concurrently. The pnpm store is deleted in
|
||||||
|
# the same layer: node_modules entries are hardlinks, so they survive the
|
||||||
|
# delete while ~500 MB of duplicate store files do not.
|
||||||
|
#
|
||||||
|
# ffprobe-static ships ffprobe for darwin/linux/win32 + ia32/x64 (~335 MB).
|
||||||
|
# The runtime image installs the distro ffmpeg instead (see below), which both
|
||||||
|
# services prefer via `which ffprobe`, so only the package stub is kept.
|
||||||
|
RUN pnpm install --filter api... --prod --no-frozen-lockfile \
|
||||||
|
&& rm -rf /root/.local/share/pnpm /root/.cache/pnpm /root/.cache/node /root/.npm \
|
||||||
|
&& rm -rf /app/node_modules/.pnpm/ffprobe-static@*/node_modules/ffprobe-static/bin
|
||||||
|
|
||||||
|
# ── Stage 2: runtime ─────────────────────────────────────────────────────────
|
||||||
|
FROM node:22-alpine
|
||||||
|
|
||||||
|
# sequelize-cli stays available for manual `db:migrate` runs on the droplet;
|
||||||
|
# the npm cache is cleared in the same layer so it never ships.
|
||||||
|
#
|
||||||
|
# ffmpeg brings ffprobe with it and is what the mov/mkv fast-start remux
|
||||||
|
# (services/ffmpeg.service.js) actually needs — ffprobe-static never shipped an
|
||||||
|
# ffmpeg binary. Costs ~100 MB unpacked (libavcodec/x265/aom), still far less
|
||||||
|
# than the 335 MB of removed ffprobe-static binaries.
|
||||||
|
RUN apk add --no-cache ffmpeg \
|
||||||
|
&& npm install -g --no-audit --no-fund sequelize-cli@^6.6.5 \
|
||||||
|
&& npm cache clean --force \
|
||||||
|
&& rm -rf /root/.npm
|
||||||
|
|
||||||
|
COPY --from=typst /usr/local/bin/typst /usr/local/bin/typst
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Symlinks inside pnpm's node_modules are relative, so copying the same
|
||||||
|
# directory layout keeps them resolving correctly.
|
||||||
|
COPY --from=deps /app/node_modules ./node_modules
|
||||||
|
COPY --from=deps /app/apps/api/node_modules ./apps/api/node_modules
|
||||||
|
|
||||||
|
COPY package.json pnpm-workspace.yaml ./
|
||||||
COPY apps/api ./apps/api
|
COPY apps/api ./apps/api
|
||||||
|
|
||||||
WORKDIR /app/apps/api
|
WORKDIR /app/apps/api
|
||||||
|
|||||||
@@ -7,21 +7,22 @@
|
|||||||
* Date Created: Oct. 6, 2025
|
* Date Created: Oct. 6, 2025
|
||||||
***********************************************************************************************************************************************************************
|
***********************************************************************************************************************************************************************
|
||||||
* Change History:
|
* Change History:
|
||||||
* DATE AUTHOR LOG DESCRIPTION
|
* DATE AUTHOR LOG DESCRIPTION
|
||||||
* Oct. 6, 2025 rgrgogu 001 Initial creation - STAR Phase 1
|
* Oct 06,2025 rgrgogu 001 Initial creation - STAR Phase 1
|
||||||
* May 23, 2026 rgrgogu 002 Added group_code to createGroup / updateGroup; added generateGroupCode helper
|
* May 23,2026 rgrgogu 002 Added group_code to createGroup / updateGroup; added generateGroupCode helper
|
||||||
|
* Sept 24,2026 Kenneth Obsequio 003 Limit group_code format for long text.
|
||||||
***********************************************************************************************************************************************************************/
|
***********************************************************************************************************************************************************************/
|
||||||
const sequelize = require('../../config/db.config');
|
const sequelize = require('../../config/db.config');
|
||||||
const { Op, Sequelize } = require('sequelize');
|
const { Op, Sequelize } = require('sequelize');
|
||||||
|
|
||||||
const mdl_Users = require('../../models/users/users.mdl');
|
const mdl_Users = require('../../models/users/users.mdl');
|
||||||
const { mdl_UserGroups, mdl_UserGroupMembers } = require('../../models/users/user_groups.mdl');
|
const { mdl_UserGroups, mdl_UserGroupMembers } = require('../../models/users/user_groups.mdl');
|
||||||
|
|
||||||
const R = require('../../utils/response.util');
|
const R = require('../../utils/response.util');
|
||||||
const { paginate } = require('../../utils/paginate.util');
|
const { paginate } = require('../../utils/paginate.util');
|
||||||
const { getFieldValues } = require('../../utils/fieldValues.util');
|
const { getFieldValues } = require('../../utils/fieldValues.util');
|
||||||
|
|
||||||
const { excludeAttributes: usersExclude, jsonbSchemas: usersSchemas } = require('../../models/users/users.attributes');
|
const { excludeAttributes: usersExclude, jsonbSchemas: usersSchemas } = require('../../models/users/users.attributes');
|
||||||
const { excludeAttributes: groupExclude, jsonbSchemas: groupSchemas, computedAttributes: groupComputed } = require('../../models/users/user_groups.attributes');
|
const { excludeAttributes: groupExclude, jsonbSchemas: groupSchemas, computedAttributes: groupComputed } = require('../../models/users/user_groups.attributes');
|
||||||
const logActivity = require('../../utils/logActivity.util');
|
const logActivity = require('../../utils/logActivity.util');
|
||||||
const { dropDefaultGroupMembership, reconcileDefaultGroup } = require('../../utils/defaultGroup.util');
|
const { dropDefaultGroupMembership, reconcileDefaultGroup } = require('../../utils/defaultGroup.util');
|
||||||
@@ -32,26 +33,60 @@ const { dropDefaultGroupMembership, reconcileDefaultGroup } = require('../../uti
|
|||||||
* e.g. "SALES-A3F1", "ONBOARD-Q1-9C2D"
|
* e.g. "SALES-A3F1", "ONBOARD-Q1-9C2D"
|
||||||
* Retries up to 5 times in the unlikely event of a collision.
|
* Retries up to 5 times in the unlikely event of a collision.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
const LIMITWORDS = new Set(['OF', 'THE', 'AND', 'FOR', 'TO', 'IN', 'A', 'AN']);
|
||||||
|
|
||||||
|
const buildSlugGroupCode = (name, maxLen = 4) => {
|
||||||
|
const words = name
|
||||||
|
.toUpperCase()
|
||||||
|
.trim()
|
||||||
|
.split(/\s+/)
|
||||||
|
.map(w => w.replace(/[^A-Z0-9]/g, ''))
|
||||||
|
.filter(w => w.length > 0 && !LIMITWORDS.has(w));
|
||||||
|
|
||||||
|
if (words.length === 0) return 'GROUP'.slice(0, maxLen); // ensure fallback also respects cap
|
||||||
|
|
||||||
|
// Single word -> just truncate it (e.g. "Sales" -> "SALE")
|
||||||
|
if (words.length === 1) {
|
||||||
|
return words[0].slice(0, maxLen);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Multiple words -> take first letter of each
|
||||||
|
const acronym = words.map(w => w[0]).join('');
|
||||||
|
|
||||||
|
// Guard against 1-letter acronyms (e.g. two 1-word-after-filtering edge cases)
|
||||||
|
return acronym.length >= 2 ? acronym.slice(0, maxLen) : words[0].slice(0, maxLen);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generates a unique group_code in the format: <SLUG>-<4-char hex>
|
||||||
|
* e.g. "GA-F2CA", "SALES-9C2D"
|
||||||
|
* Retries up to 5 times in the unlikely event of a collision.
|
||||||
|
*/
|
||||||
const generateGroupCode = async (name) => {
|
const generateGroupCode = async (name) => {
|
||||||
const slug = name.toUpperCase().trim().replace(/\s+/g, '-').replace(/[^A-Z0-9\-]/g, '').slice(0, 20);
|
const slug = buildSlugGroupCode(name);
|
||||||
|
|
||||||
for (let i = 0; i < 5; i++) {
|
for (let i = 0; i < 5; i++) {
|
||||||
const suffix = Math.random().toString(16).slice(2, 6).toUpperCase();
|
const suffix = Math.random().toString(16).slice(2, 6).toUpperCase();
|
||||||
const code = `${slug}-${suffix}`;
|
const code = `${slug}-${suffix}`;
|
||||||
const exists = await mdl_UserGroups.findOne({ where: { group_code: code }, paranoid: false });
|
const exists = await mdl_UserGroups.findOne({ where: { group_code: code }, paranoid: false });
|
||||||
if (!exists) return code;
|
if (!exists) return code;
|
||||||
}
|
}
|
||||||
throw new Error('Could not generate a unique group code after 5 attempts.');
|
throw new Error('Could not generate a unique group code after 5 attempts.');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// ─── Exports for unit testing ──────────────────────────────────────────────
|
||||||
|
exports.__test__ = { buildSlugGroupCode, generateGroupCode };
|
||||||
|
|
||||||
// ─── GET ALL ──────────────────────────────────────────────────────────────────
|
// ─── GET ALL ──────────────────────────────────────────────────────────────────
|
||||||
exports.getGroups = async (req, res) => {
|
exports.getGroups = async (req, res) => {
|
||||||
try {
|
try {
|
||||||
const result = await paginate(mdl_UserGroups, req, {
|
const result = await paginate(mdl_UserGroups, req, {
|
||||||
excludeAttributes: groupExclude,
|
excludeAttributes: groupExclude,
|
||||||
jsonbSchemas: groupSchemas,
|
jsonbSchemas: groupSchemas,
|
||||||
computedAttributes: groupComputed,
|
computedAttributes: groupComputed,
|
||||||
context: 'list',
|
context: 'list',
|
||||||
auditOptions: { mdl_Users, parentAlias: 'UserGroup' },
|
auditOptions: { mdl_Users, parentAlias: 'UserGroup' },
|
||||||
});
|
});
|
||||||
|
|
||||||
return R.success(res, 'Groups retrieved.', result);
|
return R.success(res, 'Groups retrieved.', result);
|
||||||
@@ -69,16 +104,16 @@ exports.getGroup = async (req, res) => {
|
|||||||
|
|
||||||
const members = await paginate(mdl_Users, req, {
|
const members = await paginate(mdl_Users, req, {
|
||||||
excludeAttributes: usersExclude,
|
excludeAttributes: usersExclude,
|
||||||
jsonbSchemas: usersSchemas,
|
jsonbSchemas: usersSchemas,
|
||||||
jsonbColumn: 'personal_info',
|
jsonbColumn: 'personal_info',
|
||||||
auditOptions: { mdl_Users, parentAlias: 'User' },
|
auditOptions: { mdl_Users, parentAlias: 'User' },
|
||||||
context: 'list',
|
context: 'list',
|
||||||
findOptions: {
|
findOptions: {
|
||||||
include: [{
|
include: [{
|
||||||
model: mdl_UserGroupMembers,
|
model: mdl_UserGroupMembers,
|
||||||
where: { group_id: req.params.gid },
|
where: { group_id: req.params.gid },
|
||||||
attributes: [],
|
attributes: [],
|
||||||
required: true,
|
required: true,
|
||||||
}],
|
}],
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@@ -109,7 +144,7 @@ exports.createGroup = async (req, res) => {
|
|||||||
name,
|
name,
|
||||||
description,
|
description,
|
||||||
group_code: code,
|
group_code: code,
|
||||||
createdBy: req.user.user_id,
|
createdBy: req.user.user_id,
|
||||||
});
|
});
|
||||||
|
|
||||||
logActivity(req.user.user_id, 'create_group', { entityType: 'group', entityId: group.group_id, details: { name: group.name, group_code: group.group_code } });
|
logActivity(req.user.user_id, 'create_group', { entityType: 'group', entityId: group.group_id, details: { name: group.name, group_code: group.group_code } });
|
||||||
@@ -128,11 +163,11 @@ exports.updateGroup = async (req, res) => {
|
|||||||
|
|
||||||
const { name, description, group_code } = req.body;
|
const { name, description, group_code } = req.body;
|
||||||
|
|
||||||
if (name !== undefined) group.name = name;
|
if (name !== undefined) group.name = name;
|
||||||
if (description !== undefined) group.description = description;
|
if (description !== undefined) group.description = description;
|
||||||
|
|
||||||
if (group_code !== undefined) {
|
if (group_code !== undefined) {
|
||||||
const code = group_code.toUpperCase().trim();
|
const code = group_code.toUpperCase().trim();
|
||||||
const duplicate = await mdl_UserGroups.findOne({
|
const duplicate = await mdl_UserGroups.findOne({
|
||||||
where: { group_code: code, group_id: { [Op.ne]: group.group_id } },
|
where: { group_code: code, group_id: { [Op.ne]: group.group_id } },
|
||||||
paranoid: false,
|
paranoid: false,
|
||||||
@@ -156,7 +191,7 @@ exports.updateGroup = async (req, res) => {
|
|||||||
exports.deactivateGroup = async (req, res) => {
|
exports.deactivateGroup = async (req, res) => {
|
||||||
try {
|
try {
|
||||||
const group = await mdl_UserGroups.findByPk(req.params.gid);
|
const group = await mdl_UserGroups.findByPk(req.params.gid);
|
||||||
if (!group) return R.error(res, 'Group not found.', 404);
|
if (!group) return R.error(res, 'Group not found.', 404);
|
||||||
if (!group.is_active) return R.error(res, 'Group is already deactivated.', 400);
|
if (!group.is_active) return R.error(res, 'Group is already deactivated.', 400);
|
||||||
|
|
||||||
await group.update({ is_active: false, updatedBy: req.user.user_id, deletedBy: req.user.user_id });
|
await group.update({ is_active: false, updatedBy: req.user.user_id, deletedBy: req.user.user_id });
|
||||||
@@ -174,7 +209,7 @@ exports.deactivateGroup = async (req, res) => {
|
|||||||
exports.restoreGroup = async (req, res) => {
|
exports.restoreGroup = async (req, res) => {
|
||||||
try {
|
try {
|
||||||
const group = await mdl_UserGroups.findOne({ where: { group_id: req.params.gid }, paranoid: false });
|
const group = await mdl_UserGroups.findOne({ where: { group_id: req.params.gid }, paranoid: false });
|
||||||
if (!group) return R.error(res, 'Group not found.', 404);
|
if (!group) return R.error(res, 'Group not found.', 404);
|
||||||
if (group.is_active) return R.error(res, 'Group is already active.', 400);
|
if (group.is_active) return R.error(res, 'Group is already active.', 400);
|
||||||
|
|
||||||
await group.restore();
|
await group.restore();
|
||||||
@@ -195,7 +230,7 @@ exports.bulkDeactivateGroups = async (req, res) => {
|
|||||||
if (!Array.isArray(ids) || !ids.length)
|
if (!Array.isArray(ids) || !ids.length)
|
||||||
return R.error(res, 'No group IDs provided.', 400);
|
return R.error(res, 'No group IDs provided.', 400);
|
||||||
|
|
||||||
const groups = await mdl_UserGroups.findAll({ where: { group_id: ids } });
|
const groups = await mdl_UserGroups.findAll({ where: { group_id: ids } });
|
||||||
if (!groups.length) return R.error(res, 'No groups found.', 404);
|
if (!groups.length) return R.error(res, 'No groups found.', 404);
|
||||||
|
|
||||||
const activeGroups = groups.filter((g) => g.is_active && !g.deletedAt);
|
const activeGroups = groups.filter((g) => g.is_active && !g.deletedAt);
|
||||||
@@ -213,7 +248,7 @@ exports.bulkDeactivateGroups = async (req, res) => {
|
|||||||
logActivity(req.user.user_id, 'bulk_deactivate_groups', { entityType: 'group', details: { ids: activeIds, count: activeIds.length } });
|
logActivity(req.user.user_id, 'bulk_deactivate_groups', { entityType: 'group', details: { ids: activeIds, count: activeIds.length } });
|
||||||
return R.success(res, `${activeIds.length} group(s) deactivated successfully.`, {
|
return R.success(res, `${activeIds.length} group(s) deactivated successfully.`, {
|
||||||
deactivated_ids: activeIds,
|
deactivated_ids: activeIds,
|
||||||
skipped_ids: ids.filter((id) => !activeIds.includes(id)),
|
skipped_ids: ids.filter((id) => !activeIds.includes(id)),
|
||||||
});
|
});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('[ADMIN][BULK DEACTIVATE GROUPS]', err);
|
console.error('[ADMIN][BULK DEACTIVATE GROUPS]', err);
|
||||||
@@ -228,8 +263,8 @@ exports.bulkRestoreGroups = async (req, res) => {
|
|||||||
if (!Array.isArray(ids) || !ids.length)
|
if (!Array.isArray(ids) || !ids.length)
|
||||||
return R.error(res, 'No group IDs provided.', 400);
|
return R.error(res, 'No group IDs provided.', 400);
|
||||||
|
|
||||||
const groups = await mdl_UserGroups.findAll({ where: { group_id: ids }, paranoid: false });
|
const groups = await mdl_UserGroups.findAll({ where: { group_id: ids }, paranoid: false });
|
||||||
if (!groups.length) return R.error(res, 'No groups found.', 404);
|
if (!groups.length) return R.error(res, 'No groups found.', 404);
|
||||||
|
|
||||||
const deletedGroups = groups.filter((g) => g.deletedAt);
|
const deletedGroups = groups.filter((g) => g.deletedAt);
|
||||||
if (!deletedGroups.length)
|
if (!deletedGroups.length)
|
||||||
@@ -246,7 +281,7 @@ exports.bulkRestoreGroups = async (req, res) => {
|
|||||||
logActivity(req.user.user_id, 'bulk_restore_groups', { entityType: 'group', details: { ids: deletedIds, count: deletedIds.length } });
|
logActivity(req.user.user_id, 'bulk_restore_groups', { entityType: 'group', details: { ids: deletedIds, count: deletedIds.length } });
|
||||||
return R.success(res, `${deletedIds.length} group(s) restored successfully.`, {
|
return R.success(res, `${deletedIds.length} group(s) restored successfully.`, {
|
||||||
restored_ids: deletedIds,
|
restored_ids: deletedIds,
|
||||||
skipped_ids: ids.filter((id) => !deletedIds.includes(id)),
|
skipped_ids: ids.filter((id) => !deletedIds.includes(id)),
|
||||||
});
|
});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('[ADMIN][BULK RESTORE GROUPS]', err);
|
console.error('[ADMIN][BULK RESTORE GROUPS]', err);
|
||||||
@@ -258,7 +293,7 @@ exports.bulkRestoreGroups = async (req, res) => {
|
|||||||
exports.permanentlyDeleteGroup = async (req, res) => {
|
exports.permanentlyDeleteGroup = async (req, res) => {
|
||||||
try {
|
try {
|
||||||
const group = await mdl_UserGroups.findOne({ where: { group_id: req.params.gid }, paranoid: false });
|
const group = await mdl_UserGroups.findOne({ where: { group_id: req.params.gid }, paranoid: false });
|
||||||
if (!group) return R.error(res, 'Group not found.', 404);
|
if (!group) return R.error(res, 'Group not found.', 404);
|
||||||
if (!group.deletedAt) return R.error(res, 'Group must be deactivated before it can be permanently deleted.', 400);
|
if (!group.deletedAt) return R.error(res, 'Group must be deactivated before it can be permanently deleted.', 400);
|
||||||
|
|
||||||
await group.destroy({ force: true });
|
await group.destroy({ force: true });
|
||||||
@@ -278,8 +313,8 @@ exports.bulkPermanentlyDeleteGroups = async (req, res) => {
|
|||||||
if (!Array.isArray(ids) || !ids.length)
|
if (!Array.isArray(ids) || !ids.length)
|
||||||
return R.error(res, 'No group IDs provided.', 400);
|
return R.error(res, 'No group IDs provided.', 400);
|
||||||
|
|
||||||
const groups = await mdl_UserGroups.findAll({ where: { group_id: ids }, paranoid: false });
|
const groups = await mdl_UserGroups.findAll({ where: { group_id: ids }, paranoid: false });
|
||||||
if (!groups.length) return R.error(res, 'No groups found.', 404);
|
if (!groups.length) return R.error(res, 'No groups found.', 404);
|
||||||
|
|
||||||
const deletedGroups = groups.filter((g) => g.deletedAt);
|
const deletedGroups = groups.filter((g) => g.deletedAt);
|
||||||
if (!deletedGroups.length)
|
if (!deletedGroups.length)
|
||||||
@@ -304,14 +339,14 @@ exports.bulkPermanentlyDeleteGroups = async (req, res) => {
|
|||||||
exports.getArchivedGroups = async (req, res) => {
|
exports.getArchivedGroups = async (req, res) => {
|
||||||
try {
|
try {
|
||||||
const result = await paginate(mdl_UserGroups, req, {
|
const result = await paginate(mdl_UserGroups, req, {
|
||||||
excludeAttributes: groupExclude,
|
excludeAttributes: groupExclude,
|
||||||
jsonbSchemas: groupSchemas,
|
jsonbSchemas: groupSchemas,
|
||||||
computedAttributes: groupComputed,
|
computedAttributes: groupComputed,
|
||||||
context: 'archived',
|
context: 'archived',
|
||||||
auditOptions: { mdl_Users, parentAlias: 'UserGroup' },
|
auditOptions: { mdl_Users, parentAlias: 'UserGroup' },
|
||||||
findOptions: {
|
findOptions: {
|
||||||
paranoid: false,
|
paranoid: false,
|
||||||
where: { deletedAt: { [Op.ne]: null }, is_active: false },
|
where: { deletedAt: { [Op.ne]: null }, is_active: false },
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -325,7 +360,7 @@ exports.getArchivedGroups = async (req, res) => {
|
|||||||
// ─── FIELD VALUES ─────────────────────────────────────────────────────────────
|
// ─── FIELD VALUES ─────────────────────────────────────────────────────────────
|
||||||
exports.getGroupFieldValues = getFieldValues(mdl_UserGroups, 'GROUP', {
|
exports.getGroupFieldValues = getFieldValues(mdl_UserGroups, 'GROUP', {
|
||||||
blockedFields: ['deletedAt'],
|
blockedFields: ['deletedAt'],
|
||||||
paranoid: false,
|
paranoid: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
// ─── MEMBERSHIP ───────────────────────────────────────────────────────────────
|
// ─── MEMBERSHIP ───────────────────────────────────────────────────────────────
|
||||||
@@ -334,12 +369,12 @@ exports.getUsersNotInGroup = async (req, res) => {
|
|||||||
const { gid: group_id } = req.params;
|
const { gid: group_id } = req.params;
|
||||||
|
|
||||||
// Exclude users already in THIS group
|
// Exclude users already in THIS group
|
||||||
const members = await mdl_UserGroupMembers.findAll({ where: { group_id }, attributes: ['user_id'] });
|
const members = await mdl_UserGroupMembers.findAll({ where: { group_id }, attributes: ['user_id'] });
|
||||||
const memberIds = members.map((m) => m.user_id);
|
const memberIds = members.map((m) => m.user_id);
|
||||||
|
|
||||||
const users = await mdl_Users.findAll({
|
const users = await mdl_Users.findAll({
|
||||||
where: {
|
where: {
|
||||||
user_id: { [Op.notIn]: memberIds.length ? memberIds : [0] },
|
user_id: { [Op.notIn]: memberIds.length ? memberIds : [0] },
|
||||||
acc_type: 'user', // exclude staff/admin — only regular users can be added to a group
|
acc_type: 'user', // exclude staff/admin — only regular users can be added to a group
|
||||||
},
|
},
|
||||||
attributes: [
|
attributes: [
|
||||||
@@ -374,9 +409,9 @@ exports.getUsersInGroup = async (req, res) => {
|
|||||||
|
|
||||||
const group = await mdl_UserGroups.findByPk(group_id, {
|
const group = await mdl_UserGroups.findByPk(group_id, {
|
||||||
include: [{
|
include: [{
|
||||||
model: mdl_Users,
|
model: mdl_Users,
|
||||||
as: 'members',
|
as: 'members',
|
||||||
through: { attributes: [] },
|
through: { attributes: [] },
|
||||||
attributes: [
|
attributes: [
|
||||||
'user_id',
|
'user_id',
|
||||||
[Sequelize.literal(`("members"."personal_info"->'name'->>'full_name')`), 'full_name'],
|
[Sequelize.literal(`("members"."personal_info"->'name'->>'full_name')`), 'full_name'],
|
||||||
@@ -395,14 +430,14 @@ exports.getUsersInGroup = async (req, res) => {
|
|||||||
exports.addUserToGroup = async (req, res) => {
|
exports.addUserToGroup = async (req, res) => {
|
||||||
try {
|
try {
|
||||||
const { gid: group_id } = req.params;
|
const { gid: group_id } = req.params;
|
||||||
const { user_ids } = req.body;
|
const { user_ids } = req.body;
|
||||||
|
|
||||||
if (!Array.isArray(user_ids) || !user_ids.length)
|
if (!Array.isArray(user_ids) || !user_ids.length)
|
||||||
return R.error(res, 'No users provided.', 400);
|
return R.error(res, 'No users provided.', 400);
|
||||||
|
|
||||||
const existingUsers = await mdl_Users.findAll({ where: { user_id: user_ids }, attributes: ['user_id'] });
|
const existingUsers = await mdl_Users.findAll({ where: { user_id: user_ids }, attributes: ['user_id'] });
|
||||||
const existingIds = existingUsers.map((u) => u.user_id);
|
const existingIds = existingUsers.map((u) => u.user_id);
|
||||||
const notFound = user_ids.filter((id) => !existingIds.includes(id));
|
const notFound = user_ids.filter((id) => !existingIds.includes(id));
|
||||||
|
|
||||||
if (notFound.length)
|
if (notFound.length)
|
||||||
return R.error(res, `Users not found: ${notFound.join(', ')}`, 404);
|
return R.error(res, `Users not found: ${notFound.join(', ')}`, 404);
|
||||||
@@ -430,7 +465,7 @@ exports.addUserToGroup = async (req, res) => {
|
|||||||
exports.removeUserFromGroup = async (req, res) => {
|
exports.removeUserFromGroup = async (req, res) => {
|
||||||
try {
|
try {
|
||||||
const { gid: group_id } = req.params;
|
const { gid: group_id } = req.params;
|
||||||
const { user_ids } = req.body;
|
const { user_ids } = req.body;
|
||||||
|
|
||||||
if (!Array.isArray(user_ids) || !user_ids.length)
|
if (!Array.isArray(user_ids) || !user_ids.length)
|
||||||
return R.error(res, 'No users provided.', 400);
|
return R.error(res, 'No users provided.', 400);
|
||||||
@@ -439,7 +474,7 @@ exports.removeUserFromGroup = async (req, res) => {
|
|||||||
where: { user_id: user_ids, group_id }, attributes: ['user_id'],
|
where: { user_id: user_ids, group_id }, attributes: ['user_id'],
|
||||||
});
|
});
|
||||||
const existingIds = existingMembers.map((m) => m.user_id);
|
const existingIds = existingMembers.map((m) => m.user_id);
|
||||||
const notFound = user_ids.filter((id) => !existingIds.includes(id));
|
const notFound = user_ids.filter((id) => !existingIds.includes(id));
|
||||||
|
|
||||||
if (notFound.length)
|
if (notFound.length)
|
||||||
return R.error(res, `Memberships not found for users: ${notFound.join(', ')}`, 404);
|
return R.error(res, `Memberships not found for users: ${notFound.join(', ')}`, 404);
|
||||||
|
|||||||
@@ -1,4 +1,7 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
exec pm2-runtime start server.js --name "${APP_NAME:-app}"
|
# Docker's `restart: unless-stopped` policy handles crash recovery, so the
|
||||||
|
# process supervisor (pm2) is not shipped — it costs image size and ~40 MB RSS
|
||||||
|
# on a 2 GB droplet. node runs as PID 1 and receives SIGTERM directly.
|
||||||
|
exec node server.js
|
||||||
|
|||||||
+26
-26
@@ -15,43 +15,43 @@
|
|||||||
"db:seed:undo": "sequelize-cli db:seed:undo:all"
|
"db:seed:undo": "sequelize-cli db:seed:undo:all"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@aws-sdk/client-s3": "^3.1068.0",
|
"@aws-sdk/client-s3": "^3.1157.0",
|
||||||
"@aws-sdk/lib-storage": "^3.1085.0",
|
"@aws-sdk/lib-storage": "^3.1157.0",
|
||||||
"@aws-sdk/s3-request-presigner": "^3.1068.0",
|
"@aws-sdk/s3-request-presigner": "^3.1157.0",
|
||||||
"axios": "^1.16.0",
|
"axios": "^1.21.0",
|
||||||
"bcryptjs": "^2.4.3",
|
"bcryptjs": "^2.4.3",
|
||||||
"connect-pg-simple": "^10.0.0",
|
"connect-pg-simple": "^10.0.0",
|
||||||
"cookie-parser": "^1.4.6",
|
"cookie-parser": "^1.4.7",
|
||||||
"cors": "^2.8.5",
|
"cors": "^2.8.6",
|
||||||
"csurf": "^1.11.0",
|
"csurf": "^1.11.0",
|
||||||
"currency-codes": "^2.2.0",
|
"currency-codes": "^2.2.0",
|
||||||
"dotenv": "^16.0.3",
|
"dotenv": "^16.6.1",
|
||||||
"express": "^4.18.2",
|
"express": "^4.22.3",
|
||||||
"express-rate-limit": "^6.10.0",
|
"express-rate-limit": "^6.11.2",
|
||||||
"express-session": "^1.17.3",
|
"express-session": "^1.19.0",
|
||||||
"express-validator": "^7.0.1",
|
"express-validator": "^7.3.2",
|
||||||
"ffprobe-static": "^3.1.0",
|
"ffprobe-static": "^3.1.0",
|
||||||
"fluent-ffmpeg": "^2.1.3",
|
"fluent-ffmpeg": "^2.1.3",
|
||||||
"form-data": "^4.0.5",
|
"form-data": "^4.0.6",
|
||||||
"google-auth-library": "^9.0.0",
|
"google-auth-library": "^9.15.1",
|
||||||
"http-proxy-middleware": "^4.0.0",
|
"http-proxy-middleware": "^4.2.1",
|
||||||
"jsonwebtoken": "^9.0.1",
|
"jsonwebtoken": "^9.0.3",
|
||||||
"multer": "^2.1.1",
|
"multer": "^2.5.0",
|
||||||
"node-cron": "^4.2.1",
|
"node-cron": "^4.6.0",
|
||||||
"nodemailer": "^6.9.5",
|
"nodemailer": "^6.10.1",
|
||||||
"path": "^0.12.7",
|
"path": "^0.12.7",
|
||||||
"pg": "^8.11.3",
|
"pg": "^8.23.1",
|
||||||
"pg-hstore": "^2.3.4",
|
"pg-hstore": "^2.3.4",
|
||||||
"rate-limit-redis": "^4.0.0",
|
"rate-limit-redis": "^4.3.1",
|
||||||
"redis": "^4.6.7",
|
"redis": "^4.7.1",
|
||||||
"sequelize": "^6.32.1",
|
"sequelize": "^6.37.8",
|
||||||
"sharp": "^0.35.3",
|
"sharp": "^0.35.5",
|
||||||
"ua-parser-js": "^2.0.10",
|
"ua-parser-js": "^2.0.10",
|
||||||
"uuid": "^9.0.0"
|
"uuid": "^9.0.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"jest": "^30.4.2",
|
"jest": "^30.5.2",
|
||||||
"nodemon": "^3.0.1",
|
"nodemon": "^3.1.14",
|
||||||
"sequelize-cli": "^6.6.5"
|
"sequelize-cli": "^6.6.5"
|
||||||
},
|
},
|
||||||
"jest": {
|
"jest": {
|
||||||
|
|||||||
@@ -0,0 +1,100 @@
|
|||||||
|
// tests/controllers/user_groups.controller.test.js
|
||||||
|
|
||||||
|
jest.mock('../../models/users/user_groups.mdl', () => ({
|
||||||
|
mdl_UserGroups: { findOne: jest.fn() },
|
||||||
|
mdl_UserGroupMembers: {},
|
||||||
|
}));
|
||||||
|
|
||||||
|
const { mdl_UserGroups } = require('../../models/users/user_groups.mdl');
|
||||||
|
const { __test__ } = require('../../controllers/admin/user_groups.controller');
|
||||||
|
const { buildSlugGroupCode, generateGroupCode } = __test__;
|
||||||
|
|
||||||
|
describe('buildSlugGroupCode', () => {
|
||||||
|
test('multi-word name -> acronym from first letters', () => {
|
||||||
|
const result = buildSlugGroupCode('Group of Auditors');
|
||||||
|
expect(result).toBe('GA');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('filters out stopwords before building acronym', () => {
|
||||||
|
const result = buildSlugGroupCode('The Sales and Marketing Team');
|
||||||
|
expect(result).toBe('SMT');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('single word -> truncated as-is', () => {
|
||||||
|
const result = buildSlugGroupCode('Sales');
|
||||||
|
expect(result).toBe('SALE');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('respects maxLen', () => {
|
||||||
|
const result = buildSlugGroupCode('Internal Audit Team Extended', 3);
|
||||||
|
expect(result).toBe('IAT');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('strips non-alphanumeric characters per word', () => {
|
||||||
|
const result = buildSlugGroupCode('R&D Ops');
|
||||||
|
expect(result).toBe('RO');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('falls back to GROUP when name is only stopwords/empty after filtering', () => {
|
||||||
|
const result = buildSlugGroupCode('The Of And');
|
||||||
|
expect(result).toBe('GROU');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('falls back to first word when acronym would be 1 letter', () => {
|
||||||
|
const result = buildSlugGroupCode('A Ops');
|
||||||
|
expect(result).toBe('OPS');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('is case-insensitive on input', () => {
|
||||||
|
const result = buildSlugGroupCode('group of auditors');
|
||||||
|
expect(result).toBe('GA');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('generateGroupCode', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
mdl_UserGroups.findOne.mockReset();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('returns SLUG-XXXX when code is unique on first try', async () => {
|
||||||
|
mdl_UserGroups.findOne.mockResolvedValueOnce(null);
|
||||||
|
|
||||||
|
const code = await generateGroupCode('Group of Auditors');
|
||||||
|
console.log(`[TEST][GROUP CODE] Generated unique code: "${code}" (1 attempt)`);
|
||||||
|
|
||||||
|
expect(code).toMatch(/^GA-[0-9A-F]{4}$/);
|
||||||
|
expect(mdl_UserGroups.findOne).toHaveBeenCalledTimes(1);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('retries on collision until a unique code is found', async () => {
|
||||||
|
mdl_UserGroups.findOne
|
||||||
|
.mockResolvedValueOnce({ group_code: 'GA-AAAA' })
|
||||||
|
.mockResolvedValueOnce({ group_code: 'GA-BBBB' })
|
||||||
|
.mockResolvedValueOnce(null);
|
||||||
|
|
||||||
|
const code = await generateGroupCode('Group of Auditors');
|
||||||
|
|
||||||
|
expect(code).toMatch(/^GA-[0-9A-F]{4}$/);
|
||||||
|
expect(mdl_UserGroups.findOne).toHaveBeenCalledTimes(3);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('throws after 5 failed attempts', async () => {
|
||||||
|
mdl_UserGroups.findOne.mockResolvedValue({ group_code: 'GA-AAAA' });
|
||||||
|
|
||||||
|
await expect(generateGroupCode('Group of Auditors')).rejects.toThrow(
|
||||||
|
'Could not generate a unique group code after 5 attempts.'
|
||||||
|
);
|
||||||
|
expect(mdl_UserGroups.findOne).toHaveBeenCalledTimes(5);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('generated code stays within max slug length', async () => {
|
||||||
|
mdl_UserGroups.findOne.mockResolvedValueOnce(null);
|
||||||
|
|
||||||
|
const code = await generateGroupCode('Internal Audit Team For The Whole Organization Wide');
|
||||||
|
const [slug] = code.split('-');
|
||||||
|
console.log(`[TEST][GROUP CODE] Long name -> "${code}" (slug length: ${slug.length})`);
|
||||||
|
|
||||||
|
expect(slug.length).toBeLessThanOrEqual(4); // 4, not 8
|
||||||
|
expect(code.length).toBeLessThanOrEqual(9); // total: XXXX-XXXX
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -131,8 +131,8 @@ describe('createOrder()', () => {
|
|||||||
await provider.createOrder({ amount: 5, referenceId: 'ref-1' });
|
await provider.createOrder({ amount: 5, referenceId: 'ref-1' });
|
||||||
|
|
||||||
const [, body] = axios.post.mock.calls[1];
|
const [, body] = axios.post.mock.calls[1];
|
||||||
expect(body.application_context.return_url).toBe('https://app.new-starr.test/plans/checkout');
|
expect(body.application_context.return_url).toBe('https://app.new-starr.test/subscriptions/checkout');
|
||||||
expect(body.application_context.cancel_url).toBe('https://app.new-starr.test/plans/checkout?cancelled=true');
|
expect(body.application_context.cancel_url).toBe('https://app.new-starr.test/subscriptions/checkout?cancelled=true');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('honors explicit return/cancel urls when provided', async () => {
|
test('honors explicit return/cancel urls when provided', async () => {
|
||||||
|
|||||||
@@ -1,34 +0,0 @@
|
|||||||
const { Course } = require('../../api/models/courses/courses.mdl');
|
|
||||||
const Unit = require('../../api/models/courses/units.mdl');
|
|
||||||
const Lesson = require('../../api/models/courses/lessons.mdl');
|
|
||||||
const { TaskList, Task } = require('../../api/models/task/task.mdl');
|
|
||||||
const Advertisement = require('../../api/models/advertisements/advertisements.mdl');
|
|
||||||
const TierPlan = require('../../api/models/tiers/tier_plans.mdl');
|
|
||||||
const { Op } = require('sequelize');
|
|
||||||
|
|
||||||
const QA_PREFIX = '[QA-TEST';
|
|
||||||
|
|
||||||
const TARGETS = [
|
|
||||||
{ model: Task, column: 'name' },
|
|
||||||
{ model: TaskList, column: 'name' },
|
|
||||||
{ model: Advertisement, column: 'headline' },
|
|
||||||
{ model: Unit, column: 'title' },
|
|
||||||
{ model: Lesson, column: 'title' },
|
|
||||||
{ model: Course, column: 'title' },
|
|
||||||
{ model: TierPlan, column: 'label' },
|
|
||||||
];
|
|
||||||
|
|
||||||
/** Hard-deletes every QA-TEST-prefixed fixture row across all modules this suite touches. */
|
|
||||||
async function cleanupQaTestFixtures() {
|
|
||||||
const removed = {};
|
|
||||||
for (const { model, column } of TARGETS) {
|
|
||||||
const count = await model.destroy({
|
|
||||||
where: { [column]: { [Op.like]: `${QA_PREFIX}%` } },
|
|
||||||
force: true, // hard delete, not just paranoid soft-delete — mirrors the manual "archive then permanently delete" cleanup flow
|
|
||||||
});
|
|
||||||
if (count) removed[model.name] = count;
|
|
||||||
}
|
|
||||||
return removed;
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = { cleanupQaTestFixtures, QA_PREFIX };
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
// Reuses the app's own Sequelize connection/config instead of duplicating
|
|
||||||
// DB_HOST/DB_PORT/... wiring — env.js pre-loads apps/api/.env so db.config.js
|
|
||||||
// picks up the real dev credentials when it runs its own (no-op, already-set)
|
|
||||||
// dotenv.config() call.
|
|
||||||
require('./env');
|
|
||||||
const sequelize = require('../../api/config/db.config');
|
|
||||||
const Users = require('../../api/models/users/users.mdl');
|
|
||||||
|
|
||||||
async function getUserIdByEmail(email) {
|
|
||||||
const user = await Users.findOne({ where: { email }, attributes: ['user_id'] });
|
|
||||||
if (!user) throw new Error(`No user found for email ${email} — check the dev DB seed / helpers/env.js USERS config.`);
|
|
||||||
return String(user.user_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
async function getPendingOtp(user_id) {
|
|
||||||
const rows = await sequelize.query(
|
|
||||||
`SELECT otp_code FROM users WHERE user_id = :uid`,
|
|
||||||
{ replacements: { uid: user_id }, type: sequelize.QueryTypes.SELECT },
|
|
||||||
);
|
|
||||||
return rows[0]?.otp_code ?? null;
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = { sequelize, getUserIdByEmail, getPendingOtp };
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
// Loads real dev secrets from apps/api/.env (gitignored — never committed).
|
|
||||||
// Falls back to apps/api/.env-development (git-tracked shared dev creds) for
|
|
||||||
// anything .env doesn't override, matching how apps/api itself resolves config.
|
|
||||||
const path = require('path');
|
|
||||||
require('dotenv').config({ path: path.join(__dirname, '../../api/.env') });
|
|
||||||
require('dotenv').config({ path: path.join(__dirname, '../../api/.env-development') });
|
|
||||||
|
|
||||||
const APP_URL = process.env.E2E_APP_URL || 'http://localhost:5173';
|
|
||||||
const API_URL = process.env.E2E_API_URL || 'http://localhost:3024/api';
|
|
||||||
|
|
||||||
const JWT_REFRESH_SECRET = process.env.JWT_REFRESH_SECRET;
|
|
||||||
if (!JWT_REFRESH_SECRET || JWT_REFRESH_SECRET.startsWith('CHANGE_ME')) {
|
|
||||||
throw new Error('JWT_REFRESH_SECRET missing/placeholder — check apps/api/.env has real dev secrets.');
|
|
||||||
}
|
|
||||||
|
|
||||||
// Known test accounts. user_id is intentionally NOT hardcoded here — these
|
|
||||||
// accounts get recreated over time (see chibistar/automation/starr/config.cjs
|
|
||||||
// history) which silently breaks hardcoded ids. helpers/session.js looks the
|
|
||||||
// id up by email at call time instead.
|
|
||||||
const USERS = {
|
|
||||||
admin: {
|
|
||||||
email: process.env.E2E_ADMIN_EMAIL || 'k80308392@gmail.com',
|
|
||||||
password: process.env.E2E_ADMIN_PASSWORD || 'Test123@',
|
|
||||||
acc_type: 'admin',
|
|
||||||
},
|
|
||||||
seedClient: {
|
|
||||||
// Synthetic, no real owner — safe default for read-only/client-facing checks.
|
|
||||||
email: process.env.E2E_SEED_CLIENT_EMAIL || 'veronica.castro@example.com',
|
|
||||||
acc_type: 'user',
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
module.exports = { APP_URL, API_URL, JWT_REFRESH_SECRET, USERS };
|
|
||||||
@@ -1,55 +0,0 @@
|
|||||||
const jwt = require('jsonwebtoken');
|
|
||||||
const crypto = require('crypto');
|
|
||||||
const { APP_URL, JWT_REFRESH_SECRET, USERS } = require('./env');
|
|
||||||
const { sequelize, getUserIdByEmail, getPendingOtp } = require('./db');
|
|
||||||
|
|
||||||
/** Build the cookie jar for context.addCookies() from a refresh token. */
|
|
||||||
function buildCookies(refreshToken, csrfToken = 'e2e-csrf') {
|
|
||||||
return [
|
|
||||||
{ name: 'refreshToken', value: refreshToken, domain: 'localhost', path: '/', httpOnly: true, secure: false, sameSite: 'Lax' },
|
|
||||||
{ name: 'csrfToken', value: csrfToken, domain: 'localhost', path: '/', httpOnly: false, secure: false, sameSite: 'Lax' },
|
|
||||||
{ name: 'sidebar_state', value: 'false', domain: 'localhost', path: '/', httpOnly: false, secure: false, sameSite: 'Lax' },
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Generate a fresh refresh token + DB session row for a client user, keyed
|
|
||||||
* by email (not a hardcoded user_id — those drift as test accounts get
|
|
||||||
* recreated, see chibistar/automation/starr/config.cjs history).
|
|
||||||
*/
|
|
||||||
async function generateClientSession(email) {
|
|
||||||
const user_id = await getUserIdByEmail(email);
|
|
||||||
const refreshToken = jwt.sign({ user_id }, JWT_REFRESH_SECRET, { expiresIn: '7d' });
|
|
||||||
const tokenHash = crypto.createHash('sha256').update(refreshToken).digest('hex');
|
|
||||||
|
|
||||||
await sequelize.query(
|
|
||||||
`INSERT INTO user_sessions (user_id, refresh_token_hash, is_active, login_info, "createdAt", "updatedAt")
|
|
||||||
VALUES (:uid, :hash, true, '{}', NOW(), NOW())`,
|
|
||||||
{ replacements: { uid: user_id, hash: tokenHash }, type: sequelize.QueryTypes.INSERT },
|
|
||||||
);
|
|
||||||
|
|
||||||
return { user_id, refreshToken };
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Authenticate as admin via cookie injection (same mechanism as
|
|
||||||
* generateClientSession), not the UI login form.
|
|
||||||
*
|
|
||||||
* REAL FINDING (2026-08-25): the admin account (k80308392@gmail.com) is
|
|
||||||
* Google-OAuth-only now — submitting the UI email/password form returns
|
|
||||||
* "Login failed — Please log in with Google." This matches a prior finding
|
|
||||||
* that the *live*-domain admin session had gone Google-only, but it turns
|
|
||||||
* out to be true here against localhost too, so the email+password+OTP flow
|
|
||||||
* this helper originally ported from chibistar/automation/starr/config.cjs
|
|
||||||
* (loginAsAdmin) is dead — forging the session cookie is the only way in now.
|
|
||||||
*/
|
|
||||||
async function loginAsAdmin(page) {
|
|
||||||
const { refreshToken } = await generateClientSession(USERS.admin.email);
|
|
||||||
await page.context().addCookies(buildCookies(refreshToken));
|
|
||||||
await page.goto(`${APP_URL}/admin`, { waitUntil: 'networkidle' });
|
|
||||||
if (/\/login/.test(page.url())) {
|
|
||||||
throw new Error('Cookie-based admin auth bounced to /login — check JWT_REFRESH_SECRET / user_sessions wiring.');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = { buildCookies, generateClientSession, loginAsAdmin };
|
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
const { execSync } = require('child_process');
|
|
||||||
|
|
||||||
// Real monitor resolution instead of a hardcoded viewport — this suite runs
|
|
||||||
// on whatever box the self-hosted runner/dev machine happens to be (varies:
|
|
||||||
// 1366x768, 1920x1080, ...). Memoized per process.
|
|
||||||
let _cachedViewport = null;
|
|
||||||
|
|
||||||
function detectViewport() {
|
|
||||||
if (_cachedViewport) return _cachedViewport;
|
|
||||||
const FALLBACK = { width: 1366, height: 768 };
|
|
||||||
let detected = null;
|
|
||||||
try {
|
|
||||||
if (process.platform === 'linux') {
|
|
||||||
const out = execSync('xrandr --current 2>/dev/null', { encoding: 'utf8' });
|
|
||||||
const m = out.match(/(\d+)x(\d+)\s+[\d.]+\*/);
|
|
||||||
if (m) detected = { width: Number(m[1]), height: Number(m[2]) };
|
|
||||||
} else if (process.platform === 'win32') {
|
|
||||||
const out = execSync(
|
|
||||||
'powershell -NoProfile -Command "Add-Type -AssemblyName System.Windows.Forms; ' +
|
|
||||||
'$b = [System.Windows.Forms.Screen]::PrimaryScreen.Bounds; Write-Output \\"$($b.Width)x$($b.Height)\\""',
|
|
||||||
{ encoding: 'utf8', windowsHide: true },
|
|
||||||
).trim();
|
|
||||||
const m = out.match(/(\d+)x(\d+)/);
|
|
||||||
if (m) detected = { width: Number(m[1]), height: Number(m[2]) };
|
|
||||||
} else if (process.platform === 'darwin') {
|
|
||||||
const out = execSync('system_profiler SPDisplaysDataType 2>/dev/null', { encoding: 'utf8' });
|
|
||||||
const m = out.match(/Resolution:\s*(\d+)\s*x\s*(\d+)/);
|
|
||||||
if (m) detected = { width: Number(m[1]), height: Number(m[2]) };
|
|
||||||
}
|
|
||||||
} catch {
|
|
||||||
// No xrandr on a headless CI box, PowerShell blocked, etc. — fall back.
|
|
||||||
}
|
|
||||||
_cachedViewport = detected ?? FALLBACK;
|
|
||||||
return _cachedViewport;
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = { detectViewport };
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "e2e",
|
|
||||||
"private": true,
|
|
||||||
"scripts": {
|
|
||||||
"test": "playwright test"
|
|
||||||
},
|
|
||||||
"devDependencies": {
|
|
||||||
"@playwright/test": "^1.48.0",
|
|
||||||
"dotenv": "^16.4.5",
|
|
||||||
"jsonwebtoken": "^9.0.3",
|
|
||||||
"pg": "^8.11.3",
|
|
||||||
"pg-hstore": "^2.3.4",
|
|
||||||
"sequelize": "^6.37.8"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
const { defineConfig, devices } = require('@playwright/test');
|
|
||||||
|
|
||||||
module.exports = defineConfig({
|
|
||||||
testDir: './tests',
|
|
||||||
fullyParallel: false, // specs share/mutate DB fixtures tagged by module — keep runs serial to avoid cross-spec QA-TEST collisions
|
|
||||||
workers: 1,
|
|
||||||
retries: process.env.CI ? 1 : 0,
|
|
||||||
reporter: [['html', { open: 'never' }], ['list']],
|
|
||||||
timeout: 120_000,
|
|
||||||
use: {
|
|
||||||
baseURL: 'http://localhost:5173',
|
|
||||||
trace: 'retain-on-failure',
|
|
||||||
screenshot: 'only-on-failure',
|
|
||||||
video: 'retain-on-failure',
|
|
||||||
},
|
|
||||||
projects: [
|
|
||||||
{ name: 'firefox', use: { ...devices['Desktop Firefox'] } },
|
|
||||||
],
|
|
||||||
webServer: {
|
|
||||||
command: 'pnpm --dir ../.. dev',
|
|
||||||
url: 'http://localhost:5173',
|
|
||||||
reuseExistingServer: !process.env.CI,
|
|
||||||
timeout: 120_000,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
Not converted in this pass. Source doc: `~/Downloads/Client_Achievements_and_Certificates_Test_Case_Documentation.txt`.
|
|
||||||
`test-cert-dialog.cjs` exists in chibistar/automation/starr and covers part of this — worth starting from there.
|
|
||||||
@@ -1,166 +0,0 @@
|
|||||||
// Ported from chibistar/automation/starr/test-advertisements-doc.cjs — see
|
|
||||||
// ~/Downloads/ADMIN_Advertisements_Test_Case_Documentation.txt.
|
|
||||||
//
|
|
||||||
// Not ported here (dropped, not silently): TC-ADV-013/014/015/016/017/018
|
|
||||||
// (archived-table sort/filter/refresh/export/columns — generic DataTable
|
|
||||||
// behavior already covered structurally by the Courses admin spec's
|
|
||||||
// equivalent checks) and test-client-advertisements-live.cjs /
|
|
||||||
// test-ad-image-select.cjs, both hardcoded against specific live-site rows
|
|
||||||
// (a real advertisement_id, a real course_id, user_id 132's live DB state)
|
|
||||||
// that don't exist on a fresh local dev DB and can't be faithfully
|
|
||||||
// recreated without fabricating the exact scenario they were checking.
|
|
||||||
const { test, expect } = require('@playwright/test');
|
|
||||||
const { APP_URL, USERS } = require('../../helpers/env');
|
|
||||||
const { generateClientSession, buildCookies } = require('../../helpers/session');
|
|
||||||
const { cleanupQaTestFixtures } = require('../../helpers/cleanup');
|
|
||||||
|
|
||||||
async function settle(page, ms = 1200) {
|
|
||||||
await page.waitForLoadState('networkidle').catch(() => {});
|
|
||||||
await page.waitForTimeout(ms);
|
|
||||||
}
|
|
||||||
|
|
||||||
const TS = Date.now().toString().slice(-6);
|
|
||||||
const QA_HEADLINE = `[QA-TEST] Advertisements Doc Pass ${TS}`;
|
|
||||||
const QA_HEADLINE_EDITED = `${QA_HEADLINE} (edited)`;
|
|
||||||
|
|
||||||
test.describe.serial('Advertisements (admin)', () => {
|
|
||||||
test.setTimeout(120_000);
|
|
||||||
|
|
||||||
let adminCookies;
|
|
||||||
|
|
||||||
test.beforeAll(async () => {
|
|
||||||
test.setTimeout(60_000);
|
|
||||||
const { refreshToken } = await generateClientSession(USERS.admin.email);
|
|
||||||
adminCookies = buildCookies(refreshToken);
|
|
||||||
});
|
|
||||||
|
|
||||||
test.afterAll(async () => {
|
|
||||||
const removed = await cleanupQaTestFixtures();
|
|
||||||
console.log('QA-TEST fixtures removed:', removed);
|
|
||||||
});
|
|
||||||
|
|
||||||
test.beforeEach(async ({ page }) => {
|
|
||||||
await page.context().addCookies(adminCookies);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('TC-ADV-006/007/008: New Advertisement wizard blocks missing placement, happy-path create as Draft', async ({ page }) => {
|
|
||||||
await page.goto(`${APP_URL}/admin/advertisements/add`, { waitUntil: 'networkidle' });
|
|
||||||
await settle(page, 1000);
|
|
||||||
await expect(page.getByText('Choose where this ad appears')).toBeVisible();
|
|
||||||
|
|
||||||
// TC-ADV-007: missing placement blocks Next
|
|
||||||
await page.getByRole('button', { name: 'Next' }).click();
|
|
||||||
await page.waitForTimeout(1200);
|
|
||||||
await expect(page.getByText('Choose where this ad appears')).toBeVisible();
|
|
||||||
|
|
||||||
// TC-ADV-008: happy path
|
|
||||||
await page.locator('button').filter({ hasText: 'Select a placement' }).click();
|
|
||||||
await page.getByRole('option', { name: /Tier Plans/ }).click();
|
|
||||||
await page.waitForTimeout(400);
|
|
||||||
await page.getByRole('button', { name: 'Next' }).click();
|
|
||||||
await page.waitForTimeout(400);
|
|
||||||
|
|
||||||
await page.getByText('Content + image', { exact: false }).click();
|
|
||||||
await page.getByPlaceholder('e.g. Advertisement').fill('QA-TEST Badge');
|
|
||||||
await page.getByPlaceholder(/Discover the World/).fill(QA_HEADLINE);
|
|
||||||
await page.getByPlaceholder('Supporting text under the headline').fill('QA-TEST description for the Advertisements doc pass.');
|
|
||||||
await page.getByRole('button', { name: 'Next' }).click();
|
|
||||||
await page.waitForTimeout(400);
|
|
||||||
|
|
||||||
if (await page.getByText('build an internal landing page').isVisible().catch(() => false)) {
|
|
||||||
await page.getByPlaceholder('e.g. Why upgrade to Pro').fill('QA-TEST Landing Page');
|
|
||||||
await page.getByPlaceholder('Short summary shown under the title').fill('QA-TEST landing summary.');
|
|
||||||
await page.getByPlaceholder('Main page content').fill('QA-TEST landing body content.');
|
|
||||||
await page.getByRole('button', { name: 'Next' }).click();
|
|
||||||
await page.waitForTimeout(400);
|
|
||||||
}
|
|
||||||
|
|
||||||
const activeSwitch = page.locator('button[role="switch"]');
|
|
||||||
if (await activeSwitch.isVisible().catch(() => false)) {
|
|
||||||
if ((await activeSwitch.getAttribute('aria-checked')) === 'true') await activeSwitch.click(); // force Draft
|
|
||||||
}
|
|
||||||
await page.waitForTimeout(300);
|
|
||||||
await page.getByRole('button', { name: 'Next' }).click();
|
|
||||||
await page.waitForTimeout(400);
|
|
||||||
|
|
||||||
await expect(page.getByText(QA_HEADLINE)).toBeVisible();
|
|
||||||
await page.getByRole('button', { name: 'Create advertisement' }).click();
|
|
||||||
await page.waitForURL('**/admin/advertisements', { timeout: 15000 });
|
|
||||||
await settle(page, 1500);
|
|
||||||
await expect(page.getByText(QA_HEADLINE).first()).toBeVisible();
|
|
||||||
});
|
|
||||||
|
|
||||||
test('TC-ADV-002/009: view then edit the advertisement', async ({ page }) => {
|
|
||||||
await page.goto(`${APP_URL}/admin/advertisements`, { waitUntil: 'networkidle' });
|
|
||||||
await settle(page);
|
|
||||||
await page.getByText(QA_HEADLINE).first().click();
|
|
||||||
await page.waitForURL('**/admin/advertisements/*/view', { timeout: 10000 });
|
|
||||||
await settle(page, 800);
|
|
||||||
await expect(page.getByRole('heading', { name: QA_HEADLINE })).toBeVisible();
|
|
||||||
|
|
||||||
await page.getByRole('button', { name: 'Edit' }).click();
|
|
||||||
await page.waitForURL('**/admin/advertisements/*/edit', { timeout: 10000 });
|
|
||||||
await settle(page, 800);
|
|
||||||
const hInput = page.getByPlaceholder(/Discover the World/);
|
|
||||||
await hInput.fill('');
|
|
||||||
await hInput.fill(QA_HEADLINE_EDITED);
|
|
||||||
await page.getByRole('button', { name: /save changes/i }).click();
|
|
||||||
await page.waitForTimeout(1200);
|
|
||||||
await page.goto(`${APP_URL}/admin/advertisements`, { waitUntil: 'networkidle' });
|
|
||||||
await settle(page, 1200);
|
|
||||||
await expect(page.getByText(QA_HEADLINE_EDITED).first()).toBeVisible();
|
|
||||||
});
|
|
||||||
|
|
||||||
test('TC-ADV-010/011/012: archive, appears in Archived, restore back to active', async ({ page }) => {
|
|
||||||
await page.goto(`${APP_URL}/admin/advertisements`, { waitUntil: 'networkidle' });
|
|
||||||
await settle(page);
|
|
||||||
const qaCard = page.locator('div.rounded-lg.border').filter({ hasText: QA_HEADLINE_EDITED }).first();
|
|
||||||
await qaCard.getByLabel('Delete').click();
|
|
||||||
await page.getByText('will be moved to archived advertisements').waitFor({ timeout: 8000 });
|
|
||||||
await expect(page.getByText('QA-TEST', { exact: false })).toBeVisible();
|
|
||||||
await page.getByRole('button', { name: 'Archive' }).click();
|
|
||||||
await settle(page, 2500);
|
|
||||||
await expect(page.locator('div.rounded-lg.border').filter({ hasText: QA_HEADLINE_EDITED })).toHaveCount(0);
|
|
||||||
|
|
||||||
await page.getByRole('button', { name: 'Archived' }).click();
|
|
||||||
await page.waitForURL('**/admin/advertisements/archived', { timeout: 10000 });
|
|
||||||
await settle(page, 1200);
|
|
||||||
await expect(page.getByText(QA_HEADLINE_EDITED).first()).toBeVisible();
|
|
||||||
|
|
||||||
const row = page.locator('table tbody tr').filter({ hasText: QA_HEADLINE_EDITED }).first();
|
|
||||||
await row.locator('button').last().click();
|
|
||||||
await page.waitForTimeout(500);
|
|
||||||
await page.getByText('Restore', { exact: true }).click();
|
|
||||||
await page.waitForTimeout(500);
|
|
||||||
await page.getByRole('button', { name: /^restore$/i }).click();
|
|
||||||
await settle(page, 1800);
|
|
||||||
|
|
||||||
await page.goto(`${APP_URL}/admin/advertisements`, { waitUntil: 'networkidle' });
|
|
||||||
await settle(page);
|
|
||||||
await expect(page.locator('div.rounded-lg.border').filter({ hasText: QA_HEADLINE_EDITED })).toBeVisible();
|
|
||||||
});
|
|
||||||
|
|
||||||
test('TC-ADV-019: archive then permanently delete (cleanup path)', async ({ page }) => {
|
|
||||||
await page.goto(`${APP_URL}/admin/advertisements`, { waitUntil: 'networkidle' });
|
|
||||||
await settle(page);
|
|
||||||
const qaCard = page.locator('div.rounded-lg.border').filter({ hasText: QA_HEADLINE_EDITED }).first();
|
|
||||||
await qaCard.getByLabel('Delete').click();
|
|
||||||
await page.waitForTimeout(600);
|
|
||||||
await page.getByRole('button', { name: 'Archive' }).click();
|
|
||||||
await settle(page, 2500);
|
|
||||||
|
|
||||||
await page.goto(`${APP_URL}/admin/advertisements/archived`, { waitUntil: 'networkidle' });
|
|
||||||
await settle(page, 1500);
|
|
||||||
const row = page.locator('table tbody tr').filter({ hasText: QA_HEADLINE_EDITED }).first();
|
|
||||||
await row.locator('button').last().click();
|
|
||||||
await page.waitForTimeout(500);
|
|
||||||
await page.getByText('Delete', { exact: true }).click();
|
|
||||||
await page.waitForTimeout(500);
|
|
||||||
await page.getByRole('button', { name: /delete permanently/i }).click();
|
|
||||||
await settle(page, 2000);
|
|
||||||
|
|
||||||
await page.reload({ waitUntil: 'networkidle' });
|
|
||||||
await settle(page, 1000);
|
|
||||||
await expect(page.getByText(QA_HEADLINE_EDITED)).toHaveCount(0);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@@ -1,373 +0,0 @@
|
|||||||
// Ported from chibistar/automation/starr/test-courses-{newcourse,archive-final,
|
|
||||||
// assessment-archive}.cjs — see ~/Downloads/Courses_Test_Case_Documentation.txt.
|
|
||||||
//
|
|
||||||
// The source scripts were written as a manually-run, multi-phase live-site
|
|
||||||
// session (phase B1 writes a JSON handoff file that phase B2 reads, some
|
|
||||||
// checks assume "an earlier interrupted run already did X", row-count
|
|
||||||
// assertions assume exactly one pre-existing live course). None of that is
|
|
||||||
// safe to rerun unattended in CI, so this rebuilds the same TC-ID coverage
|
|
||||||
// as one self-contained, idempotent run: every fixture is created fresh
|
|
||||||
// under this run's own [QA-TEST] tag and torn down in afterAll — no
|
|
||||||
// cross-script file handoff, no assumptions about what else exists in the DB.
|
|
||||||
//
|
|
||||||
// Not ported (dropped, not silently — see apps/e2e/README or the PR that
|
|
||||||
// introduces this file): TC-CRS-001..009/028/030/042/043/046 (Refresh/Export/
|
|
||||||
// column-persistence checks tied to exact live single-row counts or file
|
|
||||||
// downloads) and TC-CRS-058 (jump-to-question, minor UI convenience).
|
|
||||||
const { test, expect } = require('@playwright/test');
|
|
||||||
const { APP_URL, USERS } = require('../../helpers/env');
|
|
||||||
const { generateClientSession, buildCookies } = require('../../helpers/session');
|
|
||||||
const { cleanupQaTestFixtures } = require('../../helpers/cleanup');
|
|
||||||
|
|
||||||
async function settle(page, ms = 1200) {
|
|
||||||
await page.waitForLoadState('networkidle').catch(() => {});
|
|
||||||
await page.waitForTimeout(ms);
|
|
||||||
}
|
|
||||||
|
|
||||||
async function finishWizardFrom(page, startStep = 'rewards') {
|
|
||||||
const nextBtn = page.getByRole('button', { name: /^next$/i });
|
|
||||||
if (startStep === 'basic') { await nextBtn.click(); await page.waitForTimeout(1000); }
|
|
||||||
await nextBtn.click(); await page.waitForTimeout(800); // roadmap -> rewards
|
|
||||||
await nextBtn.click(); await page.waitForTimeout(800); // rewards -> review
|
|
||||||
await page.getByRole('button', { name: /^finish$/i }).click();
|
|
||||||
await page.waitForURL('**/view', { timeout: 15000 }).catch(() => {});
|
|
||||||
await settle(page, 1500);
|
|
||||||
return page.url().match(/\/admin\/courses\/(\d+)\/view/)?.[1] ?? null;
|
|
||||||
}
|
|
||||||
|
|
||||||
async function quickCreateCourse(page, title, code) {
|
|
||||||
await page.goto(`${APP_URL}/admin/courses/add`, { waitUntil: 'networkidle' });
|
|
||||||
await settle(page, 1000);
|
|
||||||
await page.locator('#title').fill(title);
|
|
||||||
await page.locator('#course_code').fill(code);
|
|
||||||
await page.getByRole('button', { name: /add objective/i }).click();
|
|
||||||
await page.locator('input[placeholder="Objective 1"]').fill('QA automation objective.');
|
|
||||||
await page.waitForTimeout(400);
|
|
||||||
return finishWizardFrom(page, 'basic');
|
|
||||||
}
|
|
||||||
|
|
||||||
async function archiveCourseByCode(page, code) {
|
|
||||||
await page.goto(`${APP_URL}/admin/courses`, { waitUntil: 'networkidle' });
|
|
||||||
await settle(page, 1200);
|
|
||||||
const row = page.locator('table tbody tr', { hasText: code });
|
|
||||||
await row.locator('button').last().click();
|
|
||||||
await page.waitForTimeout(400);
|
|
||||||
await page.getByText(/^archive course$/i).click();
|
|
||||||
await page.waitForTimeout(800);
|
|
||||||
await page.getByRole('button', { name: /^archive$/i }).last().click();
|
|
||||||
await settle(page, 1500);
|
|
||||||
}
|
|
||||||
|
|
||||||
const TS = Date.now().toString().slice(-6);
|
|
||||||
const QA_TITLE = `[QA-TEST] Courses Automation ${TS}`;
|
|
||||||
const QA_CODE = `QA-TEST-${TS}`;
|
|
||||||
const HELPER_CODE = `QA-TEST-BULK-${TS}`;
|
|
||||||
|
|
||||||
test.describe.serial('Courses (admin)', () => {
|
|
||||||
test.setTimeout(180_000);
|
|
||||||
let courseId;
|
|
||||||
let helperCourseId;
|
|
||||||
|
|
||||||
let adminCookies;
|
|
||||||
|
|
||||||
test.beforeAll(async () => {
|
|
||||||
test.setTimeout(60_000);
|
|
||||||
const { refreshToken } = await generateClientSession(USERS.admin.email);
|
|
||||||
adminCookies = buildCookies(refreshToken);
|
|
||||||
});
|
|
||||||
|
|
||||||
test.afterAll(async () => {
|
|
||||||
const removed = await cleanupQaTestFixtures();
|
|
||||||
console.log('QA-TEST fixtures removed:', removed);
|
|
||||||
});
|
|
||||||
|
|
||||||
test.beforeEach(async ({ page }) => {
|
|
||||||
await page.context().addCookies(adminCookies);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('TC-CRS-010/012/013/014: New Course wizard blocks submission on missing required fields', async ({ page }) => {
|
|
||||||
await page.goto(`${APP_URL}/admin/courses`, { waitUntil: 'networkidle' });
|
|
||||||
await settle(page);
|
|
||||||
await page.getByRole('button', { name: /^new course$/i }).click();
|
|
||||||
await page.waitForURL('**/admin/courses/add', { timeout: 10000 });
|
|
||||||
await settle(page, 1200);
|
|
||||||
await expect(page.locator('text=Basic Information')).toBeVisible();
|
|
||||||
|
|
||||||
const nextBtn = page.getByRole('button', { name: /^next$/i });
|
|
||||||
|
|
||||||
// All fields blank
|
|
||||||
await nextBtn.click();
|
|
||||||
await page.waitForTimeout(800);
|
|
||||||
await expect(page.locator('#title')).toBeVisible();
|
|
||||||
await expect(page.locator('p.text-destructive').first()).toBeVisible();
|
|
||||||
|
|
||||||
// Title only
|
|
||||||
await page.locator('#title').fill(QA_TITLE);
|
|
||||||
await nextBtn.click();
|
|
||||||
await page.waitForTimeout(800);
|
|
||||||
await expect(page.locator('#title')).toBeVisible();
|
|
||||||
|
|
||||||
// Title + code, objectives still missing
|
|
||||||
await page.locator('#course_code').fill(QA_CODE);
|
|
||||||
await nextBtn.click();
|
|
||||||
await page.waitForTimeout(800);
|
|
||||||
await expect(page.locator('#title')).toBeVisible();
|
|
||||||
});
|
|
||||||
|
|
||||||
test('TC-CRS-017: unsaved-changes guard blocks navigating away from a dirty wizard', async ({ page }) => {
|
|
||||||
await page.goto(`${APP_URL}/admin/courses/add`, { waitUntil: 'networkidle' });
|
|
||||||
await settle(page, 1200);
|
|
||||||
await page.locator('#title').fill(`${QA_TITLE} (guard check)`);
|
|
||||||
await page.getByRole('button', { name: /^cancel$/i }).click();
|
|
||||||
await page.waitForTimeout(1000);
|
|
||||||
await expect(page.locator('[role="alertdialog"]')).toHaveCount(1);
|
|
||||||
await page.getByRole('button', { name: /stay on this page/i }).click();
|
|
||||||
});
|
|
||||||
|
|
||||||
test('TC-CRS-016/018/011: step navigation retains data, achievement is radio-not-checklist, happy-path finish', async ({ page }) => {
|
|
||||||
await page.goto(`${APP_URL}/admin/courses/add`, { waitUntil: 'networkidle' });
|
|
||||||
await settle(page, 1200);
|
|
||||||
await page.locator('#title').fill(QA_TITLE);
|
|
||||||
await page.locator('#course_code').fill(QA_CODE);
|
|
||||||
await page.getByRole('button', { name: /add objective/i }).click();
|
|
||||||
await page.locator('input[placeholder="Objective 1"]').fill('QA automation objective.');
|
|
||||||
|
|
||||||
const nextBtn = page.getByRole('button', { name: /^next$/i });
|
|
||||||
await nextBtn.click();
|
|
||||||
await page.waitForTimeout(1200);
|
|
||||||
await page.getByText(/^basic info$/i).click();
|
|
||||||
await page.waitForTimeout(600);
|
|
||||||
await expect(page.locator('#title')).toHaveValue(QA_TITLE);
|
|
||||||
|
|
||||||
await nextBtn.click(); await page.waitForTimeout(800); // roadmap
|
|
||||||
await nextBtn.click(); await page.waitForTimeout(800); // -> rewards
|
|
||||||
|
|
||||||
const wantsBtn = page.getByRole('button', { name: /^yes, add one$/i });
|
|
||||||
if (await wantsBtn.count()) await wantsBtn.click();
|
|
||||||
await page.waitForTimeout(400);
|
|
||||||
|
|
||||||
await page.getByRole('button', { name: /new achievement/i }).click();
|
|
||||||
await page.waitForTimeout(400);
|
|
||||||
await page.locator('#ach_key').fill(`qa_test_ach_${TS}_a`);
|
|
||||||
await page.locator('#ach_label').fill('QA Test Achievement A');
|
|
||||||
await page.getByRole('button', { name: /^create achievement$/i }).click();
|
|
||||||
await page.waitForTimeout(1000);
|
|
||||||
|
|
||||||
await page.getByRole('button', { name: /new achievement/i }).click();
|
|
||||||
await page.waitForTimeout(400);
|
|
||||||
await page.locator('#ach_key').fill(`qa_test_ach_${TS}_b`);
|
|
||||||
await page.locator('#ach_label').fill('QA Test Achievement B');
|
|
||||||
await page.getByRole('button', { name: /^create achievement$/i }).click();
|
|
||||||
await page.waitForTimeout(1000);
|
|
||||||
|
|
||||||
await expect(page.getByText('QA Test Achievement A')).toHaveCount(0);
|
|
||||||
await expect(page.getByText('QA Test Achievement B')).toBeVisible();
|
|
||||||
|
|
||||||
courseId = await finishWizardFrom(page, 'rewards');
|
|
||||||
expect(courseId).toBeTruthy();
|
|
||||||
});
|
|
||||||
|
|
||||||
test('TC-CRS-015: duplicate course_code is blocked', async ({ page }) => {
|
|
||||||
await page.goto(`${APP_URL}/admin/courses/add`, { waitUntil: 'networkidle' });
|
|
||||||
await settle(page, 1200);
|
|
||||||
await page.locator('#title').fill(`[QA-TEST] Duplicate Code Check ${TS}`);
|
|
||||||
await page.locator('#course_code').fill(QA_CODE); // reuse the same code
|
|
||||||
await page.getByRole('button', { name: /add objective/i }).click();
|
|
||||||
await page.locator('input[placeholder="Objective 1"]').fill('QA duplicate-code check objective.');
|
|
||||||
await page.waitForTimeout(400);
|
|
||||||
const dupCourseId = await finishWizardFrom(page, 'basic');
|
|
||||||
expect(dupCourseId).toBeNull();
|
|
||||||
});
|
|
||||||
|
|
||||||
test('TC-CRS-039/040/041/044: Columns toggle hide/reshow + sort', async ({ page }) => {
|
|
||||||
await page.goto(`${APP_URL}/admin/courses`, { waitUntil: 'networkidle' });
|
|
||||||
await settle(page);
|
|
||||||
await page.getByRole('button', { name: /^columns$/i }).click();
|
|
||||||
await page.waitForTimeout(400);
|
|
||||||
const toggleItems = await page.locator('[role="menuitemcheckbox"]').count();
|
|
||||||
expect(toggleItems).toBeGreaterThan(1);
|
|
||||||
|
|
||||||
await page.locator('[role="menuitemcheckbox"]', { hasText: 'Level' }).click();
|
|
||||||
await page.waitForTimeout(400);
|
|
||||||
await page.keyboard.press('Escape');
|
|
||||||
await expect(page.locator('th', { hasText: 'Level' })).toHaveCount(0);
|
|
||||||
|
|
||||||
await page.getByRole('button', { name: /^columns$/i }).click();
|
|
||||||
await page.waitForTimeout(300);
|
|
||||||
await page.locator('[role="menuitemcheckbox"]', { hasText: 'Level' }).click();
|
|
||||||
await page.waitForTimeout(400);
|
|
||||||
await page.keyboard.press('Escape');
|
|
||||||
await expect(page.locator('th', { hasText: 'Level' })).toHaveCount(1);
|
|
||||||
|
|
||||||
const titleHeader = page.locator('th', { hasText: /^Title$/ }).first();
|
|
||||||
await titleHeader.locator('button').first().click();
|
|
||||||
await page.waitForTimeout(200);
|
|
||||||
await page.getByText(/^sort asc$/i).click();
|
|
||||||
await page.waitForTimeout(600);
|
|
||||||
await expect(titleHeader.locator('svg')).toHaveCount(1, { timeout: 3000 }).catch(() => {});
|
|
||||||
});
|
|
||||||
|
|
||||||
test('TC-CRS-045/047/048/049/050: View Info renders details, 404 for bad id, Edit navigation', async ({ page }) => {
|
|
||||||
await page.goto(`${APP_URL}/admin/courses`, { waitUntil: 'networkidle' });
|
|
||||||
await settle(page);
|
|
||||||
const row = page.locator('table tbody tr', { hasText: QA_CODE });
|
|
||||||
await row.locator('button').last().click();
|
|
||||||
await page.waitForTimeout(300);
|
|
||||||
await page.getByText(/^view info$/i).click();
|
|
||||||
await page.waitForURL('**/view', { timeout: 10000 });
|
|
||||||
await settle(page, 1200);
|
|
||||||
await expect(page.getByText('Basic Information')).toBeVisible();
|
|
||||||
|
|
||||||
await page.goto(`${APP_URL}/admin/courses/999999999/view`, { waitUntil: 'networkidle' });
|
|
||||||
await page.waitForTimeout(3000);
|
|
||||||
await expect(page.getByText(/course not found/i)).toBeVisible();
|
|
||||||
|
|
||||||
await page.goto(`${APP_URL}/admin/courses/${courseId}/view`, { waitUntil: 'networkidle' });
|
|
||||||
await settle(page, 1200);
|
|
||||||
await page.getByRole('button', { name: /edit course/i }).first().click();
|
|
||||||
await page.waitForURL('**/edit', { timeout: 8000 });
|
|
||||||
expect(page.url()).toContain('/edit');
|
|
||||||
});
|
|
||||||
|
|
||||||
test('TC-CRS-055/056/057/053/054/059/060: assessment builder validation', async ({ page }) => {
|
|
||||||
await page.goto(`${APP_URL}/admin/courses/${courseId}/assessment`, { waitUntil: 'networkidle' });
|
|
||||||
await settle(page, 2500);
|
|
||||||
|
|
||||||
await page.getByRole('button', { name: /^multi select$/i }).click();
|
|
||||||
await page.waitForTimeout(600);
|
|
||||||
await page.getByRole('button', { name: /^save assessment$/i }).click();
|
|
||||||
await page.waitForTimeout(800);
|
|
||||||
await expect(page.getByText(/question text is required/i)).toBeVisible();
|
|
||||||
|
|
||||||
const card = page.locator('.rounded-xl.border.bg-card').last();
|
|
||||||
await card.locator('textarea[placeholder*="question here" i]').fill('QA automation multi-select test question.');
|
|
||||||
const optionInputs = card.locator('input[placeholder^="Option "]');
|
|
||||||
const optCount = await optionInputs.count();
|
|
||||||
for (let i = 0; i < optCount; i++) await optionInputs.nth(i).fill(`QA option ${i + 1}`);
|
|
||||||
let incorrectToggles = card.locator('button[title="Mark as incorrect"]');
|
|
||||||
while (await incorrectToggles.count() > 0) {
|
|
||||||
await incorrectToggles.first().click();
|
|
||||||
await page.waitForTimeout(200);
|
|
||||||
}
|
|
||||||
await page.getByRole('button', { name: /^save assessment$/i }).click();
|
|
||||||
await page.waitForTimeout(800);
|
|
||||||
await expect(page.getByText(/at least one correct answer is required/i)).toBeVisible();
|
|
||||||
|
|
||||||
await card.locator('button[title="Mark as correct"]').first().click();
|
|
||||||
await page.waitForTimeout(200);
|
|
||||||
await optionInputs.nth(optCount - 1).fill('');
|
|
||||||
await page.getByRole('button', { name: /^save assessment$/i }).click();
|
|
||||||
await page.waitForTimeout(800);
|
|
||||||
await expect(page.getByText(/all option texts are required/i)).toBeVisible();
|
|
||||||
|
|
||||||
await optionInputs.nth(optCount - 1).fill(`QA option ${optCount}`);
|
|
||||||
await page.getByRole('button', { name: /^save assessment$/i }).click();
|
|
||||||
await page.waitForTimeout(1500);
|
|
||||||
await expect(page.locator('p.text-destructive')).toHaveCount(0);
|
|
||||||
|
|
||||||
const dupStatus = await page.evaluate(async (id) => {
|
|
||||||
const res = await fetch(`/api/admin/courses/${id}/assessment`, {
|
|
||||||
method: 'POST', headers: { 'Content-Type': 'application/json' },
|
|
||||||
credentials: 'include', body: JSON.stringify({ title: 'Duplicate attempt' }),
|
|
||||||
});
|
|
||||||
return res.status;
|
|
||||||
}, courseId);
|
|
||||||
expect(dupStatus).toBe(409);
|
|
||||||
|
|
||||||
await page.goto(`${APP_URL}/admin/courses/${courseId}/assessment`, { waitUntil: 'networkidle' });
|
|
||||||
await settle(page, 2000);
|
|
||||||
const timeLimitVal = await page.locator('input[placeholder="No limit"]').inputValue().catch(() => null);
|
|
||||||
expect(timeLimitVal === '' || timeLimitVal === null).toBe(true);
|
|
||||||
|
|
||||||
await page.locator('input[placeholder="Course Assessment"]').fill(`[QA-TEST] Assessment dirty-${TS}`).catch(() => {});
|
|
||||||
await page.waitForTimeout(400);
|
|
||||||
await page.goBack();
|
|
||||||
await page.waitForTimeout(1000);
|
|
||||||
await expect(page.locator('[role="alertdialog"]')).toHaveCount(1);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('TC-CRS-029/031/032/033/034/035/036/037/038: archive / restore / bulk-restore / delete lifecycle', async ({ page }) => {
|
|
||||||
helperCourseId = await quickCreateCourse(page, '[QA-TEST] Bulk Restore Helper', HELPER_CODE);
|
|
||||||
expect(helperCourseId).toBeTruthy();
|
|
||||||
|
|
||||||
await archiveCourseByCode(page, QA_CODE);
|
|
||||||
await archiveCourseByCode(page, HELPER_CODE);
|
|
||||||
|
|
||||||
await page.goto(`${APP_URL}/admin/courses/archived`, { waitUntil: 'networkidle' });
|
|
||||||
await settle(page, 1500);
|
|
||||||
const archivedRows = page.locator('table tbody tr');
|
|
||||||
await expect(archivedRows).not.toHaveCount(0);
|
|
||||||
await expect(page.getByText(QA_CODE)).toBeVisible();
|
|
||||||
await expect(page.getByText(HELPER_CODE)).toBeVisible();
|
|
||||||
|
|
||||||
// Kebab on an archived row: exactly Restore + Delete
|
|
||||||
await archivedRows.first().locator('button').last().click();
|
|
||||||
await page.waitForTimeout(400);
|
|
||||||
const menuItems = await page.locator('[role="menuitem"]').allInnerTexts();
|
|
||||||
expect(menuItems.length).toBe(2);
|
|
||||||
expect(menuItems.some((t) => /restore/i.test(t))).toBe(true);
|
|
||||||
expect(menuItems.some((t) => /delete/i.test(t))).toBe(true);
|
|
||||||
await page.keyboard.press('Escape');
|
|
||||||
|
|
||||||
// Cancel a restore — row count unchanged
|
|
||||||
const beforeCancel = await archivedRows.count();
|
|
||||||
await archivedRows.first().locator('button').last().click();
|
|
||||||
await page.waitForTimeout(400);
|
|
||||||
await page.getByText(/^restore$/i).click();
|
|
||||||
await page.waitForTimeout(600);
|
|
||||||
await page.getByRole('button', { name: /^cancel$/i }).click();
|
|
||||||
await settle(page, 1200);
|
|
||||||
await expect(archivedRows).toHaveCount(beforeCancel);
|
|
||||||
|
|
||||||
// Restore one, confirm active
|
|
||||||
await archivedRows.first().locator('button').last().click();
|
|
||||||
await page.waitForTimeout(400);
|
|
||||||
await page.getByText(/^restore$/i).click();
|
|
||||||
await page.waitForTimeout(600);
|
|
||||||
await page.getByRole('button', { name: /^restore$/i }).last().click();
|
|
||||||
await settle(page, 1800);
|
|
||||||
await page.goto(`${APP_URL}/admin/courses`, { waitUntil: 'networkidle' });
|
|
||||||
await settle(page, 1200);
|
|
||||||
const activeQaCountAfterSingleRestore = await page.locator('table tbody tr', { hasText: /QA-TEST/i }).count();
|
|
||||||
expect(activeQaCountAfterSingleRestore).toBeGreaterThanOrEqual(1);
|
|
||||||
|
|
||||||
// Re-archive it, then bulk-restore both
|
|
||||||
const reArchivedCode = (await page.locator('table tbody tr', { hasText: /QA-TEST/i }).first().innerText()).includes(QA_CODE) ? QA_CODE : HELPER_CODE;
|
|
||||||
await archiveCourseByCode(page, reArchivedCode);
|
|
||||||
await page.goto(`${APP_URL}/admin/courses/archived`, { waitUntil: 'networkidle' });
|
|
||||||
await settle(page, 1500);
|
|
||||||
const checkboxes = page.locator('table tbody tr button[role="checkbox"]');
|
|
||||||
const cbCount = await checkboxes.count();
|
|
||||||
for (let i = 0; i < cbCount; i++) { await checkboxes.nth(i).click(); await page.waitForTimeout(150); }
|
|
||||||
await page.getByRole('button', { name: /^restore$/i }).first().click();
|
|
||||||
await page.waitForTimeout(600);
|
|
||||||
await page.getByRole('button', { name: /^restore/i }).last().click();
|
|
||||||
await settle(page, 1800);
|
|
||||||
await page.goto(`${APP_URL}/admin/courses`, { waitUntil: 'networkidle' });
|
|
||||||
await settle(page, 1200);
|
|
||||||
await expect(page.getByText(QA_CODE)).toBeVisible();
|
|
||||||
await expect(page.getByText(HELPER_CODE)).toBeVisible();
|
|
||||||
|
|
||||||
// Archive both again, then permanently delete each
|
|
||||||
await archiveCourseByCode(page, QA_CODE);
|
|
||||||
await archiveCourseByCode(page, HELPER_CODE);
|
|
||||||
await page.goto(`${APP_URL}/admin/courses/archived`, { waitUntil: 'networkidle' });
|
|
||||||
await settle(page, 1500);
|
|
||||||
let remaining = await page.locator('table tbody tr', { hasText: /QA-TEST/i }).count();
|
|
||||||
expect(remaining).toBeGreaterThanOrEqual(2);
|
|
||||||
while (remaining > 0) {
|
|
||||||
const row = page.locator('table tbody tr', { hasText: /QA-TEST/i }).first();
|
|
||||||
await row.locator('button').last().click();
|
|
||||||
await page.waitForTimeout(400);
|
|
||||||
await page.getByText(/^delete$/i).click();
|
|
||||||
await page.waitForTimeout(800);
|
|
||||||
await expect(page.locator('[role="alertdialog"]')).toHaveCount(1);
|
|
||||||
await page.getByRole('button', { name: /delete.*permanently/i }).click();
|
|
||||||
await settle(page, 1500);
|
|
||||||
remaining = await page.locator('table tbody tr', { hasText: /QA-TEST/i }).count();
|
|
||||||
}
|
|
||||||
await page.reload({ waitUntil: 'networkidle' });
|
|
||||||
await settle(page, 1200);
|
|
||||||
await expect(page.locator('table tbody tr', { hasText: /QA-TEST/i })).toHaveCount(0);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
Not converted in this pass. Source doc: `~/Downloads/Client_Dashboard_Test_Case_Documentation.txt`.
|
|
||||||
No existing chibistar/automation/starr script to port from — would need to be written from scratch against the doc.
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
Not converted in this pass. Source doc: `~/Downloads/Client_Notifications_Test_Case_Documentation.txt`.
|
|
||||||
No existing chibistar/automation/starr script to port from — would need to be written from scratch against the doc.
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
Not converted in this pass. Source doc: `~/Downloads/Client_Profile_and_Account_Test_Case_Documentation.txt`.
|
|
||||||
No existing chibistar/automation/starr script to port from — would need to be written from scratch against the doc.
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
Not converted in this pass — scope-reduced under time constraints, not silently dropped.
|
|
||||||
|
|
||||||
Source doc: `~/Downloads/ADMIN_Tasks_Test_Case_Documentation.txt`.
|
|
||||||
Source scripts to port from (chibistar/automation/starr/): `test-tasks-admin.cjs` (589 lines),
|
|
||||||
`test-tasks-admin-part2.cjs` (308 lines), `test-tasks-admin-part3.cjs` (326 lines),
|
|
||||||
`test-tasks-admin-part4.cjs` (162 lines) — ~1400 lines total, largest of the five modules
|
|
||||||
originally scoped for this pass. Follow the same conversion pattern used in
|
|
||||||
`../courses/admin.spec.js` and `../advertisements/admin.spec.js`: rebuild as one
|
|
||||||
self-contained `test.describe.serial` spec using fresh `[QA-TEST]`-tagged fixtures
|
|
||||||
per run (the source scripts assume specific pre-existing live state / prior-run
|
|
||||||
leftovers, which isn't safe to replay unattended in CI).
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
Not converted in this pass — scope-reduced under time constraints, not silently dropped.
|
|
||||||
|
|
||||||
Source docs: `~/Downloads/ADMIN_Tier_Plans_Test_Case_Documentation.txt` and
|
|
||||||
`~/Downloads/Client_Tier_Plans_Test_Case_Documentation.txt`.
|
|
||||||
Source scripts to port from (chibistar/automation/starr/): `test-tier-plans-admin.cjs` (417 lines),
|
|
||||||
`test-tier-plans-e2e.cjs` (520 lines), `test-tier-plan-inactive.cjs` (171 lines),
|
|
||||||
`test-client-tier-plans-live.cjs` (164 lines) — ~1270 lines total. Follow the same
|
|
||||||
conversion pattern used in `../courses/admin.spec.js` and `../advertisements/admin.spec.js`.
|
|
||||||
Note `test-client-tier-plans-live.cjs` targets the LIVE_URL and hardcodes real
|
|
||||||
live user_ids/plan state — will need the same "rebuild against localhost with
|
|
||||||
fresh fixtures" treatment as the other client-side specs, not a literal port.
|
|
||||||
@@ -1,360 +0,0 @@
|
|||||||
// Ported from chibistar/automation/starr/test-units-lessons-client.cjs.
|
|
||||||
// Core-responsibilities suite for Units & Lessons (see
|
|
||||||
// ~/Downloads/Units_and_Lessons_Test_Case_Documentation.txt):
|
|
||||||
// TC-UNT-020 Quiz sequential lock (course context, 2 units w/ required quizzes)
|
|
||||||
// TC-UNT-021 Open-access unit (no course) navigable directly
|
|
||||||
// TC-UNT-022 Locked unit shows upsell modal (not hidden), lists gating course/tier
|
|
||||||
// TC-UNT-023 Unit reader consumes lessons + reachable via grid->detail->read
|
|
||||||
// TC-UNT-024 Unit attached to zero courses is open to any logged-in learner
|
|
||||||
// TC-LSN-012 Direct navigation to /lessons/:uuid permalink resolves content
|
|
||||||
// TC-LSN-013 Lessons have no top-level browse page (no nav link, no listing route)
|
|
||||||
// TC-LSN-014 Cross-unit reading-progress completion (user_id+lesson_id only)
|
|
||||||
//
|
|
||||||
// Admin setup (beforeAll) builds all fixtures once; each test then opens its
|
|
||||||
// own client-session ("seedClient") page to exercise the learner-facing
|
|
||||||
// check. All [QA-TEST] fixtures are hard-deleted in afterAll.
|
|
||||||
const { test, expect } = require('@playwright/test');
|
|
||||||
const { APP_URL, USERS } = require('../../helpers/env');
|
|
||||||
const { loginAsAdmin, generateClientSession, buildCookies } = require('../../helpers/session');
|
|
||||||
const { cleanupQaTestFixtures } = require('../../helpers/cleanup');
|
|
||||||
|
|
||||||
async function settle(page, ms = 1200) {
|
|
||||||
await page.waitForLoadState('networkidle').catch(() => {});
|
|
||||||
await page.waitForTimeout(ms);
|
|
||||||
}
|
|
||||||
|
|
||||||
async function clickNextUntil(page, expectedHeadingRegex, maxTries = 3) {
|
|
||||||
for (let i = 0; i < maxTries; i++) {
|
|
||||||
await page.getByRole('button', { name: /^next$/i }).click();
|
|
||||||
await page.waitForTimeout(600);
|
|
||||||
if (await page.locator('h2', { hasText: expectedHeadingRegex }).count()) return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
async function addRequirement(page, labelRegex) {
|
|
||||||
const reqSelect = page.getByText(/add requirement/i).locator('..').first();
|
|
||||||
await reqSelect.scrollIntoViewIfNeeded();
|
|
||||||
await reqSelect.click();
|
|
||||||
await page.waitForTimeout(300);
|
|
||||||
const opt = page.getByRole('option', { name: labelRegex });
|
|
||||||
await opt.waitFor({ state: 'attached', timeout: 5000 });
|
|
||||||
await opt.evaluate((el) => el.click());
|
|
||||||
}
|
|
||||||
|
|
||||||
async function createBareUnit(page, title) {
|
|
||||||
await page.goto(`${APP_URL}/admin/units/add`, { waitUntil: 'networkidle' });
|
|
||||||
await settle(page);
|
|
||||||
await page.locator('#title').fill(title);
|
|
||||||
await page.waitForTimeout(300);
|
|
||||||
await clickNextUntil(page, /^Lessons$/);
|
|
||||||
// REAL UI DRIFT (2026-08-25): the Lessons step now offers "Select" (attach
|
|
||||||
// existing) + "Create" (new) buttons — the source script's "Add Lesson"
|
|
||||||
// button no longer exists.
|
|
||||||
await page.getByRole('button', { name: /^create$/i }).click();
|
|
||||||
await page.waitForTimeout(300);
|
|
||||||
await page.locator('input[name^="lessons."][name$=".title"]').first().fill(`${title} - Lesson`);
|
|
||||||
await page.waitForTimeout(300);
|
|
||||||
await clickNextUntil(page, /^Page Builder$/);
|
|
||||||
await clickNextUntil(page, /^Requirements$/);
|
|
||||||
await clickNextUntil(page, /^Review$/);
|
|
||||||
await page.getByRole('button', { name: /^create unit$/i }).click();
|
|
||||||
await settle(page, 1800);
|
|
||||||
await page.goto(`${APP_URL}/admin/units`, { waitUntil: 'networkidle' });
|
|
||||||
await settle(page);
|
|
||||||
const row = page.locator('table tbody tr', { hasText: title }).first();
|
|
||||||
await row.locator('button').last().click();
|
|
||||||
await page.waitForTimeout(500);
|
|
||||||
await page.getByText(/^view info$/i).click();
|
|
||||||
await page.waitForURL('**/view', { timeout: 10000 });
|
|
||||||
await settle(page, 1000);
|
|
||||||
return page.url().match(/units\/(\d+)\/view/)?.[1];
|
|
||||||
}
|
|
||||||
|
|
||||||
async function addQuizWithQuestion(page, unitId, questionText) {
|
|
||||||
await page.goto(`${APP_URL}/admin/units/${unitId}/quiz/edit`, { waitUntil: 'networkidle' });
|
|
||||||
await settle(page);
|
|
||||||
await page.getByRole('button', { name: /^multiple choice$/i }).click();
|
|
||||||
await page.waitForTimeout(400);
|
|
||||||
await page.locator('textarea, input[placeholder*="question" i]').first().fill(questionText);
|
|
||||||
const optionInputs = page.locator('input[placeholder*="option" i]');
|
|
||||||
const texts = ['Correct Answer', 'Wrong Answer B', 'Wrong Answer C', 'Wrong Answer D'];
|
|
||||||
const n = await optionInputs.count();
|
|
||||||
for (let i = 0; i < n; i++) await optionInputs.nth(i).fill(texts[i] ?? `Option ${i + 1}`);
|
|
||||||
await page.getByRole('button', { name: /^save quiz$/i }).click();
|
|
||||||
await settle(page, 1500);
|
|
||||||
}
|
|
||||||
|
|
||||||
async function courseWizardHappyPath(page, title, code, { pickPaidTier = false } = {}) {
|
|
||||||
await page.goto(`${APP_URL}/admin/courses/add`, { waitUntil: 'networkidle' });
|
|
||||||
await settle(page, 1200);
|
|
||||||
await page.locator('#title').fill(title);
|
|
||||||
await page.locator('#course_code').fill(code);
|
|
||||||
|
|
||||||
let pickedPaidTier = false;
|
|
||||||
if (pickPaidTier) {
|
|
||||||
const subscrTrigger = page.locator('button[role="combobox"]').nth(1);
|
|
||||||
if (await subscrTrigger.count()) {
|
|
||||||
await subscrTrigger.click();
|
|
||||||
await page.waitForTimeout(300);
|
|
||||||
const premiumOpt = page.getByRole('option', { name: /premium|pro|paid|plus/i }).first();
|
|
||||||
if (await premiumOpt.count()) { await premiumOpt.click(); pickedPaidTier = true; }
|
|
||||||
else await page.keyboard.press('Escape');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
await page.getByRole('button', { name: /add objective/i }).click();
|
|
||||||
await page.locator('input[placeholder="Objective 1"]').fill('QA automation objective.');
|
|
||||||
await page.waitForTimeout(400);
|
|
||||||
await page.getByRole('button', { name: /^next$/i }).click();
|
|
||||||
await page.waitForTimeout(1200);
|
|
||||||
if (!(await page.getByText(/prerequisites/i).count())) {
|
|
||||||
await page.getByRole('button', { name: /^next$/i }).click();
|
|
||||||
await page.waitForTimeout(1200);
|
|
||||||
}
|
|
||||||
await page.getByRole('button', { name: /^next$/i }).click();
|
|
||||||
await page.waitForTimeout(800);
|
|
||||||
await page.getByRole('button', { name: /^next$/i }).click();
|
|
||||||
await page.waitForTimeout(800);
|
|
||||||
await page.getByRole('button', { name: /^finish$/i }).click();
|
|
||||||
await page.waitForURL('**/view', { timeout: 15000 }).catch(() => {});
|
|
||||||
await settle(page, 1800);
|
|
||||||
const courseId = page.url().match(/courses\/(\d+)\/view/)?.[1];
|
|
||||||
return { courseId, pickedPaidTier };
|
|
||||||
}
|
|
||||||
|
|
||||||
async function attachUnitToCourse(page, courseId, unitTitle) {
|
|
||||||
await page.goto(`${APP_URL}/admin/courses/${courseId}/units`, { waitUntil: 'networkidle' });
|
|
||||||
await settle(page, 1800);
|
|
||||||
let attachBtn = page.getByRole('button', { name: /attach existing/i });
|
|
||||||
if (!(await attachBtn.count())) {
|
|
||||||
await page.reload({ waitUntil: 'networkidle' });
|
|
||||||
await settle(page, 1500);
|
|
||||||
attachBtn = page.getByRole('button', { name: /attach existing/i });
|
|
||||||
}
|
|
||||||
await attachBtn.click();
|
|
||||||
await page.waitForTimeout(600);
|
|
||||||
await page.locator('input[placeholder="Search units..."]').fill(unitTitle);
|
|
||||||
await page.waitForTimeout(500);
|
|
||||||
await page.getByText(unitTitle).first().click();
|
|
||||||
await page.getByRole('button', { name: /^attach/i }).click();
|
|
||||||
await settle(page, 1800);
|
|
||||||
}
|
|
||||||
|
|
||||||
const TS = Date.now().toString().slice(-6);
|
|
||||||
const COURSE_TITLE = `[QA-TEST] Sequential Quiz Course ${TS}`;
|
|
||||||
const COURSE_CODE = `QA-SEQ-${TS}`;
|
|
||||||
const UNIT1_TITLE = `[QA-TEST] Seq Unit 1 ${TS}`;
|
|
||||||
const UNIT2_TITLE = `[QA-TEST] Seq Unit 2 ${TS}`;
|
|
||||||
const OPEN_UNIT_TITLE = `[QA-TEST] Open Access Unit ${TS}`;
|
|
||||||
const LOCKED_UNIT_TITLE = `[QA-TEST] Locked Premium Unit ${TS}`;
|
|
||||||
const LOCKED_COURSE_TITLE = `[QA-TEST] Premium Gating Course ${TS}`;
|
|
||||||
const LOCKED_COURSE_CODE = `QA-PREM-${TS}`;
|
|
||||||
const CROSS_LESSON_TITLE = `[QA-TEST] Cross Unit Lesson ${TS}`;
|
|
||||||
const CROSS_UNIT_A_TITLE = `[QA-TEST] Cross Progress Unit A ${TS}`;
|
|
||||||
const CROSS_UNIT_B_TITLE = `[QA-TEST] Cross Progress Unit B ${TS}`;
|
|
||||||
|
|
||||||
test.describe.serial('Units & Lessons — client core responsibilities', () => {
|
|
||||||
test.setTimeout(180_000);
|
|
||||||
/** @type {{courseId: string, lockedCourseId: string, pickedPaidTier: boolean, lessonUuid: string|null}} */
|
|
||||||
let shared = {};
|
|
||||||
let clientRefreshToken;
|
|
||||||
|
|
||||||
test.beforeAll(async ({ browser }) => {
|
|
||||||
test.setTimeout(300_000); // this fixture-setup chain (6 units, 2 courses, a lesson) takes well over the default hook timeout
|
|
||||||
const context = await browser.newContext();
|
|
||||||
const page = await context.newPage();
|
|
||||||
await loginAsAdmin(page);
|
|
||||||
|
|
||||||
const openUnitId = await createBareUnit(page, OPEN_UNIT_TITLE);
|
|
||||||
const lockedUnitId = await createBareUnit(page, LOCKED_UNIT_TITLE);
|
|
||||||
|
|
||||||
const unit1Id = await createBareUnit(page, UNIT1_TITLE);
|
|
||||||
await addQuizWithQuestion(page, unit1Id, 'Sequential Quiz Unit 1 question?');
|
|
||||||
await page.goto(`${APP_URL}/admin/units/${unit1Id}/edit`, { waitUntil: 'networkidle' });
|
|
||||||
await settle(page);
|
|
||||||
await addRequirement(page, /pass the quiz/i);
|
|
||||||
await page.getByRole('button', { name: /save requirements/i }).click();
|
|
||||||
await settle(page, 1500);
|
|
||||||
|
|
||||||
const unit2Id = await createBareUnit(page, UNIT2_TITLE);
|
|
||||||
await addQuizWithQuestion(page, unit2Id, 'Sequential Quiz Unit 2 question?');
|
|
||||||
await page.goto(`${APP_URL}/admin/units/${unit2Id}/edit`, { waitUntil: 'networkidle' });
|
|
||||||
await settle(page);
|
|
||||||
await addRequirement(page, /pass the quiz/i);
|
|
||||||
await page.getByRole('button', { name: /save requirements/i }).click();
|
|
||||||
await settle(page, 1500);
|
|
||||||
|
|
||||||
// Standalone lesson attached to two units, for the cross-unit progress check.
|
|
||||||
await page.goto(`${APP_URL}/admin/lessons/add`, { waitUntil: 'networkidle' });
|
|
||||||
await settle(page);
|
|
||||||
await page.locator('#title').fill(CROSS_LESSON_TITLE);
|
|
||||||
await page.waitForTimeout(300);
|
|
||||||
await clickNextUntil(page, /^Page Builder$/);
|
|
||||||
// REAL UI DRIFT (2026-08-25): Page Builder is now opened via its own
|
|
||||||
// "Open Page Builder" button before the block toolbar is reachable.
|
|
||||||
await page.getByRole('button', { name: /open page builder/i }).click();
|
|
||||||
await page.waitForTimeout(500);
|
|
||||||
await page.getByRole('button', { name: /add block/i }).click();
|
|
||||||
await page.waitForTimeout(300);
|
|
||||||
await page.locator('[role="menu"]').getByText('Text', { exact: true }).click();
|
|
||||||
await page.waitForTimeout(400);
|
|
||||||
const editor = page.locator('[contenteditable="true"]').first();
|
|
||||||
await editor.click();
|
|
||||||
await editor.type('Cross-unit reading-progress test content. Scroll to the bottom to complete.');
|
|
||||||
await page.waitForTimeout(300);
|
|
||||||
// The block editor lives inside a Drawer (StepPageBuilder in
|
|
||||||
// AddLibraryLesson.jsx) — "Done" just closes it (form state is already
|
|
||||||
// updated live via setValue as you type), but the wizard's own Next
|
|
||||||
// button is unreachable while the drawer is open.
|
|
||||||
await page.getByRole('button', { name: /^done$/i }).click();
|
|
||||||
await page.waitForTimeout(300);
|
|
||||||
await clickNextUntil(page, /^Requirements$/);
|
|
||||||
await clickNextUntil(page, /^Review$/);
|
|
||||||
await page.getByRole('button', { name: /^create lesson$/i }).click();
|
|
||||||
await settle(page, 1800);
|
|
||||||
|
|
||||||
const crossUnitAId = await createBareUnit(page, CROSS_UNIT_A_TITLE);
|
|
||||||
const crossUnitBId = await createBareUnit(page, CROSS_UNIT_B_TITLE);
|
|
||||||
for (const uid of [crossUnitAId, crossUnitBId]) {
|
|
||||||
await page.goto(`${APP_URL}/admin/units/${uid}/view`, { waitUntil: 'networkidle' });
|
|
||||||
await settle(page);
|
|
||||||
await page.getByRole('button', { name: /attach existing/i }).click();
|
|
||||||
await page.waitForTimeout(600);
|
|
||||||
await page.locator('input[placeholder="Search lessons..."]').fill(CROSS_LESSON_TITLE);
|
|
||||||
await page.waitForTimeout(500);
|
|
||||||
await page.getByText(CROSS_LESSON_TITLE).first().click();
|
|
||||||
await page.getByRole('button', { name: /^attach/i }).click();
|
|
||||||
await settle(page, 1600);
|
|
||||||
}
|
|
||||||
|
|
||||||
const { courseId } = await courseWizardHappyPath(page, COURSE_TITLE, COURSE_CODE);
|
|
||||||
await attachUnitToCourse(page, courseId, UNIT1_TITLE);
|
|
||||||
await attachUnitToCourse(page, courseId, UNIT2_TITLE);
|
|
||||||
|
|
||||||
const { courseId: lockedCourseId, pickedPaidTier } = await courseWizardHappyPath(
|
|
||||||
page, LOCKED_COURSE_TITLE, LOCKED_COURSE_CODE, { pickPaidTier: true },
|
|
||||||
);
|
|
||||||
await attachUnitToCourse(page, lockedCourseId, LOCKED_UNIT_TITLE);
|
|
||||||
|
|
||||||
// Best-effort scrape of the cross-unit lesson's uuid for the permalink test.
|
|
||||||
await page.goto(`${APP_URL}/admin/lessons`, { waitUntil: 'networkidle' });
|
|
||||||
await settle(page);
|
|
||||||
const crossLessonRow = page.locator('table tbody tr', { hasText: CROSS_LESSON_TITLE }).first();
|
|
||||||
await crossLessonRow.locator('button').last().click();
|
|
||||||
await page.waitForTimeout(500);
|
|
||||||
await page.getByText(/^view info$/i).click();
|
|
||||||
await page.waitForURL('**/lessons/**', { timeout: 10000 });
|
|
||||||
await settle(page, 1000);
|
|
||||||
const lessonUuid = await page.evaluate(() => {
|
|
||||||
const m = document.body.innerHTML.match(/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/i);
|
|
||||||
return m ? m[0] : null;
|
|
||||||
});
|
|
||||||
|
|
||||||
shared = { courseId, lockedCourseId, pickedPaidTier, lessonUuid };
|
|
||||||
({ refreshToken: clientRefreshToken } = await generateClientSession(USERS.seedClient.email));
|
|
||||||
|
|
||||||
await context.close();
|
|
||||||
});
|
|
||||||
|
|
||||||
test.afterAll(async () => {
|
|
||||||
const removed = await cleanupQaTestFixtures();
|
|
||||||
console.log('QA-TEST fixtures removed:', removed);
|
|
||||||
});
|
|
||||||
|
|
||||||
test.beforeEach(async ({ context }) => {
|
|
||||||
await context.addCookies(buildCookies(clientRefreshToken));
|
|
||||||
});
|
|
||||||
|
|
||||||
test('TC-UNT-021 / TC-UNT-024: unit with zero course attachments is open to any learner', async ({ page }) => {
|
|
||||||
await page.goto(`${APP_URL}/units`, { waitUntil: 'networkidle' });
|
|
||||||
await settle(page);
|
|
||||||
const openCard = page.getByText(OPEN_UNIT_TITLE).first();
|
|
||||||
await openCard.waitFor({ state: 'visible', timeout: 10000 });
|
|
||||||
await openCard.click();
|
|
||||||
await settle(page);
|
|
||||||
expect(page.url()).toContain('/units/');
|
|
||||||
expect(page.url().endsWith('/units')).toBe(false);
|
|
||||||
await expect(page.locator('[role="dialog"]')).toHaveCount(0);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('TC-UNT-022: locked unit shows upsell modal listing the gating course', async ({ page }) => {
|
|
||||||
test.skip(!shared.pickedPaidTier, 'No paid/premium tier available in this environment\'s tier catalog to gate the course with — same environment limitation the original script hit.');
|
|
||||||
await page.goto(`${APP_URL}/units`, { waitUntil: 'networkidle' });
|
|
||||||
await settle(page);
|
|
||||||
const lockedCard = page.getByText(LOCKED_UNIT_TITLE).first();
|
|
||||||
await lockedCard.waitFor({ state: 'visible', timeout: 10000 });
|
|
||||||
await lockedCard.click();
|
|
||||||
await settle(page);
|
|
||||||
await expect(page.locator('[role="dialog"]')).toHaveCount(1);
|
|
||||||
await expect(page.getByText(LOCKED_COURSE_TITLE)).toBeVisible();
|
|
||||||
expect(page.url().endsWith('/units')).toBe(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('TC-UNT-023: unit reader reachable via grid -> detail -> read', async ({ page }) => {
|
|
||||||
await page.goto(`${APP_URL}/units`, { waitUntil: 'networkidle' });
|
|
||||||
await settle(page);
|
|
||||||
await page.getByText(OPEN_UNIT_TITLE).first().click();
|
|
||||||
await settle(page);
|
|
||||||
expect(page.url()).toContain('/units/');
|
|
||||||
await page.getByRole('button', { name: /start|read|continue/i }).first().click();
|
|
||||||
await settle(page);
|
|
||||||
expect(page.url()).toContain('/read');
|
|
||||||
});
|
|
||||||
|
|
||||||
test('TC-LSN-013: lessons have no top-level browse page', async ({ page }) => {
|
|
||||||
const navHasLessonsLink = await page.locator('nav a, header a').filter({ hasText: /^lessons$/i }).count();
|
|
||||||
expect(navHasLessonsLink).toBe(0);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('TC-LSN-012: direct navigation to /lessons/:uuid permalink resolves content', async ({ page }) => {
|
|
||||||
test.skip(!shared.lessonUuid, 'Could not scrape a lesson uuid from the admin View Info page.');
|
|
||||||
await page.goto(`${APP_URL}/lessons/${shared.lessonUuid}`, { waitUntil: 'networkidle' });
|
|
||||||
await settle(page);
|
|
||||||
await expect(page.getByText(CROSS_LESSON_TITLE)).toBeVisible();
|
|
||||||
});
|
|
||||||
|
|
||||||
test('TC-LSN-014: cross-unit reading-progress completion (user_id+lesson_id only)', async ({ page }) => {
|
|
||||||
await page.goto(`${APP_URL}/units`, { waitUntil: 'networkidle' });
|
|
||||||
await settle(page);
|
|
||||||
const unitACard = page.getByText(CROSS_UNIT_A_TITLE).first();
|
|
||||||
await unitACard.waitFor({ state: 'visible', timeout: 10000 });
|
|
||||||
await unitACard.click();
|
|
||||||
await settle(page);
|
|
||||||
const startBtnA = page.getByRole('button', { name: /start|read|continue/i }).first();
|
|
||||||
if (await startBtnA.count()) {
|
|
||||||
await startBtnA.click();
|
|
||||||
await settle(page);
|
|
||||||
await page.evaluate(() => window.scrollTo(0, document.body.scrollHeight));
|
|
||||||
await page.waitForTimeout(1200);
|
|
||||||
await page.evaluate(() => window.scrollTo(0, document.body.scrollHeight));
|
|
||||||
await page.waitForTimeout(1800);
|
|
||||||
}
|
|
||||||
|
|
||||||
await page.goto(`${APP_URL}/units`, { waitUntil: 'networkidle' });
|
|
||||||
await settle(page);
|
|
||||||
const unitBCard = page.getByText(CROSS_UNIT_B_TITLE).first();
|
|
||||||
await unitBCard.click();
|
|
||||||
await settle(page);
|
|
||||||
let completed = await page.getByText(/completed/i).count() > 0;
|
|
||||||
if (!completed) {
|
|
||||||
const startBtnB = page.getByRole('button', { name: /start|read|continue/i }).first();
|
|
||||||
if (await startBtnB.count()) {
|
|
||||||
await startBtnB.click();
|
|
||||||
await settle(page);
|
|
||||||
completed = await page.getByText(/completed/i).count() > 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
expect(completed).toBe(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('TC-UNT-020: quiz sequential lock blocks unit 2 before unit 1 is passed', async ({ page }) => {
|
|
||||||
await page.goto(`${APP_URL}/course/${shared.courseId}/unit`, { waitUntil: 'networkidle' });
|
|
||||||
await settle(page);
|
|
||||||
await page.getByText(UNIT2_TITLE).first().click();
|
|
||||||
await settle(page);
|
|
||||||
const quizTab = page.getByText(/quiz/i).first();
|
|
||||||
if (await quizTab.count()) { await quizTab.click(); await settle(page); }
|
|
||||||
await expect(page.getByText(/complete previous quiz|complete previous quizzes first/i)).toBeVisible();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@@ -4,6 +4,7 @@
|
|||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8" />
|
||||||
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
|
<meta name="referrer" content="no-referrer">
|
||||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||||
<link
|
<link
|
||||||
|
|||||||
@@ -10,6 +10,16 @@ server {
|
|||||||
try_files $uri $uri/ /index.html;
|
try_files $uri $uri/ /index.html;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# pdfjs-dist ships its worker as an ES module. Firefox rejects a module
|
||||||
|
# worker when nginx falls back to application/octet-stream for .mjs.
|
||||||
|
location ~* \.mjs$ {
|
||||||
|
types {
|
||||||
|
application/javascript mjs;
|
||||||
|
}
|
||||||
|
expires 1y;
|
||||||
|
add_header Cache-Control "public, immutable";
|
||||||
|
}
|
||||||
|
|
||||||
# Cache hashed assets aggressively
|
# Cache hashed assets aggressively
|
||||||
location ~* \.(js|css|woff2?|ttf|svg|ico|png|jpg|jpeg|webp|gif)$ {
|
location ~* \.(js|css|woff2?|ttf|svg|ico|png|jpg|jpeg|webp|gif)$ {
|
||||||
expires 1y;
|
expires 1y;
|
||||||
|
|||||||
+36
-36
@@ -10,61 +10,61 @@
|
|||||||
"preview": "vite preview"
|
"preview": "vite preview"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@base-ui/react": "^1.4.1",
|
"@base-ui/react": "^1.9.0",
|
||||||
"@fontsource-variable/geist": "^5.2.8",
|
"@fontsource-variable/geist": "^5.3.0",
|
||||||
"@hookform/resolvers": "^5.2.2",
|
"@hookform/resolvers": "^5.9.2",
|
||||||
"@radix-ui/react-tabs": "^1.1.13",
|
"@radix-ui/react-tabs": "^1.2.1",
|
||||||
"@tailwindcss/vite": "^4.2.4",
|
"@tailwindcss/vite": "^4.3.3",
|
||||||
"@tanstack/react-table": "^8.21.3",
|
"@tanstack/react-table": "^8.21.3",
|
||||||
"@tauri-apps/api": "^2.11.0",
|
"@tauri-apps/api": "^2.12.4",
|
||||||
"axios": "^1.16.0",
|
"axios": "^1.21.0",
|
||||||
"class-variance-authority": "^0.7.1",
|
"class-variance-authority": "^0.7.1",
|
||||||
"clsx": "^2.1.1",
|
"clsx": "^2.1.1",
|
||||||
"cmdk": "^1.1.1",
|
"cmdk": "^1.1.1",
|
||||||
"date-fns": "^4.1.0",
|
"date-fns": "^4.4.0",
|
||||||
"embla-carousel-react": "^8.6.0",
|
"embla-carousel-react": "^8.6.0",
|
||||||
"framer-motion": "^12.38.0",
|
"framer-motion": "^12.43.0",
|
||||||
"input-otp": "^1.4.2",
|
"input-otp": "^1.5.0",
|
||||||
"lucide-react": "^1.14.0",
|
"lucide-react": "^1.62.0",
|
||||||
"nanoid": "^5.1.11",
|
"nanoid": "^5.1.16",
|
||||||
"next-themes": "^0.4.6",
|
"next-themes": "^0.4.6",
|
||||||
"pdfjs-dist": "^6.0.227",
|
"pdfjs-dist": "^6.4.299",
|
||||||
"qrcode.react": "^4.2.0",
|
"qrcode.react": "^4.2.0",
|
||||||
"radix-ui": "^1.4.3",
|
"radix-ui": "^1.8.1",
|
||||||
"react": "^19.2.5",
|
"react": "^19.3.1",
|
||||||
"react-day-picker": "^9.14.0",
|
"react-day-picker": "^9.14.0",
|
||||||
"react-dom": "^19.2.5",
|
"react-dom": "^19.3.1",
|
||||||
"react-easy-crop": "^6.0.2",
|
"react-easy-crop": "^6.2.4",
|
||||||
"react-helmet-async": "^3.0.0",
|
"react-helmet-async": "^3.0.0",
|
||||||
"react-hook-form": "^7.75.0",
|
"react-hook-form": "^7.91.0",
|
||||||
"react-icons": "^5.6.0",
|
"react-icons": "^5.7.0",
|
||||||
"react-markdown": "^10.1.0",
|
"react-markdown": "^10.1.0",
|
||||||
"react-phone-number-input": "^3.4.17",
|
"react-phone-number-input": "^3.4.18",
|
||||||
"react-photo-view": "^1.2.7",
|
"react-photo-view": "^1.2.7",
|
||||||
"react-resizable-panels": "^4.11.0",
|
"react-resizable-panels": "^4.15.0",
|
||||||
"react-router-dom": "^7.14.2",
|
"react-router-dom": "^7.18.4",
|
||||||
"recharts": "3.8.0",
|
"recharts": "3.8.0",
|
||||||
"remark-gfm": "^4.0.1",
|
"remark-gfm": "^4.0.1",
|
||||||
"shadcn": "^4.6.0",
|
"shadcn": "^4.23.0",
|
||||||
"sonner": "^2.0.7",
|
"sonner": "^2.0.8",
|
||||||
"tailwind-merge": "^3.5.0",
|
"tailwind-merge": "^3.7.0",
|
||||||
"tw-animate-css": "^1.4.0",
|
"tw-animate-css": "^1.4.0",
|
||||||
"vaul": "^1.1.2",
|
"vaul": "^1.1.2",
|
||||||
"xlsx-js-style": "^1.2.0",
|
"xlsx-js-style": "^1.2.0",
|
||||||
"zod": "^4.4.3"
|
"zod": "^4.6.7"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@eslint/js": "^10.0.1",
|
"@eslint/js": "^10.0.1",
|
||||||
"@types/react": "^19.2.14",
|
"@types/react": "^19.3.0",
|
||||||
"@types/react-dom": "^19.2.3",
|
"@types/react-dom": "^19.3.0",
|
||||||
"@vitejs/plugin-react": "^6.0.1",
|
"@vitejs/plugin-react": "^6.1.2",
|
||||||
"autoprefixer": "^10.5.0",
|
"autoprefixer": "^10.6.2",
|
||||||
"eslint": "^10.2.1",
|
"eslint": "^10.13.0",
|
||||||
"eslint-plugin-react-hooks": "^7.1.1",
|
"eslint-plugin-react-hooks": "^7.1.1",
|
||||||
"eslint-plugin-react-refresh": "^0.5.2",
|
"eslint-plugin-react-refresh": "^0.5.7",
|
||||||
"globals": "^17.5.0",
|
"globals": "^17.13.0",
|
||||||
"postcss": "^8.5.13",
|
"postcss": "^8.5.32",
|
||||||
"tailwindcss": "^4.2.4",
|
"tailwindcss": "^4.3.3",
|
||||||
"vite": "^8.0.10"
|
"vite": "^8.3.5"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -38,6 +38,7 @@ export function DashboardSection({
|
|||||||
iconMap = {},
|
iconMap = {},
|
||||||
linkMap = {},
|
linkMap = {},
|
||||||
chartLinkMap = {},
|
chartLinkMap = {},
|
||||||
|
chartHeight = 240,
|
||||||
className = "",
|
className = "",
|
||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
@@ -57,6 +58,8 @@ export function DashboardSection({
|
|||||||
label={b.label}
|
label={b.label}
|
||||||
data={b.data}
|
data={b.data}
|
||||||
onBarClick={chartLinkMap[b.key]}
|
onBarClick={chartLinkMap[b.key]}
|
||||||
|
height={b.height ?? chartHeight}
|
||||||
|
yAxisWidth={b.yAxisWidth}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<PieBreakdown
|
<PieBreakdown
|
||||||
@@ -64,6 +67,7 @@ export function DashboardSection({
|
|||||||
label={b.label}
|
label={b.label}
|
||||||
data={b.data}
|
data={b.data}
|
||||||
onSliceClick={chartLinkMap[b.key]}
|
onSliceClick={chartLinkMap[b.key]}
|
||||||
|
height={b.height ?? chartHeight}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ export function TableDashboard({
|
|||||||
breakdowns = [],
|
breakdowns = [],
|
||||||
statMap = {},
|
statMap = {},
|
||||||
tableRefsRef, // ← remove activeFilters prop entirely
|
tableRefsRef, // ← remove activeFilters prop entirely
|
||||||
|
chartHeight = 240,
|
||||||
className = "",
|
className = "",
|
||||||
}) {
|
}) {
|
||||||
// ─── Always read live from ref ────────────────────────────────────────────
|
// ─── Always read live from ref ────────────────────────────────────────────
|
||||||
@@ -124,6 +125,7 @@ export function TableDashboard({
|
|||||||
label={b.label}
|
label={b.label}
|
||||||
data={b.data}
|
data={b.data}
|
||||||
onBarClick={b.filterId ? (entry) => handleChartClick(b, entry) : undefined}
|
onBarClick={b.filterId ? (entry) => handleChartClick(b, entry) : undefined}
|
||||||
|
height={b.height ?? chartHeight}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<PieBreakdown
|
<PieBreakdown
|
||||||
@@ -131,6 +133,7 @@ export function TableDashboard({
|
|||||||
label={b.label}
|
label={b.label}
|
||||||
data={b.data}
|
data={b.data}
|
||||||
onSliceClick={b.filterId ? (entry) => handleChartClick(b, entry) : undefined}
|
onSliceClick={b.filterId ? (entry) => handleChartClick(b, entry) : undefined}
|
||||||
|
height={b.height ?? chartHeight}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -155,6 +155,7 @@ export default function UsersTable() {
|
|||||||
breakdowns={dashboardBreakdowns}
|
breakdowns={dashboardBreakdowns}
|
||||||
statMap={USER_STAT_MAP}
|
statMap={USER_STAT_MAP}
|
||||||
tableRefsRef={tableRefsRef}
|
tableRefsRef={tableRefsRef}
|
||||||
|
chartHeight={320}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ export default function ViewUser() {
|
|||||||
fetchUserAchievements(userId);
|
fetchUserAchievements(userId);
|
||||||
fetchUserActivity(userId, { page: 1, limit: 10 });
|
fetchUserActivity(userId, { page: 1, limit: 10 });
|
||||||
fetchUserBans(userId);
|
fetchUserBans(userId);
|
||||||
|
window.scrollTo(0, 0);
|
||||||
}, [userId]);
|
}, [userId]);
|
||||||
|
|
||||||
const loadActivityPage = (p) => {
|
const loadActivityPage = (p) => {
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ export const LessonCard = ({ lesson, tierMap = {}, onViewDetails }) => {
|
|||||||
const unitCount = Number(lesson.unit_count ?? 0);
|
const unitCount = Number(lesson.unit_count ?? 0);
|
||||||
const courses = lesson.courses ?? [];
|
const courses = lesson.courses ?? [];
|
||||||
const slug = cheapestTierSlug(courses.map((c) => c.subscription), tierMap);
|
const slug = cheapestTierSlug(courses.map((c) => c.subscription), tierMap);
|
||||||
const { label, cls } = resolveTierBadge(slug, tierMap);
|
const { label, cls, panel } = resolveTierBadge(slug, tierMap);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
@@ -32,7 +32,7 @@ export const LessonCard = ({ lesson, tierMap = {}, onViewDetails }) => {
|
|||||||
"bg-card rounded-2xl border p-4 flex flex-col gap-2.5 transition-all cursor-pointer group",
|
"bg-card rounded-2xl border p-4 flex flex-col gap-2.5 transition-all cursor-pointer group",
|
||||||
"hover:shadow-sm",
|
"hover:shadow-sm",
|
||||||
locked
|
locked
|
||||||
? "opacity-80 hover:opacity-100 hover:border-muted-foreground/40"
|
? cn("opacity-80 hover:opacity-100", panel.bg, panel.border)
|
||||||
: "hover:bg-muted/60 dark:hover:border-blue-500"
|
: "hover:bg-muted/60 dark:hover:border-blue-500"
|
||||||
)}
|
)}
|
||||||
onClick={() => onViewDetails(lesson)}
|
onClick={() => onViewDetails(lesson)}
|
||||||
@@ -43,7 +43,7 @@ export const LessonCard = ({ lesson, tierMap = {}, onViewDetails }) => {
|
|||||||
{label}
|
{label}
|
||||||
</Badge>
|
</Badge>
|
||||||
{locked && (
|
{locked && (
|
||||||
<Badge variant="secondary">
|
<Badge variant="secondary" className="bg-white dark:bg-white/15 dark:text-white dark:border-white/15">
|
||||||
<LockIcon className="size-3" /> Locked
|
<LockIcon className="size-3" /> Locked
|
||||||
</Badge>
|
</Badge>
|
||||||
)}
|
)}
|
||||||
@@ -53,11 +53,9 @@ export const LessonCard = ({ lesson, tierMap = {}, onViewDetails }) => {
|
|||||||
<h1 className="text-lg font-medium leading-snug line-clamp-3 transition-colors group-hover:text-blue-700 dark:group-hover:text-blue-400">
|
<h1 className="text-lg font-medium leading-snug line-clamp-3 transition-colors group-hover:text-blue-700 dark:group-hover:text-blue-400">
|
||||||
{lesson.title}
|
{lesson.title}
|
||||||
</h1>
|
</h1>
|
||||||
{lesson.description && (
|
<p className="text-sm leading-relaxed line-clamp-2 text-muted-foreground">
|
||||||
<p className="text-sm leading-relaxed line-clamp-2 group-hover:text-blue-700 dark:group-hover:text-blue-400">
|
{lesson.description || "No information yet provided"}
|
||||||
{lesson.description}
|
</p>
|
||||||
</p>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="flex items-center justify-between pt-2 mt-auto border-t">
|
<div className="flex items-center justify-between pt-2 mt-auto border-t">
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ export const UnitCard = ({ unit, tierMap = {}, onViewDetails }) => {
|
|||||||
const lessonCount = Number(unit.lesson_count ?? 0);
|
const lessonCount = Number(unit.lesson_count ?? 0);
|
||||||
const courses = unit.courses ?? [];
|
const courses = unit.courses ?? [];
|
||||||
const slug = cheapestTierSlug([unit.subscription, ...courses.map((c) => c.subscription)], tierMap);
|
const slug = cheapestTierSlug([unit.subscription, ...courses.map((c) => c.subscription)], tierMap);
|
||||||
const { label, cls } = resolveTierBadge(slug, tierMap);
|
const { label, cls, panel } = resolveTierBadge(slug, tierMap);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
@@ -30,7 +30,7 @@ export const UnitCard = ({ unit, tierMap = {}, onViewDetails }) => {
|
|||||||
"bg-card rounded-2xl border p-4 flex flex-col gap-2.5 transition-all cursor-pointer group",
|
"bg-card rounded-2xl border p-4 flex flex-col gap-2.5 transition-all cursor-pointer group",
|
||||||
"hover:shadow-sm",
|
"hover:shadow-sm",
|
||||||
locked
|
locked
|
||||||
? "opacity-80 hover:opacity-100 hover:border-muted-foreground/40"
|
? cn("opacity-80 hover:opacity-100", panel.bg, panel.border)
|
||||||
: "hover:bg-muted/60 dark:hover:border-blue-500"
|
: "hover:bg-muted/60 dark:hover:border-blue-500"
|
||||||
)}
|
)}
|
||||||
onClick={() => onViewDetails(unit)}
|
onClick={() => onViewDetails(unit)}
|
||||||
@@ -41,7 +41,7 @@ export const UnitCard = ({ unit, tierMap = {}, onViewDetails }) => {
|
|||||||
{label}
|
{label}
|
||||||
</Badge>
|
</Badge>
|
||||||
{locked && (
|
{locked && (
|
||||||
<Badge variant="secondary">
|
<Badge variant="secondary" className="bg-white dark:bg-white/15 dark:text-white dark:border-white/15">
|
||||||
<LockIcon className="size-3" /> Locked
|
<LockIcon className="size-3" /> Locked
|
||||||
</Badge>
|
</Badge>
|
||||||
)}
|
)}
|
||||||
@@ -51,11 +51,9 @@ export const UnitCard = ({ unit, tierMap = {}, onViewDetails }) => {
|
|||||||
<h1 className="text-lg font-medium leading-snug line-clamp-3 transition-colors group-hover:text-blue-700 dark:group-hover:text-blue-400">
|
<h1 className="text-lg font-medium leading-snug line-clamp-3 transition-colors group-hover:text-blue-700 dark:group-hover:text-blue-400">
|
||||||
{unit.title}
|
{unit.title}
|
||||||
</h1>
|
</h1>
|
||||||
{unit.description && (
|
<p className="text-sm leading-relaxed line-clamp-2 text-muted-foreground">
|
||||||
<p className="text-sm leading-relaxed line-clamp-2 group-hover:text-blue-700 dark:group-hover:text-blue-400">
|
{unit.description || "No information yet provided"}
|
||||||
{unit.description}
|
</p>
|
||||||
</p>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="flex items-center justify-between pt-2 mt-auto border-t">
|
<div className="flex items-center justify-between pt-2 mt-auto border-t">
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ const CourseCard = ({ course, tierMap, onViewDetails }) => {
|
|||||||
const slug = course.subscription ?? "free";
|
const slug = course.subscription ?? "free";
|
||||||
const locked = course.is_locked;
|
const locked = course.is_locked;
|
||||||
const duration = formatDuration(course.duration_seconds);
|
const duration = formatDuration(course.duration_seconds);
|
||||||
const { rank, label, cls } = resolveTierBadge(slug, tierMap);
|
const { rank, label, cls, panel } = resolveTierBadge(slug, tierMap);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
@@ -45,7 +45,7 @@ const CourseCard = ({ course, tierMap, onViewDetails }) => {
|
|||||||
"bg-card rounded-2xl border p-4 flex flex-col gap-2.5 transition-all cursor-pointer group",
|
"bg-card rounded-2xl border p-4 flex flex-col gap-2.5 transition-all cursor-pointer group",
|
||||||
"hover:shadow-sm",
|
"hover:shadow-sm",
|
||||||
locked
|
locked
|
||||||
? "opacity-80 hover:opacity-100 hover:border-muted-foreground/40"
|
? cn("opacity-80 hover:opacity-100", panel.bg, panel.border)
|
||||||
: "hover:bg-muted/60 dark:hover:border-blue-500"
|
: "hover:bg-muted/60 dark:hover:border-blue-500"
|
||||||
)}
|
)}
|
||||||
onClick={() => onViewDetails(course)}
|
onClick={() => onViewDetails(course)}
|
||||||
@@ -62,7 +62,7 @@ const CourseCard = ({ course, tierMap, onViewDetails }) => {
|
|||||||
<Badge key={cat.id} variant="outline"><Tags /> {cat.name}</Badge>
|
<Badge key={cat.id} variant="outline"><Tags /> {cat.name}</Badge>
|
||||||
))}
|
))}
|
||||||
{locked && (
|
{locked && (
|
||||||
<Badge variant="secondary">
|
<Badge variant="secondary" className="bg-white dark:bg-white/15 dark:text-white dark:border-white/15">
|
||||||
<LockIcon className="size-3" /> Locked
|
<LockIcon className="size-3" /> Locked
|
||||||
</Badge>
|
</Badge>
|
||||||
)}
|
)}
|
||||||
@@ -72,11 +72,9 @@ const CourseCard = ({ course, tierMap, onViewDetails }) => {
|
|||||||
<h1 className="text-lg font-medium leading-snug line-clamp-3 transition-colors group-hover:text-blue-700 dark:group-hover:text-blue-400">
|
<h1 className="text-lg font-medium leading-snug line-clamp-3 transition-colors group-hover:text-blue-700 dark:group-hover:text-blue-400">
|
||||||
{course.title}
|
{course.title}
|
||||||
</h1>
|
</h1>
|
||||||
{course.description && (
|
<p className="text-sm leading-relaxed line-clamp-2 text-muted-foreground">
|
||||||
<p className="text-sm leading-relaxed line-clamp-2 group-hover:text-blue-700 dark:group-hover:text-blue-400">
|
{course.description || "No information yet provided"}
|
||||||
{course.description}
|
</p>
|
||||||
</p>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="flex items-center justify-between pt-2 mt-auto border-t">
|
<div className="flex items-center justify-between pt-2 mt-auto border-t">
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ const CourseCard = ({ course, onViewDetails }) => {
|
|||||||
const slug = course.subscription ?? "free";
|
const slug = course.subscription ?? "free";
|
||||||
const locked = course.is_locked;
|
const locked = course.is_locked;
|
||||||
const duration = formatDuration(course.duration_seconds);
|
const duration = formatDuration(course.duration_seconds);
|
||||||
const { rank, label, cls } = resolveTierBadge(slug, tierMap);
|
const { rank, label, cls, panel } = resolveTierBadge(slug, tierMap);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
@@ -52,7 +52,7 @@ const CourseCard = ({ course, onViewDetails }) => {
|
|||||||
"bg-card rounded-2xl border p-4 flex flex-col gap-2.5 transition-all cursor-pointer group",
|
"bg-card rounded-2xl border p-4 flex flex-col gap-2.5 transition-all cursor-pointer group",
|
||||||
"hover:shadow-sm",
|
"hover:shadow-sm",
|
||||||
locked
|
locked
|
||||||
? "opacity-80 hover:opacity-100 hover:border-muted-foreground/40"
|
? cn("opacity-80 hover:opacity-100", panel.bg, panel.border)
|
||||||
: "hover:bg-muted/60 dark:hover:border-blue-500"
|
: "hover:bg-muted/60 dark:hover:border-blue-500"
|
||||||
)}
|
)}
|
||||||
onClick={() => onViewDetails(course)}
|
onClick={() => onViewDetails(course)}
|
||||||
@@ -68,7 +68,7 @@ const CourseCard = ({ course, onViewDetails }) => {
|
|||||||
</Badge>
|
</Badge>
|
||||||
)}
|
)}
|
||||||
{locked && (
|
{locked && (
|
||||||
<Badge variant="secondary" className="ml-auto">
|
<Badge variant="secondary" className="ml-auto bg-white dark:bg-white/15 dark:text-white dark:border-white/15">
|
||||||
<LockIcon className="size-3" /> Locked
|
<LockIcon className="size-3" /> Locked
|
||||||
</Badge>
|
</Badge>
|
||||||
)}
|
)}
|
||||||
@@ -78,11 +78,9 @@ const CourseCard = ({ course, onViewDetails }) => {
|
|||||||
<h1 className="text-lg font-medium leading-snug line-clamp-3 transition-colors group-hover:text-blue-700 dark:group-hover:text-blue-400">
|
<h1 className="text-lg font-medium leading-snug line-clamp-3 transition-colors group-hover:text-blue-700 dark:group-hover:text-blue-400">
|
||||||
{course.title}
|
{course.title}
|
||||||
</h1>
|
</h1>
|
||||||
{course.description && (
|
<p className="text-sm leading-relaxed line-clamp-2 text-muted-foreground">
|
||||||
<p className="text-sm leading-relaxed line-clamp-2 text-muted-foreground">
|
{course.description || "No information yet provided"}
|
||||||
{course.description}
|
</p>
|
||||||
</p>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="flex items-center justify-between pt-2 mt-auto border-t">
|
<div className="flex items-center justify-between pt-2 mt-auto border-t">
|
||||||
|
|||||||
@@ -11,73 +11,73 @@ export const TIER_COLOR_MAP = {
|
|||||||
label: "Green",
|
label: "Green",
|
||||||
swatch: "#22c55e",
|
swatch: "#22c55e",
|
||||||
badge: "bg-green-500 text-white border-0",
|
badge: "bg-green-500 text-white border-0",
|
||||||
panel: { bg: "bg-green-50 dark:bg-green-950/30", border: "border-green-200 dark:border-green-800" },
|
panel: { bg: "bg-green-50 dark:bg-green-500/15", border: "border-green-200 dark:border-green-500/40" },
|
||||||
},
|
},
|
||||||
purple: {
|
purple: {
|
||||||
label: "Purple",
|
label: "Purple",
|
||||||
swatch: "#a855f7",
|
swatch: "#a855f7",
|
||||||
badge: "bg-gradient-to-r from-fuchsia-600 to-purple-600 text-white border-0",
|
badge: "bg-gradient-to-r from-fuchsia-600 to-purple-600 text-white border-0",
|
||||||
panel: { bg: "bg-fuchsia-50 dark:bg-fuchsia-950/30", border: "border-fuchsia-200 dark:border-fuchsia-800" },
|
panel: { bg: "bg-fuchsia-50 dark:bg-fuchsia-500/15", border: "border-fuchsia-200 dark:border-fuchsia-500/40" },
|
||||||
},
|
},
|
||||||
rose: {
|
rose: {
|
||||||
label: "Rose",
|
label: "Rose",
|
||||||
swatch: "#f43f5e",
|
swatch: "#f43f5e",
|
||||||
badge: "bg-gradient-to-r from-rose-500 to-red-600 text-white border-0",
|
badge: "bg-gradient-to-r from-rose-500 to-red-600 text-white border-0",
|
||||||
panel: { bg: "bg-rose-50 dark:bg-rose-950/30", border: "border-rose-200 dark:border-rose-800" },
|
panel: { bg: "bg-rose-50 dark:bg-rose-500/15", border: "border-rose-200 dark:border-rose-500/40" },
|
||||||
},
|
},
|
||||||
amber: {
|
amber: {
|
||||||
label: "Amber",
|
label: "Amber",
|
||||||
swatch: "#f59e0b",
|
swatch: "#f59e0b",
|
||||||
badge: "bg-gradient-to-r from-amber-400 to-orange-500 text-white border-0",
|
badge: "bg-gradient-to-r from-amber-400 to-orange-500 text-white border-0",
|
||||||
panel: { bg: "bg-amber-50 dark:bg-amber-950/30", border: "border-amber-200 dark:border-amber-800" },
|
panel: { bg: "bg-amber-50 dark:bg-amber-500/15", border: "border-amber-200 dark:border-amber-500/40" },
|
||||||
},
|
},
|
||||||
sky: {
|
sky: {
|
||||||
label: "Sky",
|
label: "Sky",
|
||||||
swatch: "#0ea5e9",
|
swatch: "#0ea5e9",
|
||||||
badge: "bg-gradient-to-r from-sky-500 to-blue-600 text-white border-0",
|
badge: "bg-gradient-to-r from-sky-500 to-blue-600 text-white border-0",
|
||||||
panel: { bg: "bg-sky-50 dark:bg-sky-950/30", border: "border-sky-200 dark:border-sky-800" },
|
panel: { bg: "bg-sky-50 dark:bg-sky-500/15", border: "border-sky-200 dark:border-sky-500/40" },
|
||||||
},
|
},
|
||||||
indigo: {
|
indigo: {
|
||||||
label: "Indigo",
|
label: "Indigo",
|
||||||
swatch: "#6366f1",
|
swatch: "#6366f1",
|
||||||
badge: "bg-gradient-to-r from-indigo-500 to-violet-600 text-white border-0",
|
badge: "bg-gradient-to-r from-indigo-500 to-violet-600 text-white border-0",
|
||||||
panel: { bg: "bg-indigo-50 dark:bg-indigo-950/30", border: "border-indigo-200 dark:border-indigo-800" },
|
panel: { bg: "bg-indigo-50 dark:bg-indigo-500/15", border: "border-indigo-200 dark:border-indigo-500/40" },
|
||||||
},
|
},
|
||||||
teal: {
|
teal: {
|
||||||
label: "Teal",
|
label: "Teal",
|
||||||
swatch: "#14b8a6",
|
swatch: "#14b8a6",
|
||||||
badge: "bg-gradient-to-r from-teal-500 to-emerald-600 text-white border-0",
|
badge: "bg-gradient-to-r from-teal-500 to-emerald-600 text-white border-0",
|
||||||
panel: { bg: "bg-teal-50 dark:bg-teal-950/30", border: "border-teal-200 dark:border-teal-800" },
|
panel: { bg: "bg-teal-50 dark:bg-teal-500/15", border: "border-teal-200 dark:border-teal-500/40" },
|
||||||
},
|
},
|
||||||
orange: {
|
orange: {
|
||||||
label: "Orange",
|
label: "Orange",
|
||||||
swatch: "#f97316",
|
swatch: "#f97316",
|
||||||
badge: "bg-gradient-to-r from-orange-500 to-red-500 text-white border-0",
|
badge: "bg-gradient-to-r from-orange-500 to-red-500 text-white border-0",
|
||||||
panel: { bg: "bg-orange-50 dark:bg-orange-950/30", border: "border-orange-200 dark:border-orange-800" },
|
panel: { bg: "bg-orange-50 dark:bg-orange-500/15", border: "border-orange-200 dark:border-orange-500/40" },
|
||||||
},
|
},
|
||||||
pink: {
|
pink: {
|
||||||
label: "Pink",
|
label: "Pink",
|
||||||
swatch: "#ec4899",
|
swatch: "#ec4899",
|
||||||
badge: "bg-gradient-to-r from-pink-500 to-rose-500 text-white border-0",
|
badge: "bg-gradient-to-r from-pink-500 to-rose-500 text-white border-0",
|
||||||
panel: { bg: "bg-pink-50 dark:bg-pink-950/30", border: "border-pink-200 dark:border-pink-800" },
|
panel: { bg: "bg-pink-50 dark:bg-pink-500/15", border: "border-pink-200 dark:border-pink-500/40" },
|
||||||
},
|
},
|
||||||
cyan: {
|
cyan: {
|
||||||
label: "Cyan",
|
label: "Cyan",
|
||||||
swatch: "#06b6d4",
|
swatch: "#06b6d4",
|
||||||
badge: "bg-gradient-to-r from-cyan-500 to-sky-500 text-white border-0",
|
badge: "bg-gradient-to-r from-cyan-500 to-sky-500 text-white border-0",
|
||||||
panel: { bg: "bg-cyan-50 dark:bg-cyan-950/30", border: "border-cyan-200 dark:border-cyan-800" },
|
panel: { bg: "bg-cyan-50 dark:bg-cyan-500/15", border: "border-cyan-200 dark:border-cyan-500/40" },
|
||||||
},
|
},
|
||||||
lime: {
|
lime: {
|
||||||
label: "Lime",
|
label: "Lime",
|
||||||
swatch: "#84cc16",
|
swatch: "#84cc16",
|
||||||
badge: "bg-gradient-to-r from-lime-500 to-green-600 text-white border-0",
|
badge: "bg-gradient-to-r from-lime-500 to-green-600 text-white border-0",
|
||||||
panel: { bg: "bg-lime-50 dark:bg-lime-950/30", border: "border-lime-200 dark:border-lime-800" },
|
panel: { bg: "bg-lime-50 dark:bg-lime-500/15", border: "border-lime-200 dark:border-lime-500/40" },
|
||||||
},
|
},
|
||||||
slate: {
|
slate: {
|
||||||
label: "Slate",
|
label: "Slate",
|
||||||
swatch: "#64748b",
|
swatch: "#64748b",
|
||||||
badge: "bg-gradient-to-r from-slate-600 to-slate-800 text-white border-0",
|
badge: "bg-gradient-to-r from-slate-600 to-slate-800 text-white border-0",
|
||||||
panel: { bg: "bg-slate-50 dark:bg-slate-950/30", border: "border-slate-200 dark:border-slate-700" },
|
panel: { bg: "bg-slate-50 dark:bg-slate-500/15", border: "border-slate-200 dark:border-slate-500/40" },
|
||||||
},
|
},
|
||||||
|
|
||||||
// ── Extended palette (18 more → 30 total) ───────────────────────────────────
|
// ── Extended palette (18 more → 30 total) ───────────────────────────────────
|
||||||
@@ -85,109 +85,109 @@ export const TIER_COLOR_MAP = {
|
|||||||
label: "Red",
|
label: "Red",
|
||||||
swatch: "#ef4444",
|
swatch: "#ef4444",
|
||||||
badge: "bg-gradient-to-r from-red-500 to-red-700 text-white border-0",
|
badge: "bg-gradient-to-r from-red-500 to-red-700 text-white border-0",
|
||||||
panel: { bg: "bg-red-50 dark:bg-red-950/30", border: "border-red-200 dark:border-red-800" },
|
panel: { bg: "bg-red-50 dark:bg-red-500/15", border: "border-red-200 dark:border-red-500/40" },
|
||||||
},
|
},
|
||||||
yellow: {
|
yellow: {
|
||||||
label: "Yellow",
|
label: "Yellow",
|
||||||
swatch: "#eab308",
|
swatch: "#eab308",
|
||||||
badge: "bg-gradient-to-r from-yellow-400 to-yellow-600 text-white border-0",
|
badge: "bg-gradient-to-r from-yellow-400 to-yellow-600 text-white border-0",
|
||||||
panel: { bg: "bg-yellow-50 dark:bg-yellow-950/30", border: "border-yellow-200 dark:border-yellow-800" },
|
panel: { bg: "bg-yellow-50 dark:bg-yellow-500/15", border: "border-yellow-200 dark:border-yellow-500/40" },
|
||||||
},
|
},
|
||||||
violet: {
|
violet: {
|
||||||
label: "Violet",
|
label: "Violet",
|
||||||
swatch: "#7c3aed",
|
swatch: "#7c3aed",
|
||||||
badge: "bg-gradient-to-r from-violet-500 to-purple-700 text-white border-0",
|
badge: "bg-gradient-to-r from-violet-500 to-purple-700 text-white border-0",
|
||||||
panel: { bg: "bg-violet-50 dark:bg-violet-950/30", border: "border-violet-200 dark:border-violet-800" },
|
panel: { bg: "bg-violet-50 dark:bg-violet-500/15", border: "border-violet-200 dark:border-violet-500/40" },
|
||||||
},
|
},
|
||||||
fuchsia: {
|
fuchsia: {
|
||||||
label: "Fuchsia",
|
label: "Fuchsia",
|
||||||
swatch: "#d946ef",
|
swatch: "#d946ef",
|
||||||
badge: "bg-gradient-to-r from-fuchsia-500 to-pink-700 text-white border-0",
|
badge: "bg-gradient-to-r from-fuchsia-500 to-pink-700 text-white border-0",
|
||||||
panel: { bg: "bg-fuchsia-50 dark:bg-fuchsia-950/30", border: "border-fuchsia-200 dark:border-fuchsia-800" },
|
panel: { bg: "bg-fuchsia-50 dark:bg-fuchsia-500/15", border: "border-fuchsia-200 dark:border-fuchsia-500/40" },
|
||||||
},
|
},
|
||||||
emerald: {
|
emerald: {
|
||||||
label: "Emerald",
|
label: "Emerald",
|
||||||
swatch: "#10b981",
|
swatch: "#10b981",
|
||||||
badge: "bg-gradient-to-r from-emerald-400 to-emerald-700 text-white border-0",
|
badge: "bg-gradient-to-r from-emerald-400 to-emerald-700 text-white border-0",
|
||||||
panel: { bg: "bg-emerald-50 dark:bg-emerald-950/30", border: "border-emerald-200 dark:border-emerald-800" },
|
panel: { bg: "bg-emerald-50 dark:bg-emerald-500/15", border: "border-emerald-200 dark:border-emerald-500/40" },
|
||||||
},
|
},
|
||||||
blue: {
|
blue: {
|
||||||
label: "Blue",
|
label: "Blue",
|
||||||
swatch: "#3b82f6",
|
swatch: "#3b82f6",
|
||||||
badge: "bg-gradient-to-r from-blue-500 to-blue-700 text-white border-0",
|
badge: "bg-gradient-to-r from-blue-500 to-blue-700 text-white border-0",
|
||||||
panel: { bg: "bg-blue-50 dark:bg-blue-950/30", border: "border-blue-200 dark:border-blue-800" },
|
panel: { bg: "bg-blue-50 dark:bg-blue-500/15", border: "border-blue-200 dark:border-blue-500/40" },
|
||||||
},
|
},
|
||||||
zinc: {
|
zinc: {
|
||||||
label: "Zinc",
|
label: "Zinc",
|
||||||
swatch: "#71717a",
|
swatch: "#71717a",
|
||||||
badge: "bg-gradient-to-r from-zinc-500 to-zinc-700 text-white border-0",
|
badge: "bg-gradient-to-r from-zinc-500 to-zinc-700 text-white border-0",
|
||||||
panel: { bg: "bg-zinc-50 dark:bg-zinc-950/30", border: "border-zinc-200 dark:border-zinc-800" },
|
panel: { bg: "bg-zinc-50 dark:bg-zinc-500/15", border: "border-zinc-200 dark:border-zinc-500/40" },
|
||||||
},
|
},
|
||||||
stone: {
|
stone: {
|
||||||
label: "Stone",
|
label: "Stone",
|
||||||
swatch: "#78716c",
|
swatch: "#78716c",
|
||||||
badge: "bg-gradient-to-r from-stone-500 to-stone-700 text-white border-0",
|
badge: "bg-gradient-to-r from-stone-500 to-stone-700 text-white border-0",
|
||||||
panel: { bg: "bg-stone-50 dark:bg-stone-950/30", border: "border-stone-200 dark:border-stone-800" },
|
panel: { bg: "bg-stone-50 dark:bg-stone-500/15", border: "border-stone-200 dark:border-stone-500/40" },
|
||||||
},
|
},
|
||||||
brown: {
|
brown: {
|
||||||
label: "Brown",
|
label: "Brown",
|
||||||
swatch: "#a16207",
|
swatch: "#a16207",
|
||||||
badge: "bg-gradient-to-r from-yellow-700 to-amber-900 text-white border-0",
|
badge: "bg-gradient-to-r from-yellow-700 to-amber-900 text-white border-0",
|
||||||
panel: { bg: "bg-amber-50 dark:bg-amber-950/30", border: "border-amber-300 dark:border-amber-900" },
|
panel: { bg: "bg-amber-50 dark:bg-amber-500/15", border: "border-amber-300 dark:border-amber-500/40" },
|
||||||
},
|
},
|
||||||
gold: {
|
gold: {
|
||||||
label: "Gold",
|
label: "Gold",
|
||||||
swatch: "#ca8a04",
|
swatch: "#ca8a04",
|
||||||
badge: "bg-gradient-to-r from-yellow-500 to-amber-700 text-white border-0",
|
badge: "bg-gradient-to-r from-yellow-500 to-amber-700 text-white border-0",
|
||||||
panel: { bg: "bg-yellow-50 dark:bg-yellow-950/30", border: "border-yellow-300 dark:border-yellow-800" },
|
panel: { bg: "bg-yellow-50 dark:bg-yellow-500/15", border: "border-yellow-300 dark:border-yellow-500/40" },
|
||||||
},
|
},
|
||||||
navy: {
|
navy: {
|
||||||
label: "Navy",
|
label: "Navy",
|
||||||
swatch: "#1e40af",
|
swatch: "#1e40af",
|
||||||
badge: "bg-gradient-to-r from-blue-700 to-blue-900 text-white border-0",
|
badge: "bg-gradient-to-r from-blue-700 to-blue-900 text-white border-0",
|
||||||
panel: { bg: "bg-blue-50 dark:bg-blue-950/30", border: "border-blue-300 dark:border-blue-900" },
|
panel: { bg: "bg-blue-50 dark:bg-blue-500/15", border: "border-blue-300 dark:border-blue-500/40" },
|
||||||
},
|
},
|
||||||
forest: {
|
forest: {
|
||||||
label: "Forest",
|
label: "Forest",
|
||||||
swatch: "#166534",
|
swatch: "#166534",
|
||||||
badge: "bg-gradient-to-r from-green-700 to-green-900 text-white border-0",
|
badge: "bg-gradient-to-r from-green-700 to-green-900 text-white border-0",
|
||||||
panel: { bg: "bg-green-50 dark:bg-green-950/30", border: "border-green-300 dark:border-green-900" },
|
panel: { bg: "bg-green-50 dark:bg-green-500/15", border: "border-green-300 dark:border-green-500/40" },
|
||||||
},
|
},
|
||||||
wine: {
|
wine: {
|
||||||
label: "Wine",
|
label: "Wine",
|
||||||
swatch: "#9f1239",
|
swatch: "#9f1239",
|
||||||
badge: "bg-gradient-to-r from-rose-800 to-rose-950 text-white border-0",
|
badge: "bg-gradient-to-r from-rose-800 to-rose-950 text-white border-0",
|
||||||
panel: { bg: "bg-rose-50 dark:bg-rose-950/30", border: "border-rose-300 dark:border-rose-900" },
|
panel: { bg: "bg-rose-50 dark:bg-rose-500/15", border: "border-rose-300 dark:border-rose-500/40" },
|
||||||
},
|
},
|
||||||
charcoal: {
|
charcoal: {
|
||||||
label: "Charcoal",
|
label: "Charcoal",
|
||||||
swatch: "#374151",
|
swatch: "#374151",
|
||||||
badge: "bg-gradient-to-r from-gray-600 to-gray-900 text-white border-0",
|
badge: "bg-gradient-to-r from-gray-600 to-gray-900 text-white border-0",
|
||||||
panel: { bg: "bg-gray-50 dark:bg-gray-950/30", border: "border-gray-300 dark:border-gray-800" },
|
panel: { bg: "bg-gray-50 dark:bg-gray-500/15", border: "border-gray-300 dark:border-gray-500/40" },
|
||||||
},
|
},
|
||||||
midnight: {
|
midnight: {
|
||||||
label: "Midnight",
|
label: "Midnight",
|
||||||
swatch: "#312e81",
|
swatch: "#312e81",
|
||||||
badge: "bg-gradient-to-r from-indigo-800 to-indigo-950 text-white border-0",
|
badge: "bg-gradient-to-r from-indigo-800 to-indigo-950 text-white border-0",
|
||||||
panel: { bg: "bg-indigo-50 dark:bg-indigo-950/30", border: "border-indigo-300 dark:border-indigo-900" },
|
panel: { bg: "bg-indigo-50 dark:bg-indigo-500/15", border: "border-indigo-300 dark:border-indigo-500/40" },
|
||||||
},
|
},
|
||||||
lavender: {
|
lavender: {
|
||||||
label: "Lavender",
|
label: "Lavender",
|
||||||
swatch: "#a78bfa",
|
swatch: "#a78bfa",
|
||||||
badge: "bg-gradient-to-r from-violet-400 to-violet-600 text-white border-0",
|
badge: "bg-gradient-to-r from-violet-400 to-violet-600 text-white border-0",
|
||||||
panel: { bg: "bg-violet-50 dark:bg-violet-950/30", border: "border-violet-200 dark:border-violet-700" },
|
panel: { bg: "bg-violet-50 dark:bg-violet-500/15", border: "border-violet-200 dark:border-violet-500/40" },
|
||||||
},
|
},
|
||||||
salmon: {
|
salmon: {
|
||||||
label: "Salmon",
|
label: "Salmon",
|
||||||
swatch: "#fca5a5",
|
swatch: "#fca5a5",
|
||||||
badge: "bg-gradient-to-r from-red-300 to-rose-600 text-white border-0",
|
badge: "bg-gradient-to-r from-red-300 to-rose-600 text-white border-0",
|
||||||
panel: { bg: "bg-red-50 dark:bg-red-950/30", border: "border-red-200 dark:border-red-700" },
|
panel: { bg: "bg-red-50 dark:bg-red-500/15", border: "border-red-200 dark:border-red-500/40" },
|
||||||
},
|
},
|
||||||
mint: {
|
mint: {
|
||||||
label: "Mint",
|
label: "Mint",
|
||||||
swatch: "#6ee7b7",
|
swatch: "#6ee7b7",
|
||||||
badge: "bg-gradient-to-r from-emerald-300 to-teal-600 text-white border-0",
|
badge: "bg-gradient-to-r from-emerald-300 to-teal-600 text-white border-0",
|
||||||
panel: { bg: "bg-emerald-50 dark:bg-emerald-950/30", border: "border-emerald-200 dark:border-emerald-700" },
|
panel: { bg: "bg-emerald-50 dark:bg-emerald-500/15", border: "border-emerald-200 dark:border-emerald-500/40" },
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
+2
-3
@@ -6,10 +6,9 @@
|
|||||||
"dev": "concurrently -n api,web -c blue,green \"pnpm --filter api dev\" \"pnpm --filter web dev\"",
|
"dev": "concurrently -n api,web -c blue,green \"pnpm --filter api dev\" \"pnpm --filter web dev\"",
|
||||||
"build": "pnpm --filter web build",
|
"build": "pnpm --filter web build",
|
||||||
"start": "pnpm --filter api start",
|
"start": "pnpm --filter api start",
|
||||||
"test": "pnpm --filter api test",
|
"test": "pnpm --filter api test"
|
||||||
"test:ci": "pnpm --filter e2e test"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"concurrently": "^9.2.1"
|
"concurrently": "^9.2.5"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user