feat/wave-12-bulk-users #4

Merged
m.mabrey merged 9 commits from feat/wave-12-bulk-users into main 2026-10-06 22:41:39 +00:00
Collaborator

Wave 12 — CR-020: Bulk editing of users

Decision record: docs/waves/decisions-2026-09-17.md (CR-020; open details confirmed 2026-10-06).
Task breakdown and verification record: docs/waves/wave-12.md.

Built on main. Carries only the wave 12 plan from feat/waves-11-13: no wave 11 code, no T13.1.

Changes

Task Change
T12.1 POST /api/auth/bulk-users/{active,role,projects,delete}. Each row runs the same guards and audit as the single-user route; the rules now live once (guard_target, apply_user_*), and the single-user routes call them too. A refused row is reported with its reason; the rest still run. One AuditLog row per changed account.
T12.2 Row checkboxes in the User Directory. Select-all covers only the rows the filter shows. Changing the filter or search clears the selection, and says so. Your own row cannot be selected.
T12.3 Bulk bar: permissions role, enable/disable, add to / remove from one project with a per-project role. Each action confirms with the exact count. The result lists every failed row with the server's reason.
T12.4 "Select from CSV": a file of usernames (first column) becomes the selection. Every rejected line is listed with its line number and reason. The action and its checks are the same as for checkboxes.
T12.5 Bulk delete: the dialog lists every username and sends nothing until DELETE is typed.
T12.6 Verification record, browser probe, screenshots, browser_check.py re-pointed (see below).

Decisions applied (confirmed by Matt, 2026-10-06)

  • Bulk delete needs the typed word DELETE, whatever the count.
  • Project assignment is add/remove to one project; it never replaces a user's whole project list.
  • Changing the filter clears the selection.
  • The CSV holds usernames only; the action is chosen in the bulk bar.
  • A row already in the requested state reports unchanged and writes no audit row.

Verification

  • tests/bulk_users_check.py (new, no browser): 61/61. Against main: every bulk check fails, the 7 single-route checks pass.
  • Single-user routes before and after the refactor, 16 calls (200/400/403/404): identical responses, audit rows and memberships.
  • tests/bulk_users_ui_check.py (new, browser): 19/19. console_dialogs_check.py 16/16 (new section 4: bulk delete prompt). mobile_check.py 24/24. a11y_check.py 22/22. browser_check.py all pass.
  • server/smoketest.py 27/27; server/seed_demo.py runs.
  • Screenshots (after): docs/reference/baseline/wave-12/ at 1440px and 390px.

Review notes

  • browser_check.py was re-pointed, not loosened: it asserted column positions (9 columns; cells[3] and [4]). The new selection column comes first, so it now expects 10 columns and finds cells by header name.
  • tests/cdp.py has the same change as wave 16 (identical content, merges cleanly).
  • No database migration.
## Wave 12 — CR-020: Bulk editing of users Decision record: `docs/waves/decisions-2026-09-17.md` (CR-020; open details confirmed 2026-10-06). Task breakdown and verification record: `docs/waves/wave-12.md`. Built on `main`. Carries only the wave 12 plan from `feat/waves-11-13`: no wave 11 code, no T13.1. ### Changes | Task | Change | |---|---| | T12.1 | `POST /api/auth/bulk-users/{active,role,projects,delete}`. Each row runs the same guards and audit as the single-user route; the rules now live once (`guard_target`, `apply_user_*`), and the single-user routes call them too. A refused row is reported with its reason; the rest still run. One `AuditLog` row per changed account. | | T12.2 | Row checkboxes in the User Directory. Select-all covers only the rows the filter shows. Changing the filter or search clears the selection, and says so. Your own row cannot be selected. | | T12.3 | Bulk bar: permissions role, enable/disable, add to / remove from one project with a per-project role. Each action confirms with the exact count. The result lists every failed row with the server's reason. | | T12.4 | "Select from CSV": a file of usernames (first column) becomes the selection. Every rejected line is listed with its line number and reason. The action and its checks are the same as for checkboxes. | | T12.5 | Bulk delete: the dialog lists every username and sends nothing until `DELETE` is typed. | | T12.6 | Verification record, browser probe, screenshots, `browser_check.py` re-pointed (see below). | ### Decisions applied (confirmed by Matt, 2026-10-06) - Bulk delete needs the typed word `DELETE`, whatever the count. - Project assignment is add/remove to one project; it never replaces a user's whole project list. - Changing the filter clears the selection. - The CSV holds usernames only; the action is chosen in the bulk bar. - A row already in the requested state reports `unchanged` and writes no audit row. ### Verification - `tests/bulk_users_check.py` (new, no browser): 61/61. Against `main`: every bulk check fails, the 7 single-route checks pass. - Single-user routes before and after the refactor, 16 calls (200/400/403/404): identical responses, audit rows and memberships. - `tests/bulk_users_ui_check.py` (new, browser): 19/19. `console_dialogs_check.py` 16/16 (new section 4: bulk delete prompt). `mobile_check.py` 24/24. `a11y_check.py` 22/22. `browser_check.py` all pass. - `server/smoketest.py` 27/27; `server/seed_demo.py` runs. - Screenshots (after): `docs/reference/baseline/wave-12/` at 1440px and 390px. ### Review notes - `browser_check.py` was re-pointed, not loosened: it asserted column positions (9 columns; `cells[3]` and `[4]`). The new selection column comes first, so it now expects 10 columns and finds cells by header name. - `tests/cdp.py` has the same change as wave 16 (identical content, merges cleanly). - No database migration.
m.mabrey added 9 commits 2026-10-06 22:41:16 +00:00
Brings docs/waves/wave-12.md and decisions-2026-09-17.md across from
feat/waves-11-13 (planning docs only, no wave 11 or 13 code), so the
PR into main is wave 12 alone.

Confirmed 2026-10-06 by Matt Mabrey: typed DELETE for bulk delete;
project assignment is add/remove per project; changing the filter
clears the selection; the CSV holds usernames only.
POST /api/auth/bulk-users/{active,role,projects,delete} take a list of
user ids (max 500) and run each row through the same guards and audit
as the single-user route: the rules now live once, in guard_target and
apply_user_{active,role,delete,projects}, which the single-user routes
call too.

- A refused row is reported with its reason; the rest still run; the
  response counts ok / unchanged / failed. Never a blanket success.
- The caller's own account is refused only on its own row.
- One AuditLog row per changed account, same action and shape as the
  single route. A row already in the requested state is 'unchanged'
  and writes no audit row.
- Project assignment is add/remove to ONE project with a per-project
  role (confirmed 2026-10-06); roles on the user's other projects are
  carried over as stored.
- Routes sit under /api/auth/bulk-users/ because /api/auth/users/bulk/
  would match {user_id}='bulk'.

New tests/bulk_users_check.py (no browser): 47/47. Against main: the
7 single-route checks pass, every bulk check fails.
Single-user routes compared before/after on 16 calls (200/400/403/404):
identical responses, audit rows and memberships. Smoke test 27/27.
- A checkbox per row the caller may change; select-all covers only the
  rows the current filter and search show, and is indeterminate on a
  partial selection.
- Your own row and rows you cannot change show a disabled box whose
  label gives the reason.
- Changing the filter or the search clears the selection and says so
  in a live region (decided 2026-10-06), so no hidden row stays
  selected.
- The bulk bar appears at one or more selected rows and is hidden (out
  of the tab order) at zero. Actions arrive in T12.3.
- Selection is updated in place, not by re-rendering, so focus stays on
  the checkbox just used. One delegated listener; no ids in inline
  handlers.
- The email-width rule now targets td.ell, not nth-child(3), which the
  new column would have shifted.

Checked in a DOM harness (jsdom) against the real page and scripts:
14/14; against main the selection checks fail. Browser probe at
390px/1440px follows in T12.6.
Role change, enable/disable, and project add/remove on the selected
rows, wired to the T12.1 endpoints. Delete is T12.5.

- The toolbar offers only what the caller may do: grantable roles,
  managed projects (archived last, marked), grantable per-project roles.
- Every action confirms through wpConfirmDialog naming the exact count
  (and for projects, the project and role) before anything is sent.
- The result lists every failed row with the server's reason, plus the
  changed / already-set counts; a partial failure is a warning, an
  all-failed batch an alert, a server error says nothing was changed.
  Never a blanket success. Announced through the live-region banner.
- The directory reloads afterwards, which clears the selection.

DOM harness (jsdom, real page and scripts, mocked API): 30/30 with
T12.2.
POST /api/auth/bulk-users/resolve reads a list of usernames (first
column; comma, semicolon or tab; header skipped) and answers line by
line, the CR-005 validate-and-report pattern. A line is rejected, with
its number and reason, when it names nobody the caller can see ('User
not found', as everywhere else), an account they may not change (the
single route's own reason), their own account, or a username already
listed (duplicate of line N). An email address resolves only when
exactly one account has it. Nothing is changed by this route.

The console's 'Select from CSV' turns the accepted accounts into the
ordinary selection (filter reset so every selected row is visible) and
lists every rejected line. The action, confirm and per-row report are
the checkbox ones, through the same T12.1 routes, which re-check each
row: a CSV cannot reach an account a checkbox could not.
Usernames only, action in the toolbar (decided 2026-10-06). Files over
1 MB are refused before upload; FileReader fallback for browsers
without Blob.text().

bulk_users_check.py: 61/61. DOM harness: 40/40.
'Delete selected…' in the bulk bar. The dialog lists every affected
username (scrolling inside the dialog for a long list), says the
delete cannot be undone and offers disable instead, and sends nothing
until the word DELETE is typed in capitals, whatever the count
(confirmed 2026-10-06). Wrong words keep the dialog open with the
reason; cancel sends nothing.

Your own account cannot be selected; if it ever reached the request,
the server refuses that row and the report names it with the reason.

The bulk delete is a prompt-style dialog, so it is covered in
tests/console_dialogs_check.py (its docstring asks for exactly this):
new section 4 drives it in the browser with native dialogs poisoned.
DOM harness: 48/48.
- tests/bulk_users_ui_check.py (new): selection, keyboard Space on a
  row box, toolbar role change, super-user CSV with good and bad lines,
  add-to-project with a role, typed DELETE, all end to end against a
  real server; 390px bar layout; writes after-screenshots to
  docs/reference/baseline/wave-12/. Needs a browser: to be run on
  Matt's machine.
- tests/cdp.py: --do-not-de-elevate and the rc=0 grace, the same
  change as wave 16 T16.4 (identical content, merges cleanly), so the
  probes start from an elevated shell on this branch too.
- Verification record in wave-12.md: bulk_users_check 61/61 (main
  7/18), single-user routes identical before/after on 16 calls, DOM
  harness 48/48, jsdom against a real server 13/13, smoke 27/27,
  seed_demo OK. Server-checkable done-when boxes ticked; the browser,
  screenshot and full-suite boxes stay open until run on Edge.
- BL-060 logged: a super user's refusal reason promises a project
  access change neither the dialog nor the bulk route allows. Needs
  Nick; not fixed here (scope).
- file-map.md: wave 12's two new checks.
Matt's run (Edge/Chrome, one at a time): bulk_users_ui_check 19/19,
console_dialogs_check 16/16, mobile_check 24/24, a11y_check 22/22.

browser_check 67/71: its four failures asserted column POSITIONS
(9 columns; r.cells[3]/[4] for Permissions/Project role). CR-020's
selection column comes first, so those read Username and Email. The
probe now expects 10 columns with the selection column first, finds
the cells by header name, and checks your own row has no selection
box. Verified on the real page in the DOM harness; rerun to close.

After-screenshots committed in docs/reference/baseline/wave-12/.
BL-061 logged: the pre-existing sync badge covers a control for ~2 s
after load (pointer-events:none, so never blocks a click); belongs
with wave 14's badge work.
Matt reran tests/browser_check.py on the re-pointed probe: all
passed. Every T12 done-when and every wave 12 exit criterion is now
checked in wave-12.md.
m.mabrey merged commit d42ae0c65b into main 2026-10-06 22:41:39 +00:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: n.siegfried/Project-SDE-WP-Suite#4
No description provided.