mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-10-10 12:07:09 +02:00
test(server): drain runtime writes and load routes in setup
Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
1 parent
fb725383b9
commit
bb8b18d19e
3 files changed
+23
-13
No files matched your search
@@ -110,9 +110,11 @@ describeEmbeddedPostgres("heartbeat runtime skill version pins", () => {
|
||||
}, 20_000);
|
||||
|
||||
afterEach(async () => {
|
||||
// Terminal status precedes the executor's final writes. Drain the owned
|
||||
// executions before truncating tables they can still reference or lock.
|
||||
await heartbeatService(db).drainActiveRunExecutions();
|
||||
capturedRuns.length = 0;
|
||||
await instanceSettingsService(db).updateExperimental({ enableBetaSkills: false });
|
||||
await new Promise((resolve) => setTimeout(resolve, 100));
|
||||
await db.execute(sql.raw(`
|
||||
TRUNCATE TABLE
|
||||
"activity_log",
|
||||
|
||||
@@ -154,11 +154,10 @@ function createStorageService(body = Buffer.from("test")): TestStorageService {
|
||||
};
|
||||
}
|
||||
|
||||
let issueRoutes: typeof import("../routes/issues.js")["issueRoutes"];
|
||||
let errorHandler: typeof import("../middleware/index.js")["errorHandler"];
|
||||
|
||||
async function createApp(storage: StorageService, options?: { companyIds?: string[]; source?: string }) {
|
||||
const [{ errorHandler }, { issueRoutes }] = await Promise.all([
|
||||
vi.importActual<typeof import("../middleware/index.js")>("../middleware/index.js"),
|
||||
vi.importActual<typeof import("../routes/issues.js")>("../routes/issues.js"),
|
||||
]);
|
||||
const app = express();
|
||||
app.use(express.json());
|
||||
app.use((req, _res, next) => {
|
||||
@@ -224,7 +223,7 @@ describe("MAX_ATTACHMENT_BYTES", () => {
|
||||
});
|
||||
|
||||
describe("issue attachment routes", () => {
|
||||
beforeEach(() => {
|
||||
beforeEach(async () => {
|
||||
vi.resetModules();
|
||||
vi.doUnmock("@paperclipai/shared/telemetry");
|
||||
vi.doUnmock("../telemetry.js");
|
||||
@@ -257,7 +256,12 @@ describe("issue attachment routes", () => {
|
||||
mockWorkProductService.createForIssue.mockReset();
|
||||
mockWorkProductService.getById.mockReset();
|
||||
mockWorkProductService.update.mockReset();
|
||||
});
|
||||
// Load the cold route graph after this test's module mocks are installed.
|
||||
[{ errorHandler }, { issueRoutes }] = await Promise.all([
|
||||
vi.importActual<typeof import("../middleware/index.js")>("../middleware/index.js"),
|
||||
vi.importActual<typeof import("../routes/issues.js")>("../routes/issues.js"),
|
||||
]);
|
||||
}, 30_000);
|
||||
|
||||
it("accepts zip uploads for issue attachments", async () => {
|
||||
const storage = createStorageService();
|
||||
|
||||
@@ -171,6 +171,9 @@ function createRunContextDb(contextSnapshot: Record<string, unknown>) {
|
||||
};
|
||||
}
|
||||
|
||||
let issueRoutes: typeof import("../routes/issues.js")["issueRoutes"];
|
||||
let errorHandler: typeof import("../middleware/index.js")["errorHandler"];
|
||||
|
||||
async function createApp(
|
||||
actor: Express.Request["actor"] = {
|
||||
type: "board",
|
||||
@@ -181,10 +184,6 @@ async function createApp(
|
||||
},
|
||||
db: unknown = {},
|
||||
) {
|
||||
const [{ issueRoutes }, { errorHandler }] = await Promise.all([
|
||||
vi.importActual<typeof import("../routes/issues.js")>("../routes/issues.js"),
|
||||
vi.importActual<typeof import("../middleware/index.js")>("../middleware/index.js"),
|
||||
]);
|
||||
const app = express();
|
||||
app.use(express.json());
|
||||
app.use((req, _res, next) => {
|
||||
@@ -197,7 +196,7 @@ async function createApp(
|
||||
}
|
||||
|
||||
describe("issue document revision routes", () => {
|
||||
beforeEach(() => {
|
||||
beforeEach(async () => {
|
||||
vi.resetModules();
|
||||
vi.doUnmock("../services/access.js");
|
||||
vi.doUnmock("../services/activity-log.js");
|
||||
@@ -282,7 +281,12 @@ describe("issue document revision routes", () => {
|
||||
mockInstanceSettingsService.listCompanyIds.mockResolvedValue([companyId]);
|
||||
mockRoutineService.syncRunStatusForIssue.mockResolvedValue(undefined);
|
||||
mockLogActivity.mockResolvedValue(undefined);
|
||||
});
|
||||
// Load the cold route graph after this test's module mocks are installed.
|
||||
[{ issueRoutes }, { errorHandler }] = await Promise.all([
|
||||
vi.importActual<typeof import("../routes/issues.js")>("../routes/issues.js"),
|
||||
vi.importActual<typeof import("../middleware/index.js")>("../middleware/index.js"),
|
||||
]);
|
||||
}, 30_000);
|
||||
|
||||
it("returns revision snapshots including title and format", async () => {
|
||||
const res = await request(await createApp()).get(`/api/issues/${issueId}/documents/plan/revisions`);
|
||||
|
||||
Reference in new issue
Block a user