Repository navigation
[ttp1-ts] Single current-batch screen with per-file cards (TTP task 1) - #23
Merged
Merged
Conversation
Move the print-shop portal from the v1 per-order API to the frozen v2 batch contract (monorepo-incluir #1053 @ 27022467): - Home `/` is the ONE current batch (open, or the active collected…printed batch, since /batches/open is null then): header with reference/status/counts, progress bar, one card per file grouped under its request, residual "Instruções gerais" per request, and the backend's previouslyCancelledIn warning. Empty state "Nenhum pedido aguardando". - State-driven batch actions with explicit confirmation, If-Match = batch ETag and an Idempotency-Key kept across ambiguous retries: "Retirei os arquivos" (checkbox + dialog; 412 re-renders the changed batch and needs reconfirmation), one quote for the whole batch, "Marcar como impresso". Waiting states show their message and no action. - "Lotes anteriores" history with a read-only detail using the same cards; "Notas fiscais" reads v2 monthly closes (batch + legacy charges). - Old order list/detail screens and per-order commands are removed; the BFF JSON API now mirrors /api/print-portal/v2 as /api/print/v2. - Neutral data-ttp smoke markers on the real rendered components. Tests go through the real Hono app/HTTP boundaries, seeded with the frozen fixture and its real PDFs; the PrintApi conformance suite runs on both the memory fake and the HTTP adapter. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Quote and NF parts went upstream as untyped Blobs; the v2 upstream (and the pinned staging fake) refuses a declared type that differs from the sniffed content with 415, so every valid PDF quote/NF failed in staging. The HTTP adapter now labels the part with the type its magic bytes show (PDF/JPEG/PNG/WebP, else octet-stream so upstream still answers 415), independent of what the browser declared. The HTTP test fake now enforces declared == sniffed like upstream, which turned the HTTP conformance quote/NF cases red first; a new end-to-end test drives the HTML quote and NF forms through PrintApiHttp. The sniffer is a pure domain function shared with the memory fake. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
TTP task 1 (trial ttp1-ts): replace "list of orders → open one order" with one home screen showing the current print batch, against the frozen v2 contract (monorepo-incluir #1053 @ 27022467). No backend/contract change, no new dependency.
What changed
PrintApinow speaks/api/print-portal/v2(batches, open batch, member file/quote downloads, collected/quotes/printed commands, v2 monthly closes). Zod mirror of every v2$def(strict, plus the itemCount/unique-order/each-file-once invariants). HTTP adapter keeps the same hardening (fixed origin, no redirects, timeouts, size caps, strict parsing). Memory fake reimplements the batch rules (one current batch per supplier, queued requests, receipt/cancellation forming the next batch withpreviouslyCancelledIn, ETag/If-Match, idempotency replay/conflict, 428)./= the one current batch: open viaGET /batches/open, else the active collected…printed batch (open is null then). It shows the reference, status, counts, a progress bar (Pronto → Arquivos retirados → Orçamento enviado → Orçamento aprovado → Impresso) and one card per file grouped under its request (IMP-0001 · title): name, size, copies, instructions and Baixar arquivo. Unpaired legacy files get a "Sem vínculo seguro" card, and each request's residual text goes in its own "Instruções gerais" block, never merged across requests. A request with a backendpreviouslyCancelledInshows a warning. With no batch, the empty state reads "Nenhum pedido aguardando".confirmed=1) and sends If-Match = batch ETag and an Idempotency-Key that is kept across ambiguous retries:open→ "Retirei os arquivos": checkbox "Conferi todos os arquivos", and the dialog shows the file and request counts. A 412 re-renders the changed batch and requires reconfirmation.files_collected/quote_rejected→ one quote for the whole batch, with the rejection reason shown.quote_pending/printed→ waiting messages only.quote_approved→ "Marcar como impresso"./batches) with paginated history and a read-only detail (/batches/:id) that reuses the same cards. Notas fiscais now reads v2 closes (batch charges link to the batch; legacy orders are labelled)./ordersscreens, the per-order commands and/api/print/v1are removed. The BFF mirrors v2 at/api/print/v2(session auth, CSRF/Origin, no browser Authorization, same upload caps).data-ttpsmoke markers are on the real rendered components.Verification
pnpm checkgreen locally (lint, structure, depcruise, typecheck, builds, codegen drift, 211 tests with coverage thresholds, examples, bundle smoke, hooks).Acceptance tests (
tests/unit/portal-batch-html.test.ts) run through the real Hono app (login form, cookies, Origin, CSRF), seeded with the frozen fixture snapshots and their real PDFs. They cover:The PrintApi conformance suite runs on both the memory fake and the HTTP adapter over a real socket.
Ran the shared smoke helper (
infra/ttp/feature_smoke.pyverify) against a locally running portal over real HTTP for all 10 checkpoints (flow ×7, cancel ×2, empty-history): all pass, downloads hash-verified.Note:
infra/is untouched.infra/ttp/fake-upstream.ts(the old in-repo v1 fake, superseded by the pinnedstaging/ttp-fake-v2) still importstests/helpers/print-portal-v1.fixture.json, so that one v1 fixture file stays.🤖 Generated with Claude Code