Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 9 additions & 15 deletions apps/backend/tests/integration/auth.helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import type { Hono } from 'hono';
import { runner } from 'node-pg-migrate';
import pg from 'pg';
import { Wait } from 'testcontainers';
import { afterAll, beforeAll, beforeEach } from 'vitest';
import { afterAll, beforeAll, beforeEach, vi } from 'vitest';
import { createApp } from '../../src/index.js';
import { resetAuth } from '../../src/lib/auth.js';
import { resetRateLimiters } from '../../src/middleware/rate-limit.js';
Expand Down Expand Up @@ -41,7 +41,7 @@ export async function setupAuthTests(): Promise<AuthTestContext> {
await resetAuth();

// Set DATABASE_URL from the container
process.env.DATABASE_URL = container.getConnectionUri();
vi.stubEnv('DATABASE_URL', container.getConnectionUri());
resetConfig();

// Create connection pool
Expand Down Expand Up @@ -365,12 +365,12 @@ export function setupAuthTestSuite() {

beforeAll(async () => {
// Set required environment variables for tests
process.env.BETTER_AUTH_SECRET = 'test-better-auth-secret-test-better-auth-secret-1';
process.env.JWT_SECRET = 'test-jwt-secret-test-jwt-secret-1';
process.env.SESSION_SECRET = 'test-session-secret-test-session-secret-1';
process.env.JWT_EXPIRY = '604800';
process.env.FRONTEND_URL = 'http://localhost:5173';
process.env.LOG_LEVEL = 'silent';
vi.stubEnv('BETTER_AUTH_SECRET', 'test-better-auth-secret-test-better-auth-secret-1');
vi.stubEnv('JWT_SECRET', 'test-jwt-secret-test-jwt-secret-1');
vi.stubEnv('SESSION_SECRET', 'test-session-secret-test-session-secret-1');
vi.stubEnv('JWT_EXPIRY', '604800');
vi.stubEnv('FRONTEND_URL', 'http://localhost:5173');
vi.stubEnv('LOG_LEVEL', 'silent');

context = await setupAuthTests();
}, 120000); // 120 second timeout for container startup
Expand All @@ -382,13 +382,7 @@ export function setupAuthTestSuite() {

afterAll(async () => {
await teardownAuthTests(context);
delete process.env.BETTER_AUTH_SECRET;
delete process.env.JWT_SECRET;
delete process.env.SESSION_SECRET;
delete process.env.JWT_EXPIRY;
delete process.env.FRONTEND_URL;
delete process.env.DATABASE_URL;
delete process.env.LOG_LEVEL;
vi.unstubAllEnvs();
resetConfig();
}, 120000);

Expand Down
22 changes: 8 additions & 14 deletions apps/backend/tests/integration/friends.helpers.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type pg from 'pg';
import { afterAll, beforeAll, beforeEach } from 'vitest';
import { afterAll, beforeAll, beforeEach, vi } from 'vitest';
import { resetRateLimiters } from '../../src/middleware/rate-limit.js';
import { hashPassword } from '../../src/utils/auth.js';
import { resetConfig } from '../../src/utils/config.js';
Expand Down Expand Up @@ -159,12 +159,12 @@ export function setupFriendsTestSuite() {

beforeAll(async () => {
// Set required environment variables for tests
process.env.BETTER_AUTH_SECRET = 'test-better-auth-secret-test-better-auth-secret-1';
process.env.JWT_SECRET = 'test-jwt-secret-test-jwt-secret-1';
process.env.SESSION_SECRET = 'test-session-secret-test-session-secret-1';
process.env.JWT_EXPIRY = '604800';
process.env.FRONTEND_URL = 'http://localhost:5173';
process.env.LOG_LEVEL = 'silent';
vi.stubEnv('BETTER_AUTH_SECRET', 'test-better-auth-secret-test-better-auth-secret-1');
vi.stubEnv('JWT_SECRET', 'test-jwt-secret-test-jwt-secret-1');
vi.stubEnv('SESSION_SECRET', 'test-session-secret-test-session-secret-1');
vi.stubEnv('JWT_EXPIRY', '604800');
vi.stubEnv('FRONTEND_URL', 'http://localhost:5173');
vi.stubEnv('LOG_LEVEL', 'silent');

const authContext = await setupAuthTests();

Expand Down Expand Up @@ -194,13 +194,7 @@ export function setupFriendsTestSuite() {

afterAll(async () => {
await teardownAuthTests(context);
delete process.env.BETTER_AUTH_SECRET;
delete process.env.JWT_SECRET;
delete process.env.SESSION_SECRET;
delete process.env.JWT_EXPIRY;
delete process.env.FRONTEND_URL;
delete process.env.DATABASE_URL;
delete process.env.LOG_LEVEL;
vi.unstubAllEnvs();
resetConfig();
}, 120000);

Expand Down
15 changes: 6 additions & 9 deletions apps/backend/tests/integration/postgis.helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { runner } from 'node-pg-migrate';
import pg from 'pg';
import pino from 'pino';
import { Wait } from 'testcontainers';
import { afterAll, beforeAll } from 'vitest';
import { afterAll, beforeAll, vi } from 'vitest';
import { PostGISAddressClient } from '../../src/services/external/postgis-address.client.js';
import { resetConfig } from '../../src/utils/config.js';

Expand Down Expand Up @@ -50,7 +50,7 @@ export async function setupPostGISTests(): Promise<PostGISTestContext> {
const connectionUri = container.getConnectionUri();

// Set DATABASE_URL from the container
process.env.DATABASE_URL = connectionUri;
vi.stubEnv('DATABASE_URL', connectionUri);
resetConfig();

// Create connection pool
Expand Down Expand Up @@ -176,19 +176,16 @@ export function setupPostGISTestSuite() {

beforeAll(async () => {
// Set required environment variables for tests
process.env.JWT_SECRET = 'test-jwt-secret-test-jwt-secret-1';
process.env.SESSION_SECRET = 'test-session-secret-test-session-secret-1';
process.env.LOG_LEVEL = 'silent';
vi.stubEnv('JWT_SECRET', 'test-jwt-secret-test-jwt-secret-1');
vi.stubEnv('SESSION_SECRET', 'test-session-secret-test-session-secret-1');
vi.stubEnv('LOG_LEVEL', 'silent');

context = await setupPostGISTests();
}, 180000); // 180 second timeout for container startup

afterAll(async () => {
await teardownPostGISTests(context);
delete process.env.JWT_SECRET;
delete process.env.SESSION_SECRET;
delete process.env.DATABASE_URL;
delete process.env.LOG_LEVEL;
vi.unstubAllEnvs();
resetConfig();
}, 60000);

Expand Down
22 changes: 8 additions & 14 deletions apps/backend/tests/integration/search.helpers.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type pg from 'pg';
import { afterAll, beforeAll, beforeEach } from 'vitest';
import { afterAll, beforeAll, beforeEach, vi } from 'vitest';
import { resetRateLimiters } from '../../src/middleware/rate-limit.js';
import { resetConfig } from '../../src/utils/config.js';
import { completeTestUserOnboarding, setupAuthTests, teardownAuthTests } from './auth.helpers.js';
Expand Down Expand Up @@ -300,12 +300,12 @@ export function setupSearchTestSuite() {

beforeAll(async () => {
// Set required environment variables for tests
process.env.BETTER_AUTH_SECRET = 'test-better-auth-secret-test-better-auth-secret-1';
process.env.JWT_SECRET = 'test-jwt-secret-test-jwt-secret-1';
process.env.SESSION_SECRET = 'test-session-secret-test-session-secret-1';
process.env.JWT_EXPIRY = '604800';
process.env.FRONTEND_URL = 'http://localhost:5173';
process.env.LOG_LEVEL = 'silent';
vi.stubEnv('BETTER_AUTH_SECRET', 'test-better-auth-secret-test-better-auth-secret-1');
vi.stubEnv('JWT_SECRET', 'test-jwt-secret-test-jwt-secret-1');
vi.stubEnv('SESSION_SECRET', 'test-session-secret-test-session-secret-1');
vi.stubEnv('JWT_EXPIRY', '604800');
vi.stubEnv('FRONTEND_URL', 'http://localhost:5173');
vi.stubEnv('LOG_LEVEL', 'silent');

const authContext = await setupAuthTests();

Expand Down Expand Up @@ -338,13 +338,7 @@ export function setupSearchTestSuite() {

afterAll(async () => {
await teardownAuthTests(context);
delete process.env.BETTER_AUTH_SECRET;
delete process.env.JWT_SECRET;
delete process.env.SESSION_SECRET;
delete process.env.JWT_EXPIRY;
delete process.env.FRONTEND_URL;
delete process.env.DATABASE_URL;
delete process.env.LOG_LEVEL;
vi.unstubAllEnvs();
resetConfig();
}, 120000);

Expand Down
Loading