refactor(shared): move the accept/reject decision into planFileSelection (RB-26)

createUploadController required inject(), an effect(), and a window listener
before a test could reach it. The file-selection policy trapped behind that
cost now lives in a pure function, planFileSelection, in upload.machine.ts.

planFileSelection takes plain { name, type, size } objects, not File, and
decides per file whether to reject it or accept it, with no I/O. The
controller executes the plan: it dispatches a rejection as-is, and starts the
upload for an accepted file (the one step that needs crypto.randomUUID()).

A new spec covers the three outcomes: the 'multiple' batch rejection, a
rejectReason-based rejection, and the accept case, plus order in a mixed
batch. Verified red-then-green with a temporary stub, undone by a second edit.

No change to the controller's public surface or to the calling organism.
previewUrlFor (added by RB-24) is untouched.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
eho
2026-08-28 08:28:30 +02:00
co-authored by Claude Opus 5
parent 693016445b
commit 95bb77395e
6 changed files with 284 additions and 48 deletions
+11 -1
View File
@@ -20,7 +20,7 @@ tested where._
Every bullet below is a real test name from the suite — an `it()` title (frontend) or a test
method name (backend), read as a sentence. Nothing here is hand-written prose: this page
**is** the suite, reshaped for a business reader. 467 frontend behaviours across
**is** the suite, reshaped for a business reader. 474 frontend behaviours across
9 contexts; 238 backend behaviours across 41 test
classes.
@@ -798,6 +798,16 @@ classes.
- maskTail keeps the requested tail length
- masks the whole value when it is not longer than the kept tail
#### planFileSelection
- plans nothing for an unknown category
- rejects the whole batch with reason "multiple" for a single-file category
- does not reject a single file against a single-file category
- rejects one file via rejectReason (wrong type)
- rejects one file via rejectReason (too large)
- plans a FileSelected entry for a file that passes format validation
- judges each file independently and preserves order for a mixed multiple-file category
#### problemDetail
- extracts the detail from an RFC-7807 ProblemDetails