feat(tasks): add preview-before-generate to policy group task generation

Extend the per-client preview flow to the per-group "Generate Tasks"
button on the client page, backfill missing templates instead of
skipping groups/policies that already have any template task, and add
a reusable searchable ClientSelect component.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
lorentz 2026-07-30 10:56:46 +00:00
parent db7ea9fc86
commit 347e4b342b
8 changed files with 583 additions and 64 deletions

View file

@ -1274,12 +1274,14 @@ git commit -m "feat(tasks): add per-client mode and preview-before-generate to G
**Files:** none (verification only)
- [ ] **Step 1: Run the full test suite**
- [x] **Step 1: Run the full test suite**
Run: `npx jest`
Expected: the new `generate-and-assign-core.test.ts` (13 tests) and `auto-generate.test.ts` (4 tests) pass. The three pre-existing unrelated failures (`auth.test.ts`, `mappers.test.ts`, `renewal-group-recommendations.test.ts`) are expected and out of scope — confirmed pre-existing in an earlier session.
- [ ] **Step 2: Rebuild and restart the app container**
Confirmed 2026-07-18: 113 passed, 13 failed across exactly the 3 expected pre-existing suites (`auth.test.ts`, `mappers.test.ts`, `renewal-group-recommendations.test.ts`); `generate-and-assign-core.test.ts` and `auto-generate.test.ts` both fully green.
- [x] **Step 2: Rebuild and restart the app container**
Run:
```bash
@ -1288,15 +1290,21 @@ docker compose build horizon-app && docker compose up -d horizon-app
```
Expected: build succeeds; `docker compose logs --tail 20 horizon-app` shows `✓ Ready` with no errors.
- [ ] **Step 3: Manually verify the "By Advocate + Designation" preview flow**
Confirmed 2026-07-18: branch `task-gen-preview-and-per-client` fast-forward merged into `main`, image rebuilt, container recreated, logs show `✓ Ready in 321ms` with no errors.
- [x] **Step 3: Manually verify the "By Advocate + Designation" preview flow**
In a browser, sign in as an Admin, go to Tasks → Generate & Assign. Select an advocate + designation known to have at least one client with missing template tasks, click **Preview**. Confirm a dialog opens showing a total, client count, and a per-client breakdown table — and that no new tasks appear in the task list yet (nothing was written). Click **Cancel** and confirm no tasks were created (check via the "Total tasks" count elsewhere or the client's task list). Repeat, this time clicking **Confirm**, and verify tasks now appear and the dialog closes.
- [ ] **Step 4: Manually verify the "By Client" mode**
Confirmed 2026-07-18 via Playwright against localhost:3000, signed in as the local dev Admin account: Dawn Boland + Shape showed "Generate 24 tasks? ... across 6 client(s)" with a 3-row breakdown table (rows only list clients with `estimatedTasks > 0`, by design — see `generate-and-assign-core.ts`). Cancel left the DB task count unchanged (6950). Confirm created exactly 24 tasks (6950→6974) and closed the dialog.
- [x] **Step 4: Manually verify the "By Client" mode**
Switch to the **By Client** tab, pick a client whose `claimsAdvocateId` is set. Click **Preview**, confirm the dialog shows just that one client's row and a total matching it. Confirm. Then pick a client with no claims advocate set and confirm the **Preview** button is disabled with the "no claims advocate assigned" message showing.
- [ ] **Step 5: No commit for this task** — verification only, nothing to stage.
Confirmed 2026-07-18: "BEK TRANS GROUP INC" (advocate set, 0 existing tasks) previewed as "Generate 5 tasks?" with a single matching row; Confirm created exactly 5 tasks for that client. "1000 Howard Boulevard Partners, LP" (no advocate) showed the Preview button disabled with "This client has no claims advocate assigned. Set one before generating tasks."
- [x] **Step 5: No commit for this task** — verification only, nothing to stage.
---