Stabilize company import issue assertions

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 <noreply@paperclip.ing>
This commit is contained in:
DottaandPaperclip committed 2026-04-24 15:12:54 -05:00
1 parent 6941171684
commit f4753fb024
1 file changed
+7 -2
@@ -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<string, string> = {};