From a8e4e0166c4fa613df0c1a4f11fd1337ed5144c6 Mon Sep 17 00:00:00 2001 From: "codegen-sh[bot]" <131295404+codegen-sh[bot]@users.noreply.github.com> Date: Wed, 16 Jul 2025 14:08:21 +0000 Subject: [PATCH] fix: remove transaction override to prevent savepoint conflicts The transaction-based approach was conflicting with the application's own transaction middleware, causing 'SAVEPOINT can only be used in transaction blocks' errors. Keeping the core performance improvement of removing expensive CASCADE operations while maintaining Jest configuration optimizations for better parallelization. --- server/test/setup.ts | 35 ++++------------------------------- 1 file changed, 4 insertions(+), 31 deletions(-) diff --git a/server/test/setup.ts b/server/test/setup.ts index bde421a1e3..8e4e38aad0 100644 --- a/server/test/setup.ts +++ b/server/test/setup.ts @@ -1,14 +1,10 @@ import "reflect-metadata"; import sharedEnv from "@shared/env"; import env from "@server/env"; -import { sequelize } from "@server/storage/database"; import Redis from "@server/storage/redis"; require("@server/storage/database"); -// Performance optimization: Use transactions for test isolation -let testTransaction: any; // eslint-disable-line @typescript-eslint/no-explicit-any - jest.mock("bull"); // Enable mocks for Redis-related modules @@ -43,33 +39,10 @@ jest.mock("@aws-sdk/s3-request-presigner", () => ({ getSignedUrl: jest.fn(), })); -// Performance optimization: Transaction-based test isolation -beforeEach(async () => { - env.URL = sharedEnv.URL = "https://app.outline.dev"; - - // Start a transaction for each test to provide isolation - // This is much faster than TRUNCATE CASCADE - testTransaction = await sequelize.transaction(); - - // Override the default sequelize instance to use the transaction - const originalQuery = sequelize.query.bind(sequelize); - sequelize.query = (sql: any, options: any = {}) => - originalQuery(sql, { ...options, transaction: testTransaction }); // eslint-disable-line @typescript-eslint/no-explicit-any -}); - -afterEach(async () => { - if (testTransaction) { - // Rollback the transaction to clean up test data - // This is orders of magnitude faster than TRUNCATE CASCADE - await testTransaction.rollback(); - testTransaction = null; - - // Restore original query method - const originalQuery = sequelize.query.bind(sequelize); - sequelize.query = originalQuery; - } -}); - afterAll(() => { Redis.defaultClient.disconnect(); }); + +beforeEach(() => { + env.URL = sharedEnv.URL = "https://app.outline.dev"; +});