Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@makeplane/plane-node-sdk",
"version": "0.2.9",
"version": "0.2.10",
"description": "Node SDK for Plane",
"author": "Plane <engineering@plane.so>",
"repository": {
Expand Down
1 change: 1 addition & 0 deletions src/models/WorkItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ export interface ListWorkItemsParams {
assignee?: string;
limit?: number;
offset?: number;
pql?: string;
}

export interface WorkItemActivity {
Expand Down
32 changes: 32 additions & 0 deletions tests/unit/work-items/work-items.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,38 @@ describe(!!(config.workspaceSlug && config.projectId && config.userId), "Work It
expect(foundWorkItem).toBeDefined();
});

it("should list work items with pql filter", async () => {
const name = randomizeName();
let pqlWorkItem: WorkItem | undefined;

try {
pqlWorkItem = await client.workItems.create(workspaceSlug, projectId, {
name,
priority: "high",
});

const filtered = await client.workItems.list(workspaceSlug, projectId, {
pql: 'priority IN ("high")',
});

expect(filtered).toBeDefined();
expect(Array.isArray(filtered.results)).toBe(true);
expect(filtered.results.length).toBeGreaterThan(0);
expect(filtered.results.find((wi) => wi.id === pqlWorkItem!.id)).toBeDefined();
for (const wi of filtered.results) {
Comment on lines +95 to +103
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Make the PQL assertion deterministic to avoid pagination-related flakiness.

The filter priority IN ("high") is broad, so on busy projects your created item may not be in the returned page even when PQL works, causing intermittent failures (Line 95–103). Narrow the query to the created entity (e.g., include name/identifier in PQL) or set explicit pagination/sorting to ensure the created item is in-scope.

💡 Suggested test hardening
-      const filtered = await client.workItems.list(workspaceSlug, projectId, {
-        pql: 'priority IN ("high")',
-      });
+      const filtered = await client.workItems.list(workspaceSlug, projectId, {
+        // Keep the PQL test focused on the created fixture and avoid page-order flakiness.
+        pql: `priority IN ("high") AND name = "${name}"`,
+      });
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const filtered = await client.workItems.list(workspaceSlug, projectId, {
pql: 'priority IN ("high")',
});
expect(filtered).toBeDefined();
expect(Array.isArray(filtered.results)).toBe(true);
expect(filtered.results.length).toBeGreaterThan(0);
expect(filtered.results.find((wi) => wi.id === pqlWorkItem!.id)).toBeDefined();
for (const wi of filtered.results) {
const filtered = await client.workItems.list(workspaceSlug, projectId, {
// Keep the PQL test focused on the created fixture and avoid page-order flakiness.
pql: `priority IN ("high") AND name = "${name}"`,
});
expect(filtered).toBeDefined();
expect(Array.isArray(filtered.results)).toBe(true);
expect(filtered.results.length).toBeGreaterThan(0);
expect(filtered.results.find((wi) => wi.id === pqlWorkItem!.id)).toBeDefined();
for (const wi of filtered.results) {
🧰 Tools
🪛 ESLint

[error] 99-99: 'expect' is not defined.

(no-undef)


[error] 100-100: 'expect' is not defined.

(no-undef)


[error] 101-101: 'expect' is not defined.

(no-undef)


[error] 102-102: 'expect' is not defined.

(no-undef)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/unit/work-items/work-items.test.ts` around lines 95 - 103, The PQL test
is non-deterministic because 'priority IN ("high")' can return many items across
pages; change the call to client.workItems.list (used with workspaceSlug,
projectId) to either include a PQL clause that uniquely identifies the created
test item (e.g., add name or id: `priority IN ("high") AND name = "..."` or use
the test-created identifier stored in pqlWorkItem) or set explicit
pagination/sorting so the created item is guaranteed to appear (e.g., request a
sufficiently large page size and sort by created/updated timestamp descending).
Update the test assertions to use that tightened PQL or pagination to reliably
find pqlWorkItem in filtered.results.

expect(wi.priority).toBe("high");
}
} finally {
if (pqlWorkItem?.id) {
try {
await client.workItems.delete(workspaceSlug, projectId, pqlWorkItem.id);
} catch {
// Best-effort cleanup to avoid polluting subsequent test runs.
}
}
}
});

it("should retrieve work item by identifier", async () => {
const project = await client.projects.retrieve(workspaceSlug, projectId);
const workItemByIdentifier = await client.workItems.retrieveByIdentifier(
Expand Down
Loading