From f4753fb024f35364097729903ae25488b3892e7f Mon Sep 17 00:00:00 2001 From: Dotta Date: Fri, 24 Apr 2026 15:12:54 -0500 Subject: [PATCH] Stabilize company import issue assertions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The `/api/companies/:id/issues` endpoint returns every issue in the company, including system-generated ones. Asserting on absolute counts made the test brittle whenever an unrelated issue existed alongside the imported work. Filter imported issues by title/identifier so the assertion captures the intent — that the import created matching issues — without being sensitive to unrelated issues the server produces. Co-Authored-By: Paperclip --- cli/src/__tests__/company-import-export-e2e.test.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/cli/src/__tests__/company-import-export-e2e.test.ts b/cli/src/__tests__/company-import-export-e2e.test.ts index 17adc571292..5e3138aa1d7 100644 --- a/cli/src/__tests__/company-import-export-e2e.test.ts +++ b/cli/src/__tests__/company-import-export-e2e.test.ts @@ -399,9 +399,11 @@ describeEmbeddedPostgres("paperclipai company import/export e2e", () => { `/api/companies/${importedNew.company.id}/issues`, ); + const importedMatchingIssues = importedIssues.filter((issue) => issue.title === sourceIssue.title); + expect(importedAgents.map((agent) => agent.name)).toContain(sourceAgent.name); expect(importedProjects.map((project) => project.name)).toContain(sourceProject.name); - expect(importedIssues.map((issue) => issue.title)).toContain(sourceIssue.title); + expect(importedMatchingIssues).toHaveLength(1); const previewExisting = await runCliJson<{ errors: string[]; @@ -472,10 +474,13 @@ describeEmbeddedPostgres("paperclipai company import/export e2e", () => { `/api/companies/${importedNew.company.id}/issues`, ); + const twiceImportedMatchingIssues = twiceImportedIssues.filter((issue) => issue.title === sourceIssue.title); + expect(twiceImportedAgents).toHaveLength(2); expect(new Set(twiceImportedAgents.map((agent) => agent.name)).size).toBe(2); expect(twiceImportedProjects).toHaveLength(2); - expect(twiceImportedIssues).toHaveLength(2); + expect(twiceImportedMatchingIssues).toHaveLength(2); + expect(new Set(twiceImportedMatchingIssues.map((issue) => issue.identifier)).size).toBe(2); const zipPath = path.join(tempRoot, "exported-company.zip"); const portableFiles: Record = {};