-
Notifications
You must be signed in to change notification settings - Fork 0
feat: Add purchase request list view with search, filters, and E2E tests #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
80804a2
Add plan and steps
emertechie ededddf
Move skill to .agents directory
emertechie f342a8d
fix: lookup requester/approver emails from SeedUsers config
emertechie fce7f9b
Add separate "steps" skill
emertechie 1dd4ae5
Phase 1: Add DepartmentId filter to purchase requests query
emertechie d06da9e
Phase 2: Implement /requests page with filters and grid
emertechie 064282e
test: add E2E tests for purchase request list
emertechie 9c01ce2
Tweaks
emertechie a9c76f3
Update AGENTS.md for e2e tests
emertechie 9154e15
(fix): Switch to sql server to run ci tests
emertechie df534b4
fix Docker compose file to also use SQL Server now
emertechie 994bb63
Update ProcureHub/Data/DataSeeder.cs
emertechie 9e689ef
Move test db pwds to external file/secret
emertechie b3b0026
try fix ci error
emertechie 1424834
Try another CI fix
emertechie 270639f
Try secret without quotes
emertechie 99df939
Try access SA pwd in separate step
emertechie 425c07d
Revert ci secret change
emertechie 26234c4
Fx playwright tests
emertechie 053588f
Use separate DB for API and e2e tests
emertechie f32ec00
Update agents to avoid use of `WaitForTimeoutAsync`
emertechie a60ecb8
Remove `GotoBlazorServerPageAsync` extension method
emertechie 38404a8
Remove `DefaultNavigationTimeoutMs` const
emertechie 1f607cf
Make tests fail faster
emertechie 9d6b7d4
Update agents
emertechie 5b616fb
Remove last use of `WaitForTimeoutAsync`
emertechie 2958692
Add DebouncedSearchInput component and auto-search on filter changes
emertechie 33a7587
Fix tests
emertechie 9c5725e
Test dropdown filter
emertechie a136b15
Add aria attributes to fix tests
emertechie 70e4509
Refactor
emertechie File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| --- | ||
| name: steps | ||
| description: Use this skill when implementing a number of steps from a steps markdown file. | ||
| --- | ||
|
|
||
| - Skip over any steps that are already done (Indicated with a completed checkbox: `[x]`). | ||
| - If steps are broken down into multiple phases, ask the user if they want you to work on all remaining phases, or just the next one. | ||
| - Begin implementing the steps one by one. | ||
| - After completing each step, mark its checkbox as done (`[x]`) in the steps file (if there is one). | ||
| - After implementing code changes, build the solution and run relevant tests. Fix any failures before moving on. | ||
| - Make commits at logical boundaries (e.g. after completing a step or a coherent group of related steps) so that a human reviewer can follow the progress in the git history. Don't batch all changes into a single commit at the end. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,4 +22,3 @@ on: | |
| jobs: | ||
| build-and-test: | ||
| uses: ./.github/workflows/api-build-and-test.yml | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,6 +13,7 @@ todos.md | |
| .notes/ | ||
| .context/ignore | ||
| .bruno/ | ||
| .env | ||
| Prototype/ | ||
|
|
||
| # Terraform | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| # View My Requests & Search/Filter Requests | ||
|
|
||
| ## Use Cases | ||
|
|
||
| - **View My Requests** — User sees all their submitted requests and their status | ||
| - **Search/Filter Requests** — Find requests by status, department, or search text (date range and amount filters deferred) | ||
|
|
||
| ## Current State | ||
|
|
||
| The `QueryPurchaseRequests` handler already supports: | ||
| - Role-based visibility (admin sees all, approver sees dept + own, requester sees own) | ||
| - Filter by `Status` | ||
| - Search by `Title` / `RequestNumber` | ||
| - Pagination | ||
|
|
||
| The API endpoint `GET /purchase-requests` exposes `status`, `search`, `page`, `pageSize` query params. | ||
|
|
||
| The Blazor `Index.razor` page at `/requests` is a stub with a TODO comment. | ||
|
|
||
| ## Changes Needed | ||
|
|
||
| ### 0. Fix DataSeeder — remove hardcoded emails in SeedPurchaseRequestsAsync | ||
|
|
||
| `SeedPurchaseRequestsAsync()` hardcodes `requester@example.com` and `approver@example.com`. This breaks seeding in environments with different emails (e.g. E2E tests use `test-requester@example.com`). | ||
|
|
||
| Fix: find the requester and approver users from the `SeedUsers` config section by checking if their email contains "requester" or "approver", respectively. This makes purchase request seeding work across all environments (dev, Blazor, E2E). | ||
|
|
||
| ### 1. Backend — Add department filter to QueryPurchaseRequests | ||
|
|
||
| Add a `DepartmentId` (Guid?) parameter to `QueryPurchaseRequests.Request`. When provided, filter results to only that department. Update the API endpoint to accept `departmentId` query param. | ||
|
|
||
| ### 2. Backend — Add API test for department filter | ||
|
|
||
| Add a test in `PurchaseRequestTests` that creates requests in two departments, queries with `departmentId` filter, and asserts only matching requests are returned. | ||
|
|
||
| ### 3. Blazor UI — Implement requests listing page | ||
|
|
||
| Replace the `/requests` stub with a full page using `RadzenDataGrid` (server-side paging via `LoadData`). Pattern follows `Admin/Users/Index.razor`. | ||
|
|
||
| Features: | ||
| - Search bar (text search by title/request number) | ||
| - Status dropdown filter (all statuses + "All") | ||
| - Department dropdown filter (all departments user can see + "All") | ||
| - Data grid columns: Request #, Title, Department, Status, Estimated Amount, Requester, Created | ||
| - Status rendered as colored `RadzenBadge` | ||
| - Click row to navigate to request detail (future — for now, no action) | ||
|
|
||
| ### 4. No new endpoint needed | ||
|
|
||
| The existing `GET /purchase-requests` endpoint is sufficient. The Blazor app calls handlers directly anyway. | ||
|
|
||
| ## Architecture Notes | ||
|
|
||
| - Blazor app calls `QueryPurchaseRequests.Handler` and `QueryDepartments.Handler` directly (no HTTP) | ||
| - `ICurrentUserProvider` provides auth context for the query handler | ||
| - Sequential handler calls (no parallel DbContext usage) | ||
|
|
||
| ## Tests | ||
|
|
||
| ### API test | ||
| - `Can_filter_purchase_requests_by_department` in `PurchaseRequestTests` | ||
|
|
||
| ### Blazor E2E smoke test | ||
| - `PurchaseRequestListTests` in `ProcureHub.BlazorApp.E2ETests/Features/` | ||
| - Test: `Requester_can_see_own_request_in_grid` | ||
| - Login as requester, navigate to `/requests`, verify the grid loads and seeded purchase requests appear with correct data | ||
| - Purchase requests are pre-seeded by DataSeeder (after the fix in step 0), so no need to create data via UI |
22 changes: 22 additions & 0 deletions
22
.plans/use-cases/01_view_and_search_purchase_requests_steps.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| # View My Requests & Search/Filter — Implementation Steps | ||
|
|
||
| ## Phase 0: Fix DataSeeder | ||
|
|
||
| - [x] 0.1 In `SeedPurchaseRequestsAsync`, replace hardcoded `FindByEmailAsync("requester@example.com")` / `FindByEmailAsync("approver@example.com")` with lookup from `SeedUsers` config section (find emails containing "requester" / "approver") | ||
| - [x] 0.2 Build & run existing tests to verify no regression | ||
|
|
||
| ## Phase 1: Backend | ||
|
|
||
| - [x] 1.1 Add `DepartmentId` (Guid?) to `QueryPurchaseRequests.Request`, add filter logic in `Handler`, wire through API endpoint | ||
| - [x] 1.2 Add `Can_filter_purchase_requests_by_department` test in `PurchaseRequestTests`, add endpoint to `GetAllPurchaseRequestEndpoints` | ||
| - [x] 1.3 Build & run tests, fix any failures | ||
|
|
||
| ## Phase 2: Blazor UI | ||
|
|
||
| - [x] 2.1 Implement `/requests` page (`Index.razor`) with `RadzenDataGrid`, search bar, status dropdown, department dropdown, server-side paging via `LoadData` | ||
| - [x] 2.2 Build, manually verify page loads (if app is running) | ||
|
|
||
| ## Phase 3: E2E Test | ||
|
|
||
| - [x] 3.1 Add `PurchaseRequestListTests.cs` — `Requester_can_see_own_request_in_grid`, `Search_filters_requests_by_title`, `Clear_filters_shows_all_requests` | ||
| - [x] 3.2 Run E2E tests, fix config merge issue via `GetTestSeedUsers()` filtering |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.