Files
remove-youtube-suggestions/server/tests/setup.js
T
Lawrence Hook 3b1789e89e Gate Stripe webhook on STRIPE_ALLOWED_PRODUCT_IDS allowlist
Prevents foreign Stripe events (from other apps sharing this Stripe
account) from being processed. Webhook ignores events whose products
are not in the allowlist; server refuses to boot without it set.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-22 19:07:44 -04:00

40 lines
1.1 KiB
JavaScript

const fs = require('fs');
// Set up test environment variables
process.env.JWT_SECRET = 'test-secret-key-for-testing-only-32chars';
process.env.STRIPE_SECRET_KEY = 'sk_test_fake';
process.env.STRIPE_PRICE_MONTHLY = 'price_test_monthly';
process.env.STRIPE_PRICE_YEARLY = 'price_test_yearly';
process.env.STRIPE_WEBHOOK_SECRET = 'whsec_test';
process.env.STRIPE_ALLOWED_PRODUCT_IDS = 'prod_test_rys';
process.env.EMAIL_FROM = 'test@example.com';
process.env.BASE_URL = 'http://localhost:3000';
process.env.DATA_DIR = './tests/test-data';
// Clean up test data directory
const testDataDir = './tests/test-data';
function cleanTestData() {
const storage = require('../src/storage');
storage.closeDatabase();
try {
if (fs.existsSync(testDataDir)) {
fs.rmSync(testDataDir, { recursive: true, force: true });
}
} catch (err) {
// Ignore ENOTEMPTY errors from race conditions in parallel tests
if (err.code !== 'ENOTEMPTY' && err.code !== 'ENOENT') {
throw err;
}
}
}
// Clean before tests
cleanTestData();
// Export for use in tests
module.exports = {
cleanTestData,
testDataDir,
};