import { describe, expect, it } from 'vitest' import { mount } from '@vue/test-utils' import BioTemplateRenderer from '../../components/BioTemplateRenderer.vue' import { createLcmsBatchCollection, createWellPlateScreenCollection, } from '../../templates' describe('BioTemplateRenderer', () => { it('renders SDK components for a biology template collection', () => { const collection = createWellPlateScreenCollection({ samples: ['Control', 'Treatment'], compounds: { 'Drug A': [10, 1] }, }) const wrapper = mount(BioTemplateRenderer, { props: { target: collection }, global: { stubs: { DataFrame: true, DoseCalculator: true, PlateEditor: true, SampleSelector: true, WellPlate: true, }, }, }) expect(wrapper.find('.mint-bio-template-renderer').exists()).toBe(true) expect(wrapper.find('[data-template-component="PlateEditor"]').exists()).toBe(true) expect(wrapper.find('[data-template-component="DoseCalculator"]').exists()).toBe(true) expect(wrapper.findAll('[data-template-component="WellPlate"]')).toHaveLength(2) expect(wrapper.text()).toContain('plate-map') expect(wrapper.text()).toContain('dose-response') }) it('renders instrument-run timelines from LC-MS template collections', () => { const collection = createLcmsBatchCollection({ samples: ['S001', 'S002'], instrument: 'LC-MS', }) const wrapper = mount(BioTemplateRenderer, { props: { target: collection }, global: { stubs: { DataFrame: true, ExperimentTimeline: true, SampleSelector: true, ScheduleCalendar: true, }, }, }) expect(wrapper.find('[data-component-binding-id="instrument-run:ScheduleCalendar"]').exists()).toBe(true) expect(wrapper.find('[data-component-binding-id="instrument-run:ExperimentTimeline"]').exists()).toBe(true) expect(wrapper.find('[data-component-binding-id="assay-matrix:SampleSelector"]').exists()).toBe(true) expect(wrapper.find('[data-template-component="ScheduleCalendar"]').exists()).toBe(true) expect(wrapper.find('[data-template-component="ExperimentTimeline"]').exists()).toBe(true) expect(wrapper.find('[data-template-id="instrument-run"]').exists()).toBe(true) }) it('filters rendered components with include and exclude lists', () => { const collection = createWellPlateScreenCollection() const wrapper = mount(BioTemplateRenderer, { props: { target: collection, include: ['WellPlate', 'DataFrame'], exclude: ['DataFrame'], }, global: { stubs: { WellPlate: true, }, }, }) const components = wrapper .findAll('[data-template-component]') .map(item => item.attributes('data-template-component')) expect(components).toEqual(['WellPlate', 'WellPlate']) }) it('renders an empty state when no component binding survives filtering', () => { const collection = createLcmsBatchCollection() const wrapper = mount(BioTemplateRenderer, { props: { target: collection, include: ['WellPlate'], emptyText: 'No preview for this preset.', }, }) expect(wrapper.findAll('[data-template-component]')).toHaveLength(0) expect(wrapper.text()).toContain('No preview for this preset.') }) })