Commit initial
This commit is contained in:
@@ -0,0 +1,89 @@
|
||||
---
|
||||
phase: 11-ui-enhancements
|
||||
plan: "01"
|
||||
subsystem: printer-ui
|
||||
tags: [uie-02, tdd, htmx, templates, redirect]
|
||||
dependency_graph:
|
||||
requires: []
|
||||
provides: [GET /printers/new, POST /printers 303 redirect, Wave 0 test scaffolds]
|
||||
affects: [imptune/api/pages.py, imptune/api/printers.py, imptune/templates/printers.html, tests/test_printer_crud.py]
|
||||
tech_stack:
|
||||
added: []
|
||||
patterns: [PRG (Post/Redirect/Get), plain HTML form for browser redirect, TDD RED-GREEN]
|
||||
key_files:
|
||||
created:
|
||||
- imptune/templates/printers_new.html
|
||||
modified:
|
||||
- imptune/templates/printers.html
|
||||
- imptune/api/pages.py
|
||||
- imptune/api/printers.py
|
||||
- tests/test_printer_crud.py
|
||||
- tests/test_printer_form.py
|
||||
decisions:
|
||||
- "Used Option A for printers_new.html: inline form markup without hx-post, using plain <form action=/printers method=post> so browser follows 303 redirect naturally"
|
||||
- "driver_data context kept in GET /printers handler for future Plan 02 edit modal"
|
||||
- "GET /printers/new route placed between GET /printers and GET /printers/{id} to avoid ambiguity"
|
||||
metrics:
|
||||
duration: "~4 minutes"
|
||||
completed: "2026-04-15"
|
||||
tasks_completed: 2
|
||||
tasks_total: 2
|
||||
files_modified: 6
|
||||
---
|
||||
|
||||
# Phase 11 Plan 01: Separate Add Printer Form from Library (UIE-02) Summary
|
||||
|
||||
**One-liner:** Dedicated `/printers/new` page with plain POST form + PRG redirect replacing inline form in printer library.
|
||||
|
||||
## What Was Built
|
||||
|
||||
UIE-02 is now complete: the Add Printer form is separated from the Printer Library. Users navigate to `/printers/new` to add a printer. After submission, the browser follows a 303 redirect back to `/printers` (Post/Redirect/Get pattern).
|
||||
|
||||
### Key Changes
|
||||
|
||||
- **`imptune/templates/printers_new.html`** (new): Full page extending `base.html`. Contains a plain `<form action="/printers" method="post">` (no HTMX) so the browser follows the 303 redirect. Also includes the driver upload sub-form (HTMX preserved for that). Context: `clients`, `driver_data`.
|
||||
- **`imptune/templates/printers.html`**: Removed the inline `{% include "partials/printer_form.html" %}` section. Added `<a href="/printers/new" role="button">Add Printer</a>` link.
|
||||
- **`imptune/api/pages.py`**: Added `GET /printers/new` → `printers_new_page()`. Route placed before `GET /printers/{printer_id}`.
|
||||
- **`imptune/api/printers.py`**: `POST /printers` now returns `RedirectResponse(url="/printers", status_code=303)` instead of `_render_printer_list()`.
|
||||
- **`tests/test_printer_crud.py`**: All existing POST tests updated to `follow_redirects=False` + `assert resp.status_code == 303`. 8 Wave 0 scaffold tests added.
|
||||
- **`tests/test_printer_form.py`**: Updated to check `/printers/new` instead of `/printers` (reflects UIE-02 architecture change).
|
||||
|
||||
## Test Results
|
||||
|
||||
| Suite | Status |
|
||||
|-------|--------|
|
||||
| UIE-02 tests (printers_new, redirects, library_no_form) | GREEN |
|
||||
| All existing printer CRUD tests | GREEN |
|
||||
| test_printer_form.py | GREEN |
|
||||
| UIE-01 scaffolds (patch_printer, patch_printer_not_found) | RED (expected — Plan 02) |
|
||||
| UIE-03 scaffolds (client_detail_returns_200, client_links) | RED (expected — Plan 03) |
|
||||
| Full suite (excluding e2e) | 117 passed, 4 expected RED |
|
||||
|
||||
## Commits
|
||||
|
||||
| Hash | Message |
|
||||
|------|---------|
|
||||
| `a02df7d` | test(11-01): add Wave 0 RED scaffolds for UIE-01/02/03 |
|
||||
| `3d2cdc4` | feat(11-01): UIE-02 — dedicated Add Printer page at GET /printers/new |
|
||||
|
||||
## Deviations from Plan
|
||||
|
||||
### Auto-fixed Issues
|
||||
|
||||
**1. [Rule 1 - Bug] Updated test_printer_form.py to match UIE-02 architecture**
|
||||
- **Found during:** Task 2 — full test suite run
|
||||
- **Issue:** `test_printer_form.py::test_printer_form_has_inline_driver_upload` checked for `id="printer-form-driver-select"`, `hx-post="/drivers/upload"`, and form elements on GET `/printers`. After removing the inline form from `/printers`, this test failed.
|
||||
- **Fix:** Updated `test_printer_form.py` to check GET `/printers/new` instead of GET `/printers`. Also updated assertions to match new plain-form architecture (`action="/printers"`, `method="post"` instead of `hx-post="/printers"`).
|
||||
- **Files modified:** `tests/test_printer_form.py`
|
||||
- **Commit:** `3d2cdc4`
|
||||
|
||||
## Success Criteria Check
|
||||
|
||||
- [x] GET /printers/new returns 200 with the Add Printer form (all printer fields present)
|
||||
- [x] POST /printers returns 303 redirect to /printers (confirmed by test)
|
||||
- [x] GET /printers does NOT contain the Add Printer form markup
|
||||
- [x] GET /printers contains a link to /printers/new
|
||||
- [x] All existing tests in test_printer_crud.py pass (adjusted for 303 on POST)
|
||||
- [x] Wave 0 scaffolds for UIE-01 and UIE-03 exist in test_printer_crud.py (RED, not ERROR)
|
||||
|
||||
## Self-Check: PASSED
|
||||
Reference in New Issue
Block a user