This repository has been archived on 2026-11-17. You can view files and clone it, but cannot push or open issues or pull requests.
caelum0x 64fbe9f474 feat: round-3 deep product build-out (69 gaps closed, all 7 products green)
Deep-audit + build-out across all products to fully-usable state; all typecheck clean.

- gitgram-web (99): wire Store feature to real endpoints, close 9 gaps
- gitgram-backend (100): close 8 flow gaps, document infra-provisioning items
- gitgram-mobile (90): fix API base-URL/path mismatch (404s) + copy proximity
  components into components/proximity wired to real screens; 15 gaps, +react-native-svg
- aitm-core (95): wire natural-language CLI flow end-to-end; 11 gaps
- aitm-api (97): fix teams metadata runtime bug; copy a2a-js server/client/grpc
  into src/a2a and wire A2A route; crates.io package search; 8 gaps
- aitm-mcp (100): fix A2A client/server card mismatch; 9 gaps
- aitm-website (95): build missing docs routes; 9 gaps

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-28 13:54:57 +03:00

58 lines
2.3 KiB
TypeScript

/**
* E2E global setup.
*
* Runs ONCE before the entire E2E suite. Validates that a real database is
* configured, then applies the Prisma schema so tables exist. Redis is optional
* (the app degrades to in-memory cache when REDIS_URL is absent), but when
* provided the background-job and cache paths are exercised too.
*
* Fails fast with a clear message if DATABASE_URL is not pointed at a real,
* reachable Postgres — these tests intentionally do NOT mock the datastore.
*/
import { execSync } from 'child_process';
import path from 'path';
const BACKEND_ROOT = path.resolve(__dirname, '..', '..');
function ensureTestEnv(): void {
process.env.NODE_ENV = 'test';
process.env.JWT_SECRET =
process.env.JWT_SECRET || 'e2e-test-secret-key-at-least-32-characters-long-x';
process.env.JWT_REFRESH_SECRET =
process.env.JWT_REFRESH_SECRET || 'e2e-test-refresh-secret-key-at-least-32-chars-x';
process.env.FRONTEND_URL = process.env.FRONTEND_URL || 'http://localhost:3000';
// Keep external integrations disabled/no-op during E2E so flows are deterministic.
process.env.AI_ANALYSIS_ENABLED = process.env.AI_ANALYSIS_ENABLED || 'false';
// Disable rate limiting so the suite can fire many requests in quick succession.
process.env.DISABLE_RATE_LIMIT = 'true';
delete process.env.SENTRY_DSN;
}
function assertDatabaseConfigured(): void {
const url = process.env.DATABASE_URL;
if (!url) {
throw new Error(
'E2E setup: DATABASE_URL is not set. The E2E suite requires a real PostgreSQL ' +
'instance. Start one with `docker compose -f docker-compose.test.yml up -d` and ' +
'export DATABASE_URL=postgresql://gitgram_test:gitgram_test@localhost:5433/gitgram_test',
);
}
if (!url.startsWith('postgresql://') && !url.startsWith('postgres://')) {
throw new Error(`E2E setup: DATABASE_URL must be a PostgreSQL connection string, got: ${url}`);
}
}
export default async function globalSetup(): Promise<void> {
ensureTestEnv();
assertDatabaseConfigured();
// Push the Prisma schema to the (ephemeral) test database. `db push` is used
// instead of `migrate deploy` so the suite works against a fresh empty DB
// without requiring a full migration history to be present.
execSync('npx prisma db push --skip-generate --accept-data-loss', {
cwd: BACKEND_ROOT,
stdio: 'inherit',
env: process.env,
});
}