import { describe, expect, it } from 'vitest' import { createPlateColumnLabels, createPlateRowLabels, createWellGrid, getRectangleWellIds, PLATE_CONFIGS, WELL_PLATE_SIZE_CONFIGS, } from '../../components/WellPlate.geometry' describe('WellPlate geometry helpers', () => { it('exposes supported plate dimensions and size presets', () => { expect(PLATE_CONFIGS[96]).toEqual({ rows: 8, cols: 12 }) expect(PLATE_CONFIGS[384]).toEqual({ rows: 16, cols: 24 }) expect(WELL_PLATE_SIZE_CONFIGS.fill.cellWidth).toBe('100%') }) it('should give the xs size square wells when rendering a compact plate', () => { const { cellWidth, cellHeight } = WELL_PLATE_SIZE_CONFIGS.xs expect(cellWidth).toBe(cellHeight) }) it('creates row and column labels from a plate config', () => { const config = PLATE_CONFIGS[24] expect(createPlateRowLabels(config)).toEqual(['A', 'B', 'C', 'D']) expect(createPlateColumnLabels(config)).toEqual([1, 2, 3, 4, 5, 6]) }) it('creates a well grid with partial well data merged into defaults', () => { const config = PLATE_CONFIGS[6] const rows = createPlateRowLabels(config) const grid = createWellGrid(config, rows, { A1: { state: 'filled', sampleType: 'qc', value: 42, metadata: { label: 'QC 1' } }, }) expect(grid[0][0]).toEqual({ id: 'A1', row: 0, col: 0, state: 'filled', sampleType: 'qc', value: 42, metadata: { label: 'QC 1' }, }) expect(grid[1][2]).toMatchObject({ id: 'B3', row: 1, col: 2, state: 'empty' }) }) it('should carry the group of a well into the grid', () => { const config = PLATE_CONFIGS[6] const grid = createWellGrid(config, createPlateRowLabels(config), { A1: { state: 'filled', sampleType: 'sample', group: 'ctrl' } }) expect(grid[0][0].group).toBe('ctrl') }) it('creates rectangle well ids independent of drag direction', () => { expect(Array.from(getRectangleWellIds({ row: 1, col: 2 }, { row: 0, col: 0 }, ['A', 'B']))).toEqual([ 'A1', 'A2', 'A3', 'B1', 'B2', 'B3', ]) }) })