Commit Graph
6 Commits
Author SHA1 Message Date
Ben WestandCopilot 6a681509f3 feat: add database-level production safety checks (GAP-SYNC-047)
Adds multi-layer protection against running destructive tests on production:

1. Pre-flight check (hooks.js): Verifies NODE_ENV=test before any DB connection
2. Database name check: Requires 'test' substring in database name
3. Entry count threshold: Refuses if database has >100 entries (configurable)

Environment Variables:
- TEST_SAFETY_MAX_ENTRIES: Max entries before refusing (default: 100)
- TEST_SAFETY_REQUIRE_TEST_DB: Require 'test' in DB name (default: true)
- TEST_SAFETY_SKIP: Emergency bypass for all checks (default: false)

Files:
- tests/lib/production-safety.js: Core safety check module
- tests/00_production-safety.test.js: Runs first to gate test suite
- tests/production-safety.test.js: Unit tests for safety module
- tests/hooks.js: Updated to use new module

This addresses concerns about users with 'test' in production DB names
by adding the entry count threshold as a secondary safety measure.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-18 19:49:49 -07:00
Ben WestandCopilot e12cf3d2e2 fix(tests): make NODE_ENV=test check a hard failure (GAP-SYNC-046)
Change from warning to process.exit(1) to prevent any possibility of
running destructive test operations against a production database.

Tests now fail immediately if NODE_ENV !== 'test', with clear instructions
on how to fix.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-12 12:39:01 -07:00
Ben WestandCopilot 61501cac3a feat(tests): add NODE_ENV=test safety check (GAP-SYNC-046)
SAFETY-001: Fix tests/ci.test.env to use NODE_ENV=test instead of production
SAFETY-002: Add NODE_ENV check to tests/hooks.js with warning
SAFETY-003: Create tests/fixtures/test-guard.js with guarded deleteMany/drop helpers

This prevents deleteMany({}) from accidentally running against production
databases if test environment is misconfigured.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-12 12:24:15 -07:00
bewest cface54888 Optimize test suite by converting beforeEach to before and adding parallel testing scripts
Updated test execution scripts in package.json to include parallel and fast test options. Converted several `beforeEach` hooks to `before` in test files for more efficient application setup. Added documentation for test optimizations.

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: 271f3cac-bab1-4e81-9982-f31b3b030aab
Replit-Commit-Checkpoint-Type: intermediate_checkpoint
Replit-Commit-Event-Id: ac6eb857-be5a-454b-96cf-b9c4c57f058b
Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/7ea4278b-5c6c-4065-9cb8-f1013771318d/271f3cac-bab1-4e81-9982-f31b3b030aab/69H2O1r
Replit-Helium-Checkpoint-Created: true
2026-01-19 22:47:02 +00:00
bewestandBen West 851d46b99f Add test instrumentation to detect and warn about flaky tests
Introduce timing instrumentation to identify slow tests and setTimeout anti-patterns, refactor helper functions into a shared module, and update documentation and npm scripts.

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: a10b5171-2266-431b-a8b1-bbc77898c289
Replit-Commit-Checkpoint-Type: intermediate_checkpoint
Replit-Commit-Event-Id: fdf582ee-3e62-4543-a850-a72060814d7d
Replit-Helium-Checkpoint-Created: true
2026-01-19 13:14:46 -08:00
Sulka HaroandGitHub 04ca7b240b Unit test teardown improvements (#6821)
* Clear module require()s between tests
Clear profile cache between tests

* Fix authentication for careportal test

* Add logging to see where the careportal test gets to

* Even more logging for headless setup

* Change to use before and after in careportal test

* Add time logging

* Bump headless setup time to a full minute

* More timers to figure out what's slow in GA

* Bump up timeout on failing test
2021-02-01 17:50:48 +02:00