This commit is contained in:
parent
171fbf1927
commit
8bf3e3b705
40 changed files with 1443 additions and 1497 deletions
|
|
@ -2,7 +2,6 @@ import { createElement } from 'react';
|
|||
import { renderToStaticMarkup } from 'react-dom/server';
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { FlooringPreview, SkirtingPreview } from '../src/components/CutPreview';
|
||||
import { CutDialog } from '../src/components/CutDialog';
|
||||
import { planSkirting } from '../src/lib/skirting';
|
||||
import { skirtingEndLabel } from '../src/lib/cut-list';
|
||||
import { defaultProject } from '../src/lib/defaults';
|
||||
|
|
@ -14,7 +13,6 @@ const floor: FlooringPiece = {
|
|||
id: 'F1',
|
||||
roomId: 'room-1',
|
||||
row: 1,
|
||||
column: 1,
|
||||
polygon: [],
|
||||
length: 600.001,
|
||||
width: 190,
|
||||
|
|
@ -41,6 +39,7 @@ const template: SkirtingPiece['template'] = [
|
|||
{ x: 0, y: 18 },
|
||||
];
|
||||
const skirt: SkirtingPiece = {
|
||||
cut: true,
|
||||
id: 'A1',
|
||||
roomId: 'room-1',
|
||||
wallId: 'w1',
|
||||
|
|
@ -58,10 +57,6 @@ const skirt: SkirtingPiece = {
|
|||
template,
|
||||
installedTemplate: template,
|
||||
visibleLength: 1200,
|
||||
leftOverlap: 0,
|
||||
rightOverlap: 0,
|
||||
leftBevel: -45,
|
||||
rightBevel: 45,
|
||||
};
|
||||
|
||||
describe('cut shape previews', () => {
|
||||
|
|
@ -223,39 +218,6 @@ describe('cut shape previews', () => {
|
|||
expect(markup).toContain('angles from horizontal');
|
||||
});
|
||||
|
||||
it('keeps dialog instructions useful without source codes or numbered coordinate lists', () => {
|
||||
const markup = renderToStaticMarkup(
|
||||
createElement(CutDialog, {
|
||||
floor: { ...floor, factoryLeft: true, ripEdge: 'top' },
|
||||
project: defaultProject(),
|
||||
close: () => {},
|
||||
}),
|
||||
);
|
||||
expect(markup).toContain('Living room · Row 1');
|
||||
expect(markup).toContain('Keep the left factory end; trim from the right.');
|
||||
expect(markup).toContain('Rip the top long edge; keep the bottom factory edge.');
|
||||
expect(markup).not.toContain('Source');
|
||||
expect(markup).not.toContain('coordinates');
|
||||
expect(markup).not.toContain('cut-edge-lengths');
|
||||
});
|
||||
|
||||
it('shows skirting dimensions and mitre directions without a second measurement list', () => {
|
||||
const markup = renderToStaticMarkup(
|
||||
createElement(CutDialog, {
|
||||
skirt,
|
||||
project: defaultProject(),
|
||||
close: () => {},
|
||||
}),
|
||||
);
|
||||
expect(markup).toContain('Living room · Wall 1');
|
||||
expect(markup).toContain('>1,164</text>');
|
||||
expect(markup).toContain('>1,200</text>');
|
||||
expect(markup).toContain('Mitre 45°');
|
||||
expect(markup).not.toContain('Source');
|
||||
expect(markup).not.toContain('coordinates');
|
||||
expect(markup).not.toContain('<dl');
|
||||
});
|
||||
|
||||
it('keeps the complete end cut visible even at shallow mitre angles', () => {
|
||||
const shallow = [
|
||||
{ x: 0, y: 0 },
|
||||
|
|
@ -278,34 +240,11 @@ describe('cut shape previews', () => {
|
|||
}
|
||||
});
|
||||
|
||||
it('makes thumbnails decorative while retaining true-scale SVGs and visible end breaks', () => {
|
||||
const floorMarkup = renderToStaticMarkup(
|
||||
createElement(FlooringPreview, { piece: floor, compact: true }),
|
||||
);
|
||||
const skirtMarkup = renderToStaticMarkup(
|
||||
createElement(SkirtingPreview, { piece: skirt, thickness: 18, compact: true }),
|
||||
);
|
||||
expect(floorMarkup).toContain('aria-hidden="true"');
|
||||
expect(skirtMarkup.match(/aria-hidden="true"/g)).toHaveLength(3);
|
||||
expect(skirtMarkup).toContain('>//</span>');
|
||||
expect(skirtMarkup.match(/preserveAspectRatio="xMidYMid meet"/g)).toHaveLength(2);
|
||||
expect(floorMarkup).not.toContain('<figure');
|
||||
expect(skirtMarkup).not.toContain('<figure');
|
||||
});
|
||||
it('shows cope preparation and its full-thickness body without inventing a decorative profile', () => {
|
||||
const project = defaultProject();
|
||||
const plan = planSkirting(project.rooms, project.skirting, project.tolerance);
|
||||
const piece = plan.pieces.find((piece) => piece.leftType === 'cope')!;
|
||||
expect(piece).toBeDefined();
|
||||
const markup = renderToStaticMarkup(
|
||||
createElement(CutDialog, { skirt: piece, project, close: () => {} }),
|
||||
);
|
||||
expect(markup).toContain(`Left cope preparation close-up ${piece.id}`);
|
||||
expect(markup).toContain('Cope · prepare 45°');
|
||||
expect(markup).toContain('preparation before coping');
|
||||
expect(markup).toContain('class="skirting-cope-body"');
|
||||
expect(markup).toContain('mark your moulding’s exposed profile');
|
||||
expect(markup).toContain('Exposed front length:');
|
||||
expect(skirtingEndLabel({ ...piece, rightType: 'internal', rightMitre: 0 }, 'right')).toBe(
|
||||
'Receive cope · square',
|
||||
);
|
||||
|
|
@ -316,14 +255,6 @@ describe('cut shape previews', () => {
|
|||
const installed = piece.installedTemplate;
|
||||
expect(prepared[0].x).toBeLessThan(installed[0].x);
|
||||
expect(prepared[3].x).toBeCloseTo(installed[3].x);
|
||||
const compact = renderToStaticMarkup(
|
||||
createElement(SkirtingPreview, {
|
||||
piece,
|
||||
thickness: project.skirting.thickness,
|
||||
compact: true,
|
||||
}),
|
||||
);
|
||||
expect(compact).toContain('class="skirting-cope-body"');
|
||||
});
|
||||
|
||||
it('keeps an oblique coped body inside the uniformly scaled end close-up', () => {
|
||||
|
|
|
|||
Loading…
Reference in a new issue