29e63e5ce5
The AdminHeader "Clear All" notifications button has been 404'ing for
a while: frontend `notifications.service.ts` calls
`DELETE /admin/notifications/clear-all`, backend only defined
`DELETE /admin/notifications/clear-old`.
The /clear-old route was misleadingly named anyway — it tried to
delete read OR >30-days-old rows, then had a fallback that nuked
EVERY row when nothing matched. Both the frontend and the existing
test expect a simple Clear All shape, so just rename to /clear-all,
drop the tiered logic, and return the plain
`{ message, deletedCount }` payload the test asserts on.
The test (adminNotifications.test.js) was hiding the breakage —
it was on CI's --testPathIgnorePatterns ignore list and so never
ran. Two reasons it failed locally before this fix:
1. Route path mismatch (the actual #597 bug).
2. The mock only stubbed adminAuth — requirePermission lives in
its own middleware module and ran for real, 403'ing before
the handler. Add a passthrough mock for that too.
With both fixed, the test passes. Drop adminNotifications from the
CI ignore list so future regressions in this route fail loudly
instead of going to ground.
90 lines
2.9 KiB
YAML
90 lines
2.9 KiB
YAML
name: Tests
|
|
|
|
# Runs the backend Jest suite and the frontend Vitest suite on every PR.
|
|
# Both suites already exist and cover the CRM service layer (quoteService,
|
|
# contractService, invoiceService.*, customerHoursService, eventService.
|
|
# calendar) plus the photo / settings / OG / auth surface — wiring them
|
|
# into CI makes regressions visible at PR time instead of post-merge.
|
|
#
|
|
# Six backend suites are excluded via --testPathIgnorePatterns. They
|
|
# fail on `upstream/beta` too (pre-existing mock/infra issues, NOT CRM
|
|
# regressions). Excluding them here keeps CI green from day 1; revisit
|
|
# each individually as its own fix.
|
|
#
|
|
# Triggers on any change that could affect either suite. The backend
|
|
# job intentionally omits frontend paths and vice versa so unrelated
|
|
# PRs don't pay both build costs.
|
|
|
|
on:
|
|
push:
|
|
branches: [main, beta]
|
|
pull_request:
|
|
branches: [main, beta]
|
|
workflow_dispatch:
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
jobs:
|
|
backend:
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 10
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: '22'
|
|
cache: 'npm'
|
|
cache-dependency-path: backend/package-lock.json
|
|
|
|
- name: Install backend deps
|
|
working-directory: ./backend
|
|
run: npm ci
|
|
|
|
- name: Run Jest suite
|
|
working-directory: ./backend
|
|
env:
|
|
# backupService tests would otherwise try a real S3 round-trip.
|
|
# The S3 path itself is covered separately by the integration
|
|
# suite when MinIO is provisioned.
|
|
SKIP_S3_TESTS: 'true'
|
|
run: |
|
|
# Excluded suites — fail on upstream/beta too, tracked
|
|
# separately as test-infra debt:
|
|
# adminSettings.logo — supertest fixture
|
|
# integration/adminPhotos.reference — supertest fixture
|
|
# integration/webhookDelivery — supertest fixture
|
|
# services/backupService.enhanced — knex mock chain
|
|
# routes/__tests__/adminAuth — supertest fixture
|
|
# (adminNotifications was excluded; #597 fix re-enables it.)
|
|
npx jest \
|
|
--testPathIgnorePatterns='/node_modules/|adminSettings\.logo\.test|integration/adminPhotos\.reference|integration/webhookDelivery|backupService\.enhanced|routes/__tests__/adminAuth' \
|
|
--ci
|
|
|
|
frontend:
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 10
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: '22'
|
|
cache: 'npm'
|
|
cache-dependency-path: frontend/package-lock.json
|
|
|
|
- name: Install frontend deps
|
|
working-directory: ./frontend
|
|
run: npm ci
|
|
|
|
- name: Run Vitest suite
|
|
working-directory: ./frontend
|
|
run: npm test -- --run
|