Skip to content

OpenAI's Codex Security CLI and TypeScript SDK for finding, validating, and fixing security vulnerabilities. npm: https://www.npmjs.com/package/@openai/codex-security

test(linear): cover issue comment pagination with SDK connections (#811)

HughChaw764c89b3fd25
diff --git a/sdk/typescript/tests-ts/linear-comment-pagination.test.ts b/sdk/typescript/tests-ts/linear-comment-pagination.test.ts
new file mode 100644
index 000000000..014bbf41c
--- /dev/null
+++ b/sdk/typescript/tests-ts/linear-comment-pagination.test.ts
@@ -0,0 +1,40 @@
+import { expect, test } from "bun:test";
+import { importLinearIssues, type LinearClientFactory } from "../src/linear.js";
+import { paginated } from "./support/linear-pagination.js";
+
+test.each([
+ [0, []],
+ [1, []],
+ [51, ["50"]],
+ [101, ["50", "100"]],
+] as const)(
+ "imports %i issue comments exactly once",
+ async (count, expectedCursors) => {
+ const comments = Array.from({ length: count }, (_, index) => ({
+ body: `Synthetic comment ${index + 1}`,
+ url: `https://linear.app/example/issue/DEMO-1#comment-${index + 1}`,
+ }));
+ const { connection, cursors } = paginated(comments);
+
+ const imported = await importLinearIssues({
+ issues: ["DEMO-1"],
+ environment: { CODEX_SECURITY_LINEAR_API_KEY: "synthetic-key" },
+ linearClient: () =>
+ ({
+ issue: async () => ({
+ identifier: "DEMO-1",
+ title: "Synthetic issue",
+ description: "Synthetic evidence.",
+ url: "https://linear.app/example/issue/DEMO-1",
+ comments: async () => connection,
+ }),
+ }) as unknown as ReturnType<LinearClientFactory>,
+ });
+
+ expect(imported).toHaveLength(1);
+ const importedComments: string[] =
+ imported[0]!.text.match(/Synthetic comment \d+/gu) ?? [];
+ expect(importedComments).toEqual(comments.map(({ body }) => body));
+ expect(cursors).toEqual([...expectedCursors]);
+ },
+);