From f20d84c5431350d73b0c5906616456db41ebf525 Mon Sep 17 00:00:00 2001 From: grokbot_ty Date: Mon, 14 Sep 2026 23:40:01 +0000 Subject: [PATCH] test(capture): expect 800px inventory PNG floor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Ty UAT rejected phone photos under the 1600px bar. Lock the mid-band case (shorter side 1000) and floor geometry at 800×1067 / 0.8×800=640 before the code change. --- frontend/src/png/inventory.test.ts | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/frontend/src/png/inventory.test.ts b/frontend/src/png/inventory.test.ts index d8245da..4ce1298 100644 --- a/frontend/src/png/inventory.test.ts +++ b/frontend/src/png/inventory.test.ts @@ -31,7 +31,7 @@ test('alpha contract: removed pixels transparent, slab pixels keep RGB at alpha const out = composeInventoryFrame(src, maskFor(bitset, { x: 1, y: 1, w: 4, h: 4 }), source); assert.equal(out.sourceBelowFloor, true); - assert.ok(out.width < 1600, 'undersized source stays small'); + assert.ok(out.width < 800, 'undersized source stays small'); let opaque = 0; let transparent = 0; @@ -56,7 +56,7 @@ test('alpha contract: removed pixels transparent, slab pixels keep RGB at alpha assert.ok(transparent > 0, 'frame has transparent pixels'); }); -test('3:4 frame at the floor: 2000×1800 slab → 1600×2133', () => { +test('3:4 frame at the floor: 2000×1800 slab → 800×1067', () => { const source: Pick = { widthPx: 2000, heightPx: 1800 }; const bitset = new Uint8Array(source.widthPx * source.heightPx).fill(1); const out = composeInventoryFrame( @@ -64,11 +64,23 @@ test('3:4 frame at the floor: 2000×1800 slab → 1600×2133', () => { maskFor(bitset, { x: 0, y: 0, w: 2000, h: 1800 }), source, ); - assert.equal(out.width, 1600); - assert.equal(out.height, 2133); + assert.equal(out.width, 800); + assert.equal(out.height, 1067); assert.equal(out.sourceBelowFloor, false); }); +test('mid-band: slab shorter side 1000 (between 800 and 1600) → at floor, not belowFloor', () => { + const source: Pick = { widthPx: 1200, heightPx: 1000 }; + const bitset = new Uint8Array(source.widthPx * source.heightPx).fill(1); + const out = composeInventoryFrame( + makePhoto(source.widthPx, source.heightPx), + maskFor(bitset, { x: 0, y: 0, w: 1200, h: 1000 }), + source, + ); + assert.equal(out.sourceBelowFloor, false); + assert.equal(out.width, 800); +}); + test('80% fill: limiting dimension maps to 0.8 × frame side', () => { const source: Pick = { widthPx: 2200, heightPx: 2000 }; const bitset = new Uint8Array(source.widthPx * source.heightPx).fill(1); @@ -91,11 +103,11 @@ test('80% fill: limiting dimension maps to 0.8 × frame side', () => { const xs = [minx, maxx], ys = [miny, maxy]; const wExtent = Math.max(...xs) - Math.min(...xs) + 1; const hExtent = Math.max(...ys) - Math.min(...ys) + 1; - assert.ok(Math.abs(wExtent - 1280) <= 2, `width extent ${wExtent} ≈ 1280 (0.8×1600)`); - assert.ok(Math.abs(hExtent - 1152) <= 2, `height extent ${hExtent} ≈ 1152 (0.8×1800×0.64)`); + assert.ok(Math.abs(wExtent - 640) <= 2, `width extent ${wExtent} ≈ 640 (0.8×800)`); + assert.ok(Math.abs(hExtent - 576) <= 2, `height extent ${hExtent} ≈ 576 (1800×0.32)`); }); -test('belowFloor: small slab → sourceBelowFloor, outW < 1600', () => { +test('belowFloor: small slab → sourceBelowFloor, outW capped at floor (no upscale)', () => { const source: Pick = { widthPx: 900, heightPx: 700 }; const bitset = new Uint8Array(source.widthPx * source.heightPx).fill(1); const out = composeInventoryFrame( @@ -104,5 +116,5 @@ test('belowFloor: small slab → sourceBelowFloor, outW < 1600', () => { source, ); assert.equal(out.sourceBelowFloor, true); - assert.ok(out.width < 1600, `outW ${out.width}`); + assert.ok(out.width <= 800, `outW ${out.width} must not exceed the floor`); });