diff --git a/src/__tests__/CompareResults/CommonGraph.test.tsx b/src/__tests__/CompareResults/CommonGraph.test.tsx index 9ff26d762..7a4dcc762 100644 --- a/src/__tests__/CompareResults/CommonGraph.test.tsx +++ b/src/__tests__/CompareResults/CommonGraph.test.tsx @@ -88,6 +88,8 @@ describe('CommonGraph', () => { newValues={[3, 4]} unit='ms' isSubtest={false} + vt={0.5} + onVtChange={jest.fn()} />, ); @@ -132,6 +134,8 @@ describe('CommonGraph', () => { newValues={[3, 4]} unit='ms' isSubtest={false} + vt={0.5} + onVtChange={jest.fn()} />, ); @@ -164,6 +168,8 @@ describe('CommonGraph', () => { newValues={[3, 4]} unit='ms' isSubtest={true} + vt={0.5} + onVtChange={jest.fn()} />, ); @@ -194,12 +200,18 @@ describe('CommonGraph', () => { newValues={[]} unit='ms' isSubtest={false} + vt={0.5} + onVtChange={jest.fn()} />, ); const option = getLatestEChartsOption(); const allSeries = option.series as LineSeriesOption[]; - const series = allSeries.filter((s) => s.type === 'line'); + // Exclude the mode-overlay markLine series (named "_mode-*") — only count + // the two underlying KDE curves. + const series = allSeries.filter( + (s) => s.type === 'line' && !String(s.name ?? '').startsWith('_mode-'), + ); expect(series).toHaveLength(2); // Base side has a resampled density curve. expect(series[0].data as unknown[]).toHaveLength(1024); @@ -232,6 +244,8 @@ describe('CommonGraph', () => { newValues={[3, 4]} unit='ms' isSubtest={false} + vt={0.5} + onVtChange={jest.fn()} />, ); @@ -254,6 +268,8 @@ describe('CommonGraph', () => { newValues={[3, 4]} unit='ms' isSubtest={false} + vt={0.5} + onVtChange={jest.fn()} />, ); @@ -296,6 +312,8 @@ describe('CommonGraph', () => { newValues={[3, 4]} unit='ms' isSubtest={false} + vt={0.5} + onVtChange={jest.fn()} />, ); @@ -336,6 +354,8 @@ describe('CommonGraph', () => { newValues={[3, 4]} unit={null} isSubtest={false} + vt={0.5} + onVtChange={jest.fn()} />, ); @@ -353,4 +373,107 @@ describe('CommonGraph', () => { // No "(unit)" suffix after the value when unit is null. expect(rendered).toBe('Value: 5.00
Base: 0.1000'); }); + + it('emits a mode-overlay markLine series for each detected peak', () => { + // Strictly increasing fake KDE — fitModesFromKde returns a single peak at + // the global max (last x). That yields exactly one "_mode-*" overlay per + // series, with a label tagged by series and letter A. + (fftkde as jest.Mock).mockImplementation(() => ({ + x: [10, 20, 30], + y: [0.1, 0.2, 0.3], + bandwidth: 1, + })); + + render( + , + ); + + const option = getLatestEChartsOption(); + const series = option.series as Array<{ + name?: string; + markLine?: { + data?: Array<{ xAxis?: number }>; + label?: { formatter?: string }; + lineStyle?: { color?: string }; + }; + }>; + const overlays = series.filter((s) => + String(s.name ?? '').startsWith('_mode-'), + ); + // One overlay per series (Base + New), both peaking at the same x. + expect(overlays).toHaveLength(2); + expect(overlays[0].markLine?.data?.[0]?.xAxis).toBe(30); + expect(overlays[1].markLine?.data?.[0]?.xAxis).toBe(30); + expect(overlays[0].markLine?.label?.formatter).toMatch(/^Base A: 30/); + expect(overlays[1].markLine?.label?.formatter).toMatch(/^New A: 30/); + }); + + it('shows raw run values in the scatter tooltip with the unit suffix', () => { + (fftkde as jest.Mock).mockImplementation(() => ({ + x: [10, 20, 30], + y: [0.1, 0.2, 0.3], + bandwidth: 1, + })); + + render( + , + ); + + const formatter = getTooltipFormatter(getLatestEChartsOption()); + // The formatter inspects items[0].seriesType to pick between scatter and + // KDE rendering — pass a scatter-shaped item to exercise the scatter path. + const rendered = formatter([ + { + seriesType: 'scatter', + seriesName: 'Base', + value: [12.5, 0], + marker: '[m]', + }, + ] as unknown as Parameters[0]); + expect(rendered).toBe('[m]Base: 12.50 (ms)'); + }); + + it("labels the scatter y-axis as 'Base' for 0 and 'New' for 1", () => { + (fftkde as jest.Mock).mockImplementation(() => ({ + x: [10, 20, 30], + y: [0.1, 0.2, 0.3], + bandwidth: 1, + })); + + render( + , + ); + + const option = getLatestEChartsOption(); + const yAxes = option.yAxis as Array<{ + axisLabel?: { formatter?: (v: number) => string }; + }>; + const scatterYAxisFormatter = yAxes[1]?.axisLabel?.formatter; + expect(scatterYAxisFormatter).toBeDefined(); + expect(scatterYAxisFormatter!(0)).toBe('Base'); + expect(scatterYAxisFormatter!(1)).toBe('New'); + // Anything else returns empty so intermediate jitter values stay unlabelled. + expect(scatterYAxisFormatter!(0.5)).toBe(''); + }); }); diff --git a/src/__tests__/CompareResults/__snapshots__/ResultsView.test.tsx.snap b/src/__tests__/CompareResults/__snapshots__/ResultsView.test.tsx.snap index 2867458f7..b034456fe 100644 --- a/src/__tests__/CompareResults/__snapshots__/ResultsView.test.tsx.snap +++ b/src/__tests__/CompareResults/__snapshots__/ResultsView.test.tsx.snap @@ -4,7 +4,7 @@ exports[`Results View Should display Base, New and Common graphs with replicates
Runs Density Distribution +
+ + Valley depth threshold + + : + + + + + + + + + + 50 + % + +
@@ -482,11 +542,71 @@ exports[`Results View Should display Base, New and Common graphs with tooltips 1 > Runs Density Distribution +
+ + Valley depth threshold + + : + + + + + + + + + + 50 + % + +
diff --git a/src/__tests__/CompareResults/__snapshots__/SubtestsResultsView.test.tsx.snap b/src/__tests__/CompareResults/__snapshots__/SubtestsResultsView.test.tsx.snap index d053ad239..84f40523e 100644 --- a/src/__tests__/CompareResults/__snapshots__/SubtestsResultsView.test.tsx.snap +++ b/src/__tests__/CompareResults/__snapshots__/SubtestsResultsView.test.tsx.snap @@ -2643,7 +2643,7 @@ exports[`SubtestsViewCompareOverTime Component Tests in mann-whitney-u testVersi aria-invalid="false" aria-label="Search by title" class="MuiInputBase-input MuiOutlinedInput-input MuiInputBase-inputSizeSmall MuiInputBase-inputAdornedStart MuiInputBase-inputAdornedEnd css-3v3un6-MuiInputBase-input-MuiOutlinedInput-input" - id="_r_r3_" + id="_r_r9_" placeholder="Filter results" type="search" value="" @@ -3153,7 +3153,7 @@ exports[`SubtestsViewCompareOverTime Component Tests in mann-whitney-u testVersi role="cell" >