test(capture): expect 800px inventory PNG floor

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.
This commit is contained in:
2026-09-14 23:40:01 +00:00
parent fbcd05169f
commit f20d84c543
+20 -8
View File
@@ -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); const out = composeInventoryFrame(src, maskFor(bitset, { x: 1, y: 1, w: 4, h: 4 }), source);
assert.equal(out.sourceBelowFloor, true); 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 opaque = 0;
let transparent = 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'); 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<Source, 'widthPx' | 'heightPx'> = { widthPx: 2000, heightPx: 1800 }; const source: Pick<Source, 'widthPx' | 'heightPx'> = { widthPx: 2000, heightPx: 1800 };
const bitset = new Uint8Array(source.widthPx * source.heightPx).fill(1); const bitset = new Uint8Array(source.widthPx * source.heightPx).fill(1);
const out = composeInventoryFrame( 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 }), maskFor(bitset, { x: 0, y: 0, w: 2000, h: 1800 }),
source, source,
); );
assert.equal(out.width, 1600); assert.equal(out.width, 800);
assert.equal(out.height, 2133); assert.equal(out.height, 1067);
assert.equal(out.sourceBelowFloor, false); assert.equal(out.sourceBelowFloor, false);
}); });
test('mid-band: slab shorter side 1000 (between 800 and 1600) → at floor, not belowFloor', () => {
const source: Pick<Source, 'widthPx' | 'heightPx'> = { 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', () => { test('80% fill: limiting dimension maps to 0.8 × frame side', () => {
const source: Pick<Source, 'widthPx' | 'heightPx'> = { widthPx: 2200, heightPx: 2000 }; const source: Pick<Source, 'widthPx' | 'heightPx'> = { widthPx: 2200, heightPx: 2000 };
const bitset = new Uint8Array(source.widthPx * source.heightPx).fill(1); 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 xs = [minx, maxx], ys = [miny, maxy];
const wExtent = Math.max(...xs) - Math.min(...xs) + 1; const wExtent = Math.max(...xs) - Math.min(...xs) + 1;
const hExtent = Math.max(...ys) - Math.min(...ys) + 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(wExtent - 640) <= 2, `width extent ${wExtent} ≈ 640 (0.8×800)`);
assert.ok(Math.abs(hExtent - 1152) <= 2, `height extent ${hExtent} ≈ 1152 (0.8×1800×0.64)`); 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<Source, 'widthPx' | 'heightPx'> = { widthPx: 900, heightPx: 700 }; const source: Pick<Source, 'widthPx' | 'heightPx'> = { widthPx: 900, heightPx: 700 };
const bitset = new Uint8Array(source.widthPx * source.heightPx).fill(1); const bitset = new Uint8Array(source.widthPx * source.heightPx).fill(1);
const out = composeInventoryFrame( const out = composeInventoryFrame(
@@ -104,5 +116,5 @@ test('belowFloor: small slab → sourceBelowFloor, outW < 1600', () => {
source, source,
); );
assert.equal(out.sourceBelowFloor, true); 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`);
}); });