test: isolate authorization setup and identify queued user comments

Finish cold route imports before shared-mock test loops begin, and seed explicit user authorship required by locked queued-comment admission. Preserve all authorization and responsible-user assertions.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
Dotta 2026-09-12 19:39:37 -05:00
parent b802e34ffb
commit 23211f7724
2 changed files with 11 additions and 4 deletions

View File

@ -1,6 +1,6 @@
import express from "express";
import request from "supertest";
import { beforeEach, describe, expect, it, vi } from "vitest";
import { beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
vi.unmock("http");
vi.unmock("node:http");
@ -344,6 +344,12 @@ function resetMockDefaults() {
}
describe.sequential("agent cross-tenant route authorization", () => {
// Pay the cold route transform cost before a test starts mutating shared mocks.
// A timed-out import otherwise leaves its request loop running into later tests.
beforeAll(async () => {
await loadRouteModules();
}, 60_000);
beforeEach(() => {
resetMockDefaults();
});

View File

@ -156,7 +156,7 @@ describeEmbeddedPostgres("heartbeat responsible-user invariant", () => {
membershipRole: "operator", status: "active" });
await db.insert(issues).values({ id: issueId, companyId, title: "Interrupted queue", status: "todo",
assigneeAgentId: agentId, responsibleUserId: ownerUserId });
await db.insert(issueComments).values({ id: commentId, companyId, issueId, authorUserId: ownerUserId, body: "Continue the task" });
await db.insert(issueComments).values({ id: commentId, companyId, issueId, authorType: "user", authorUserId: ownerUserId, body: "Continue the task" });
await db.insert(agentWakeupRequests).values({ id: queueId, companyId, agentId,
source: "automation", status: "deferred_issue_execution", requestedByActorType: "system",
payload: { issueId, commentId, queuedCommentInterrupt: { actorId: operatorId, requestedAt: new Date().toISOString() },
@ -185,7 +185,7 @@ describeEmbeddedPostgres("heartbeat responsible-user invariant", () => {
membershipRole: "operator", status: "active" });
await db.insert(issues).values({ id: issueId, companyId, title: "Manual wake", status: "todo",
assigneeAgentId: agentId, responsibleUserId: ownerUserId });
await db.insert(issueComments).values({ id: commentId, companyId, issueId, authorUserId: ownerUserId, body: "Pending work" });
await db.insert(issueComments).values({ id: commentId, companyId, issueId, authorType: "user", authorUserId: ownerUserId, body: "Pending work" });
await db.insert(agentWakeupRequests).values({ id: queueId, companyId, agentId,
source: "automation", reason: "issue_commented", status: "deferred_issue_execution", requestedByActorType: "user", requestedByActorId: ownerUserId,
payload: { issueId, commentId, _paperclipWakeContext: { wakeCommentIds: [commentId] } },
@ -216,7 +216,7 @@ describeEmbeddedPostgres("heartbeat responsible-user invariant", () => {
requestedByActorType: "user", requestedByActorId: ownerUserId });
try {
await vi.waitFor(() => expect(mockAdapterExecute).toHaveBeenCalled(), { timeout: 5_000 });
await db.insert(issueComments).values({ id: commentId, companyId, issueId, authorUserId: ownerUserId, body: "Pending work" });
await db.insert(issueComments).values({ id: commentId, companyId, issueId, authorType: "user", authorUserId: ownerUserId, body: "Pending work" });
await db.insert(agentWakeupRequests).values({ id: queueId, companyId, agentId,
source: "automation", reason: "issue_commented", status: "deferred_issue_execution",
requestedByActorType: "user", requestedByActorId: ownerUserId,
@ -358,6 +358,7 @@ describeEmbeddedPostgres("heartbeat responsible-user invariant", () => {
id: commentId,
companyId,
issueId,
authorType: "user",
authorUserId: commenterUserId,
body: `Current request for ${wakeReason}`,
});