PronounsPage/server/sentry.ts
Adaline Simonian 23a3862ca0
test: introduce snapshot-based smoke tests
- Adds a new test suite with Docker-based smoke tests for all locales.
  Can be run using the ./smoketest.sh script.
- Replaces all calls to Math.random() with a new helper that returns 0.5
  in snapshot testing mode, ensuring deterministic snapshots.
- Similarly replaces all calls to new Date() and Date.now() with new
  helpers that return a fixed date in snapshot testing mode.
- Replaces checks against NODE_ENV with APP_ENV, to ensure that the
  bundles can be built with Nuxt for testing without losing code that
  would otherwise be stripped out by production optimizations.
- Adds a database init script that can be used to initialize the
  database with a single admin user and a long-lived JWT token for use
  in automation tests.
- Adds a JWT decoding/encoding CLI tool for debugging JWTs.

Note: Snapshots are not checked in, and must be generated manually. See
test/__snapshots__/.gitignore for more information.
2025-02-02 23:11:19 -08:00

37 lines
1.1 KiB
TypeScript

import fs from 'fs';
import SentryCli from '@sentry/cli';
import './setup.ts';
import type { Config } from '../locale/config.ts';
import allLocales from '../locale/locales.ts';
import { env } from './env.ts';
import { loadSuml } from './loader.ts';
const __dirname = new URL('.', import.meta.url).pathname;
async function notifyDeployment(): Promise<void> {
if (!process.env.SENTRY_DSN) {
process.stdout.write('SENTRY_DSN is not defined, skipping deployment information to Sentry');
return;
}
const version = fs.readFileSync(`${__dirname}/../cache/version`, 'utf-8');
const config = loadSuml('config') as Config;
const sentryCli = new SentryCli();
await sentryCli.releases.setCommits(version, {
auto: true,
});
await sentryCli.releases.finalize(version);
const environment = env === 'production' ? config.locale : env!;
await sentryCli.releases.newDeploy(version, {
env: environment,
url: allLocales.find((locale) => locale.code === config.locale)?.url,
});
process.stdout.write(`Sent deployment information for environment ${environment} to Sentry`);
}
await notifyDeployment();