feat: a 57 cm ready sheet whose real width is not 57 cm opens a pop-up and is not accepted (Marcus, 2026-12-01)
Some checks failed
Build and deploy / Validate source (push) Successful in 5s
Build and deploy / Integration suite on a real stack (push) Failing after 2m34s
Build and deploy / Secret scan and release gate (push) Successful in 5s
Build and deploy / Publish images (push) Has been skipped

Order #177: a 35,8 cm sheet at 300 DPI was stretched to the film's 57 cm,
the v0 Site rule for a ready sheet image. Marcus: a pop-up on upload, and
neither a narrower nor a wider sheet is accepted.

The real width is known for a PNG whose pHYs records 200 DPI or more (the
A1 threshold) and for a PDF page; tolerance 0,1 cm (6732 px at 300 DPI is
56,998 cm). Arquivo por metro and Premium only. UV, a PNG without pHYs or
under 200 DPI, and every existing order and approved cart are unchanged.

Site: medirFolha refuses it, the sheet leaves the list (its upload stops),
and #larguraDlg lists each refused file with its width and DPI; Entendi or
Escape closes it and focus returns to the upload area; the thin-stroke
dialog waits while it is open. Server: sheet_width_issue refuses the same
cart at checkout (POST /api/quotes, 422), so a reorder or an edited page
cannot get round it. Contract: output/revisao/contrato-largura-folha.md.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Cauê Faleiros
2026-12-01 17:41:02 -03:00
parent 12bc0c3e1a
commit 711199558f
9 changed files with 244 additions and 6 deletions

View File

@@ -242,5 +242,68 @@ class ProportionTests(unittest.TestCase):
self.assertIsNone(grade_check.proportion_issue(files, items, rows))
class SheetWidthTests(unittest.TestCase):
"""A 57 cm ready sheet must really be 57 cm wide where the file tells
(contrato-largura-folha.md), or the cart is refused."""
def cart(self, mode, name, width_cm=57):
source = {'upload_id': name, 'kind': 'sheet', 'width_cm': width_cm}
return [{'mode': mode, 'production': {'sources': [source]}}], {name: {'name': name}}
def test_a_narrow_png_is_refused(self):
files = FakeFiles({'sheet.png': encoded('PNG', (4227, 100), dpi=(300, 300))})
items, rows = self.cart('file', 'sheet.png')
issue = grade_check.sheet_width_issue(files, items, rows)
self.assertIn('35,8 cm', issue)
self.assertIn('300 DPI', issue)
def test_a_wide_png_is_refused(self):
files = FakeFiles({'sheet.png': encoded('PNG', (7200, 100), dpi=(300, 300))})
items, rows = self.cart('file', 'sheet.png')
self.assertIn('61,0 cm', grade_check.sheet_width_issue(files, items, rows))
def test_sheet_width_rounding_boundaries(self):
for width_px, refused in ((6732, False), (6721, False), (6720, True)):
files = FakeFiles({'sheet.png': encoded('PNG', (width_px, 100), dpi=(300, 300))})
items, rows = self.cart('file', 'sheet.png')
issue = grade_check.sheet_width_issue(files, items, rows)
if refused:
self.assertIn('56,9 cm', issue)
else:
self.assertIsNone(issue, width_px)
def test_png_under_trusted_dpi_passes(self):
for options in ({}, {'dpi': (96, 96)}, {'dpi': (150, 150)}):
files = FakeFiles({'sheet.png': encoded('PNG', (4227, 100), **options)})
items, rows = self.cart('file', 'sheet.png')
self.assertIsNone(grade_check.sheet_width_issue(files, items, rows), options)
def test_only_the_57_cm_modes_are_checked(self):
files = FakeFiles({'sheet.png': encoded('PNG', (4227, 100), dpi=(300, 300))})
items, rows = self.cart('premium', 'sheet.png')
self.assertIn('35,8 cm', grade_check.sheet_width_issue(files, items, rows))
for mode in ('uvfile', 'avulsa'):
items, rows = self.cart(mode, 'sheet.png')
self.assertIsNone(grade_check.sheet_width_issue(files, items, rows), mode)
def test_a_pdf_width_is_checked(self):
files = FakeFiles({})
items, rows = self.cart('file', 'sheet.pdf', width_cm=30)
issue = grade_check.sheet_width_issue(files, items, rows)
self.assertIn('30,0 cm', issue)
self.assertNotIn('DPI', issue)
for width_cm in (57, '56.95'):
items, rows = self.cart('file', 'sheet.pdf', width_cm=width_cm)
self.assertIsNone(grade_check.sheet_width_issue(files, items, rows), width_cm)
def test_png_saved_dpi(self):
head = encoded('PNG', (4227, 100), dpi=(300, 300))
self.assertEqual(grade_check.png_saved_dpi(head), 300)
self.assertIsNone(grade_check.png_saved_dpi(encoded('PNG', (4227, 100))))
self.assertIsNone(grade_check.png_saved_dpi(b'not a png at all'))
cut = head.index(b'pHYs') + 8 # four of the pHYs data bytes
self.assertIsNone(grade_check.png_saved_dpi(head[:cut]))
if __name__ == '__main__':
unittest.main()