[WEB-6816]chore: added support for pql filters#39
[WEB-6816]chore: added support for pql filters#39sangeethailango wants to merge 4 commits intomainfrom
Conversation
|
Linked to Plane Work Item(s) This comment was auto-generated by Plane |
There was a problem hiding this comment.
Pull request overview
Adds SDK support for filtering work item listings via PQL by extending the list params type and introducing a unit test to validate the behavior.
Changes:
- Added optional
pqltoListWorkItemsParamsforworkItems.list(...)query filtering. - Added a unit test that exercises listing work items with a PQL filter.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/models/WorkItem.ts |
Extends list params typing to include pql for PQL-based filtering. |
tests/unit/work-items/work-items.test.ts |
Adds a test case for pql filtering when listing work items. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const allWorkItems = await client.workItems.list(workspaceSlug, projectId); | ||
| const priority = allWorkItems.results[0]?.priority ?? "none"; | ||
|
|
||
| const filtered = await client.workItems.list(workspaceSlug, projectId, { | ||
| pql: `priority IN ("${priority}")`, | ||
| }); |
There was a problem hiding this comment.
This test can produce false positives: if the first listed work item has no priority (or a value not supported by PQL), the fallback to "none" can yield an empty filtered result set, and the assertions still pass because the loop doesn’t run. Consider making the test deterministic by setting a known priority on the created workItem (or selecting a work item with a defined priority) and building the PQL from that known value.
|
Warning Rate limit exceeded
Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 11 minutes and 49 seconds. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughAdds an optional Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/models/WorkItem.ts`:
- Around line 51-52: The file has Prettier formatting violations around the
expanded mapped type for WorkItem (the line referencing WorkItemExpandableFields
and the mapped type for Expanded/WorkItem); run your formatter (prettier) to
reformat src/models/WorkItem.ts and fix spacing/semicolons so the mapped type
line for [K in Expanded]: K extends keyof WorkItemExpandableFields ?
WorkItemExpandableFields[K] : never; matches project style, then commit the
formatted file.
In `@tests/unit/work-items/work-items.test.ts`:
- Around line 93-97: The test currently can pass vacuously when filtered.results
is empty; after verifying filtered and that filtered.results is an array, add an
assertion that filtered.results.length is greater than 0 to ensure at least one
item is returned, then continue the existing loop asserting each wi.priority
equals the expected priority (references: filtered, filtered.results, priority).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: c665f4e4-0733-4ab0-9de4-41538a4a4f3b
📒 Files selected for processing (2)
src/models/WorkItem.tstests/unit/work-items/work-items.test.ts
There was a problem hiding this comment.
🧹 Nitpick comments (1)
tests/unit/work-items/work-items.test.ts (1)
85-105: Ensure created test data is always cleaned up (Line 104).If any assertion fails before Line 104,
pqlWorkItemis not deleted. Wrap assertions intry/finallyso cleanup always runs.Proposed refactor
it("should list work items with pql filter", async () => { const name = randomizeName(); const 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) { - expect(wi.priority).toBe("high"); - } - - await client.workItems.delete(workspaceSlug, projectId, pqlWorkItem.id!); + try { + 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) { + expect(wi.priority).toBe("high"); + } + } finally { + await client.workItems.delete(workspaceSlug, projectId, pqlWorkItem.id!); + } });🤖 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 85 - 105, The test "should list work items with pql filter" creates pqlWorkItem via client.workItems.create but deletes it only at the end, so if an assertion throws the created item may leak; wrap the assertions (the body between creation and deletion) in a try/finally and perform client.workItems.delete(workspaceSlug, projectId, pqlWorkItem.id!) in the finally block, guarding the delete with a check that pqlWorkItem and pqlWorkItem.id are defined to avoid runtime errors; this ensures cleanup even if any expect calls fail.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@tests/unit/work-items/work-items.test.ts`:
- Around line 85-105: The test "should list work items with pql filter" creates
pqlWorkItem via client.workItems.create but deletes it only at the end, so if an
assertion throws the created item may leak; wrap the assertions (the body
between creation and deletion) in a try/finally and perform
client.workItems.delete(workspaceSlug, projectId, pqlWorkItem.id!) in the
finally block, guarding the delete with a check that pqlWorkItem and
pqlWorkItem.id are defined to avoid runtime errors; this ensures cleanup even if
any expect calls fail.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 6900ada8-f485-43a9-8052-4e6f7765fadd
📒 Files selected for processing (2)
src/models/WorkItem.tstests/unit/work-items/work-items.test.ts
✅ Files skipped from review due to trivial changes (1)
- src/models/WorkItem.ts
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This pull request adds support for filtering work items using PQL (Project Query Language) in the work items API. The main changes introduce a new
pqlparameter to the work item listing functionality and include a corresponding unit test to ensure the filter works as expected.API Enhancements:
pqlparameter to theListWorkItemsParamsinterface insrc/models/WorkItem.ts, enabling clients to filter work items using PQL queries.Testing Improvements:
work-items.test.tsto verify that thepqlfilter returns only work items matching the specified criteria.Summary by CodeRabbit
New Features
Tests