66
77import { describe , it , expect , vi } from 'vitest' ;
88
9- // Mock Three.js and OBJLoader so the ephys-viz-3d import doesn't fail in Node
109vi . mock ( 'three' , ( ) => ( { default : { } } ) ) ;
1110vi . mock ( 'three/addons/loaders/OBJLoader.js' , ( ) => ( { OBJLoader : class { } } ) ) ;
1211
13- // Mock brain-viz-3d exports needed by ephys-viz-3d
1412vi . mock ( '../subject/brain-viz-3d.js' , ( ) => ( {
1513 STRUCTURE_COLORS : { } ,
1614 TARGET_X : 0 , TARGET_Y : - 3.668 , TARGET_Z : - 1.2 ,
@@ -21,25 +19,24 @@ vi.mock('../subject/brain-viz-3d.js', () => ({
2119 createBrainViz3D : ( ) => document . createElement ( 'div' ) ,
2220} ) ) ;
2321
24- // Mock brain-viz for ITEM_COLORS
2522vi . mock ( '../subject/brain-viz.js' , ( ) => ( {
2623 ITEM_COLORS : [ '#FF6B6B' , '#4ECDC4' , '#45B7D1' ] ,
2724 createBrainVizCanvas : ( ) => ( { canvas : document . createElement ( 'canvas' ) } ) ,
2825} ) ) ;
2926
30- // Mock assets/view.js
3127vi . mock ( '../assets/view.js' , ( ) => ( {
3228 buildQcLink : ( ) => null ,
3329 buildMetadataLink : ( ) => null ,
3430 buildCoLink : ( ) => null ,
3531 buildS3ConsoleUrl : ( ) => null ,
3632} ) ) ;
3733
38- import { hasEphysAssemblies , buildEphysProbeCard } from '../subject/details.js' ;
39-
40- // ---------------------------------------------------------------------------
41- // Fixtures
42- // ---------------------------------------------------------------------------
34+ import {
35+ hasEphysAssemblies ,
36+ buildEphysProbeCard ,
37+ buildCraniotomySubProcHtml ,
38+ buildHeadframeSubProcHtml ,
39+ } from '../subject/details.js' ;
4340
4441const EPHYS_CONFIG = {
4542 object_type : 'Ephys assembly config' ,
@@ -93,10 +90,6 @@ const ACQUISITION_WITHOUT_EPHYS = {
9390 ] ,
9491} ;
9592
96- // ---------------------------------------------------------------------------
97- // hasEphysAssemblies
98- // ---------------------------------------------------------------------------
99-
10093describe ( 'hasEphysAssemblies' , ( ) => {
10194 it ( 'returns true when acquisition has at least one Ephys assembly config' , ( ) => {
10295 expect ( hasEphysAssemblies ( ACQUISITION_WITH_EPHYS ) ) . toBe ( true ) ;
@@ -133,10 +126,6 @@ describe('hasEphysAssemblies', () => {
133126 } ) ;
134127} ) ;
135128
136- // ---------------------------------------------------------------------------
137- // buildEphysProbeCard
138- // ---------------------------------------------------------------------------
139-
140129describe ( 'buildEphysProbeCard' , ( ) => {
141130 const probe = {
142131 name : '46121' ,
@@ -229,3 +218,49 @@ describe('buildEphysProbeCard', () => {
229218 expect ( html ) . toContain ( 'Probe 3:' ) ;
230219 } ) ;
231220} ) ;
221+
222+ describe ( 'buildCraniotomySubProcHtml' , ( ) => {
223+ it ( 'renders craniotomy-specific fields' , ( ) => {
224+ const html = buildCraniotomySubProcHtml ( {
225+ object_type : 'Craniotomy' ,
226+ protocol_id : null ,
227+ craniotomy_type : 'Circle' ,
228+ coordinate_system_name : 'BREGMA_ARID' ,
229+ position : [ 'Origin' ] ,
230+ size : 5 ,
231+ size_unit : 'millimeter' ,
232+ protective_material : null ,
233+ implant_part_number : '5mm stacked coverslip' ,
234+ dura_removed : null ,
235+ } ) ;
236+
237+ expect ( html ) . toContain ( 'Craniotomy' ) ;
238+ expect ( html ) . toContain ( 'Circle' ) ;
239+ expect ( html ) . toContain ( 'BREGMA_ARID' ) ;
240+ expect ( html ) . toContain ( 'Origin' ) ;
241+ expect ( html ) . toContain ( '5 millimeter' ) ;
242+ expect ( html ) . toContain ( '5mm stacked coverslip' ) ;
243+ expect ( html ) . toContain ( 'Unknown' ) ;
244+ } ) ;
245+ } ) ;
246+
247+ describe ( 'buildHeadframeSubProcHtml' , ( ) => {
248+ it ( 'renders headframe-specific fields' , ( ) => {
249+ const html = buildHeadframeSubProcHtml ( {
250+ object_type : 'Headframe' ,
251+ protocol_id : null ,
252+ headframe_type : 'Visual Ctx' ,
253+ headframe_part_number : '0160-100-10' ,
254+ headframe_material : null ,
255+ well_part_number : '0160-200-20' ,
256+ well_type : 'Mesoscope' ,
257+ } ) ;
258+
259+ expect ( html ) . toContain ( 'Headframe' ) ;
260+ expect ( html ) . toContain ( 'Visual Ctx' ) ;
261+ expect ( html ) . toContain ( '0160-100-10' ) ;
262+ expect ( html ) . toContain ( '0160-200-20' ) ;
263+ expect ( html ) . toContain ( 'Mesoscope' ) ;
264+ expect ( html ) . toContain ( 'Unknown' ) ;
265+ } ) ;
266+ } ) ;
0 commit comments