This commit is contained in:
Andras Schmelczer 2026-09-11 16:58:58 +01:00
commit 62a385e4c9
33 changed files with 2649 additions and 809 deletions

View file

@ -1,6 +1,7 @@
import { describe, expect, it } from 'vitest';
import { planSkirting } from '../src/lib/skirting';
import { skirtingCuts } from '../src/lib/cut-list';
import { cutLength } from '../src/lib/format';
import type { Room, SkirtingSettings } from '../src/lib/types';
const settings: SkirtingSettings = { stockLengths: [2400], thickness: 18, minLength: 300, kerf: 3 };
@ -146,6 +147,22 @@ describe('skirting cutting plan', () => {
expect(plan.cuts).toBe(4);
});
it('reserves the displayed half-millimetre blanks so rounded cuts fit their source', () => {
const plan = planSkirting(
[rectangle(1198.4, 1198.6)],
{ ...settings, thickness: 0, minLength: 1100 },
5,
);
expect(plan.issues.filter((issue) => issue.severity === 'error')).toEqual([]);
expect(plan.stockCount).toBe(3);
for (const stock of plan.stocks) {
const pieces = stock.pieceIds.map((id) => plan.pieces.find((piece) => piece.id === id)!);
const marked = pieces.reduce((sum, piece) => sum + cutLength(piece.length), 0);
expect(marked + (pieces.length - 1) * settings.kerf).toBeLessThanOrEqual(stock.length);
}
expect(plan.pieces.reduce((sum, piece) => sum + piece.length, 0)).toBeCloseTo(4794);
});
it('looks ahead when choosing from different stock lengths', () => {
const plan = planSkirting(
[rectangle(1200, 1200)],