Fix server test:run regressions on the Documents branch

The Documents feature wired documentReviewService(db) into issueRoutes
(PAP-10523) and added the document review/suggestion routes, but two
PR-blocking gaps remained:

- 15 server route-test scaffolds mock ../services/index.js without the
  new documentReviewService export, so createApp threw "No
  documentReviewService export is defined" (129 failures). PAP-10578
  only patched 2 of the affected files. Add the same
  remapOpenSuggestionsForDocument stub to the rest.

- The OpenAPI spec (openapi-routes "covers the mounted server routes
  exactly") was missing the 9 document review/suggestion routes. Declare
  them via registerCurrentRoute with their validators, and list the four
  resource-creating POSTs in CREATED_OPERATIONS for 201 parity with the
  annotation routes.

pnpm -r typecheck and the full server suite pass.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
DottaandClaude Opus 4.8 committed 2026-06-07 04:44:29 +00:00
1 parent 2cbf425654
commit bf1884a2c7
16 files changed
+105

No files matched your search

@@ -83,6 +83,7 @@ function registerModuleMocks() {
getById: vi.fn(async () => null),
}),
documentAnnotationService: () => ({ remapOpenThreadsForDocument: async () => [] }),
documentReviewService: () => ({ remapOpenSuggestionsForDocument: async () => [] }),
documentService: () => ({}),
executionWorkspaceService: () => ({}),
feedbackService: () => mockFeedbackService,
@@ -100,6 +100,7 @@ function registerRouteMocks() {
vi.doMock("../services/documents.js", () => ({
documentAnnotationService: () => ({ remapOpenThreadsForDocument: async () => [] }),
documentReviewService: () => ({ remapOpenSuggestionsForDocument: async () => [] }),
documentService: () => mockDocumentService,
}));
@@ -123,6 +124,7 @@ function registerRouteMocks() {
clampIssueListLimit: (value: number) => Math.min(Math.max(value, 1), 500),
companyService: () => mockCompanyService,
documentAnnotationService: () => ({ remapOpenThreadsForDocument: async () => [] }),
documentReviewService: () => ({ remapOpenSuggestionsForDocument: async () => [] }),
documentService: () => mockDocumentService,
executionWorkspaceService: () => ({}),
feedbackService: () => ({
@@ -46,6 +46,7 @@ vi.mock("../services/index.js", () => ({
getById: vi.fn(async () => ({ id: "company-1", attachmentMaxBytes: 10 * 1024 * 1024 })),
}),
documentAnnotationService: () => ({ remapOpenThreadsForDocument: async () => [] }),
documentReviewService: () => ({ remapOpenSuggestionsForDocument: async () => [] }),
documentService: () => ({
getIssueDocumentPayload: vi.fn(async () => ({})),
}),
@@ -50,6 +50,7 @@ function registerRouteMocks() {
}),
companyService: () => mockCompanyService,
documentAnnotationService: () => ({ remapOpenThreadsForDocument: async () => [] }),
documentReviewService: () => ({ remapOpenSuggestionsForDocument: async () => [] }),
documentService: () => ({}),
executionWorkspaceService: () => ({}),
feedbackService: () => ({
@@ -82,6 +82,7 @@ function registerServiceMocks() {
getById: vi.fn(async () => null),
}),
documentAnnotationService: () => ({ remapOpenThreadsForDocument: async () => [] }),
documentReviewService: () => ({ remapOpenSuggestionsForDocument: async () => [] }),
documentService: () => ({}),
executionWorkspaceService: () => mockExecutionWorkspaceService,
feedbackService: () => ({
@@ -99,6 +99,7 @@ function registerModuleMocks() {
accessService: () => mockAccessService,
agentService: () => ({ getById: vi.fn(async () => null) }),
documentAnnotationService: () => mockDocumentAnnotationService,
documentReviewService: () => ({ remapOpenSuggestionsForDocument: async () => [] }),
documentService: () => ({}),
executionWorkspaceService: () => ({}),
feedbackService: () => mockFeedbackService,
@@ -128,6 +128,7 @@ vi.mock("../services/index.js", () => ({
accessService: () => mockAccessService,
agentService: () => mockAgentService,
documentAnnotationService: () => ({ remapOpenThreadsForDocument: async () => [] }),
documentReviewService: () => ({ remapOpenSuggestionsForDocument: async () => [] }),
documentService: () => ({}),
executionWorkspaceService: () => ({}),
feedbackService: () => mockFeedbackService,
@@ -28,6 +28,7 @@ vi.mock("../services/index.js", () => ({
getById: vi.fn(),
}),
documentAnnotationService: () => ({ remapOpenThreadsForDocument: async () => [] }),
documentReviewService: () => ({ remapOpenSuggestionsForDocument: async () => [] }),
documentService: () => ({
getIssueDocumentPayload: vi.fn(async () => ({})),
}),
@@ -76,6 +76,7 @@ function registerModuleMocks() {
})),
}),
documentAnnotationService: () => ({ remapOpenThreadsForDocument: async () => [] }),
documentReviewService: () => ({ remapOpenSuggestionsForDocument: async () => [] }),
documentService: () => ({}),
executionWorkspaceService: () => ({}),
feedbackService: () => ({
@@ -88,6 +88,7 @@ function registerModuleMocks() {
accessService: () => mockAccessService,
agentService: () => mockAgentService,
documentAnnotationService: () => ({ remapOpenThreadsForDocument: async () => [] }),
documentReviewService: () => ({ remapOpenSuggestionsForDocument: async () => [] }),
documentService: () => ({}),
executionWorkspaceService: () => mockExecutionWorkspaceService,
goalService: () => ({}),
@@ -51,6 +51,7 @@ function registerModuleMocks() {
}),
agentService: () => mockAgentService,
documentAnnotationService: () => ({ remapOpenThreadsForDocument: async () => [] }),
documentReviewService: () => ({ remapOpenSuggestionsForDocument: async () => [] }),
documentService: () => ({}),
executionWorkspaceService: () => ({}),
feedbackService: () => ({}),
@@ -74,6 +74,7 @@ function registerModuleMocks() {
ISSUE_LIST_DEFAULT_LIMIT: 500,
ISSUE_LIST_MAX_LIMIT: 1000,
documentAnnotationService: () => ({ remapOpenThreadsForDocument: async () => [] }),
documentReviewService: () => ({ remapOpenSuggestionsForDocument: async () => [] }),
documentService: () => ({}),
executionWorkspaceService: () => ({}),
feedbackService: () => ({
@@ -49,6 +49,7 @@ vi.mock("../services/index.js", () => ({
})),
}),
documentAnnotationService: () => ({ remapOpenThreadsForDocument: async () => [] }),
documentReviewService: () => ({ remapOpenSuggestionsForDocument: async () => [] }),
documentService: () => ({}),
executionWorkspaceService: () => ({}),
feedbackService: () => ({
@@ -118,6 +119,7 @@ function registerModuleMocks() {
})),
}),
documentAnnotationService: () => ({ remapOpenThreadsForDocument: async () => [] }),
documentReviewService: () => ({ remapOpenSuggestionsForDocument: async () => [] }),
documentService: () => ({}),
executionWorkspaceService: () => ({}),
feedbackService: () => ({
@@ -110,6 +110,7 @@ function registerRouteMocks() {
accessService: () => mockAccessService,
agentService: () => mockAgentService,
documentAnnotationService: () => ({ remapOpenThreadsForDocument: async () => [] }),
documentReviewService: () => ({ remapOpenSuggestionsForDocument: async () => [] }),
documentService: () => ({}),
executionWorkspaceService: () => mockExecutionWorkspaceService,
feedbackService: () => mockFeedbackService,
@@ -105,6 +105,7 @@ vi.mock("../services/index.js", () => ({
accessService: () => mockAccessService,
agentService: () => mockAgentService,
documentAnnotationService: () => ({ remapOpenThreadsForDocument: async () => [] }),
documentReviewService: () => ({ remapOpenSuggestionsForDocument: async () => [] }),
documentService: () => mockDocumentsService,
environmentService: () => mockEnvironmentService,
executionWorkspaceService: () => mockExecutionWorkspaceService,
+88
View File
@@ -119,6 +119,15 @@ import {
createDocumentAnnotationCommentSchema,
createDocumentAnnotationThreadSchema,
updateDocumentAnnotationThreadSchema,
// Document review
createDocumentReviewThreadSchema,
createDocumentReviewCommentSchema,
updateDocumentReviewThreadSchema,
createDocumentSuggestionSchema,
createDocumentSuggestionCommentSchema,
acceptDocumentSuggestionSchema,
rejectDocumentSuggestionSchema,
resolveDocumentSuggestionSchema,
// Issue recovery and decomposition
createAcceptedPlanDecompositionSchema,
resolveIssueRecoveryActionSchema,
@@ -605,6 +614,10 @@ const CREATED_OPERATIONS = new Set([
"POST /api/companies/{companyId}/labels",
"POST /api/issues/{id}/documents/{key}/annotations",
"POST /api/issues/{id}/documents/{key}/annotations/{threadId}/comments",
"POST /api/issues/{id}/documents/{key}/review-comments",
"POST /api/issues/{id}/documents/{key}/review-comments/{threadId}/comments",
"POST /api/issues/{id}/documents/{key}/suggestions",
"POST /api/issues/{id}/documents/{key}/suggestions/{suggestionId}/comments",
"POST /api/issues/{id}/work-products",
"POST /api/issues/{id}/low-trust/promotions",
"POST /api/issues/{id}/approvals",
@@ -4373,6 +4386,81 @@ registerCurrentRoute({
body: updateDocumentAnnotationThreadSchema,
});
registerCurrentRoute({
method: "get",
path: "/api/issues/{id}/documents/{key}/review-index",
tags: ["issues"],
summary: "Get the document review index",
});
registerCurrentRoute({
method: "post",
path: "/api/issues/{id}/documents/{key}/review-comments",
tags: ["issues"],
summary: "Create a document review thread",
body: createDocumentReviewThreadSchema,
responses: { 201: r.ok(), 400: r.badRequest, 401: r.unauthorized, 404: r.notFound },
});
registerCurrentRoute({
method: "post",
path: "/api/issues/{id}/documents/{key}/review-comments/{threadId}/comments",
tags: ["issues"],
summary: "Add a document review comment",
body: createDocumentReviewCommentSchema,
responses: { 201: r.ok(), 400: r.badRequest, 401: r.unauthorized, 404: r.notFound },
});
registerCurrentRoute({
method: "patch",
path: "/api/issues/{id}/documents/{key}/review-comments/{threadId}",
tags: ["issues"],
summary: "Update a document review thread",
body: updateDocumentReviewThreadSchema,
});
registerCurrentRoute({
method: "post",
path: "/api/issues/{id}/documents/{key}/suggestions",
tags: ["issues"],
summary: "Create a document suggestion",
body: createDocumentSuggestionSchema,
responses: { 201: r.ok(), 400: r.badRequest, 401: r.unauthorized, 404: r.notFound },
});
registerCurrentRoute({
method: "post",
path: "/api/issues/{id}/documents/{key}/suggestions/{suggestionId}/comments",
tags: ["issues"],
summary: "Add a document suggestion comment",
body: createDocumentSuggestionCommentSchema,
responses: { 201: r.ok(), 400: r.badRequest, 401: r.unauthorized, 404: r.notFound },
});
registerCurrentRoute({
method: "post",
path: "/api/issues/{id}/documents/{key}/suggestions/{suggestionId}/reject",
tags: ["issues"],
summary: "Reject a document suggestion",
body: rejectDocumentSuggestionSchema,
});
registerCurrentRoute({
method: "post",
path: "/api/issues/{id}/documents/{key}/suggestions/{suggestionId}/resolve",
tags: ["issues"],
summary: "Resolve a document suggestion",
body: resolveDocumentSuggestionSchema,
});
registerCurrentRoute({
method: "post",
path: "/api/issues/{id}/documents/{key}/suggestions/{suggestionId}/accept",
tags: ["issues"],
summary: "Accept a document suggestion",
body: acceptDocumentSuggestionSchema,
});
registerCurrentRoute({
method: "get",
path: "/api/issues/{id}/recovery-actions",