waveform-analysis 0.1.41 → 0.1.42
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +27 -22
- package/dist/style.css +1 -1
- package/dist/types/components/core/grid.d.ts +3 -0
- package/dist/types/components/core/useWaveformChartController.d.ts +1 -0
- package/dist/types/components/core/useWaveformChartLifecycle.d.ts +2 -4
- package/dist/types/components/core/useWaveformLayout.d.ts +1 -0
- package/package.json +1 -1
- package/src/components/annotation/WaveformAnnotationEditor.css +30 -0
- package/src/components/annotation/WaveformAnnotationEditor.vue +1 -0
- package/src/components/annotation/components.test.ts +14 -1
- package/src/components/core/fixedYDomainLayout.test.ts +21 -3
- package/src/components/core/grid.test.ts +48 -0
- package/src/components/core/grid.ts +20 -7
- package/src/components/core/layout.test.ts +21 -3
- package/src/components/core/trackLayoutBuilder.ts +1 -1
- package/src/components/core/useWaveformChartLifecycle.ts +25 -15
- package/src/components/waveformChartCases/gridFill.test.ts +95 -0
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { flushPromises } from '@vue/test-utils'
|
|
2
|
+
import { describe, expect, it } from 'vitest'
|
|
3
|
+
|
|
4
|
+
import { gridSeries, mountSizedChart } from '../../test/waveformChart'
|
|
5
|
+
|
|
6
|
+
function geometry(track: { attributes: (name: string) => string | undefined }) {
|
|
7
|
+
return {
|
|
8
|
+
left: Number(track.attributes('data-track-left')),
|
|
9
|
+
top: Number(track.attributes('data-track-top')),
|
|
10
|
+
width: Number(track.attributes('data-track-width')),
|
|
11
|
+
height: Number(track.attributes('data-track-height')),
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
describe('WaveformChart incomplete grid rows', () => {
|
|
16
|
+
it.each(['independent', 'separated', 'compact'] as const)(
|
|
17
|
+
'fills an incomplete two by two row in %s mode',
|
|
18
|
+
async (displayMode) => {
|
|
19
|
+
const wrapper = await mountSizedChart(gridSeries(3), {
|
|
20
|
+
displayMode,
|
|
21
|
+
grid: { rowCount: 2, columnCount: 2, fillIncompleteLastRow: true },
|
|
22
|
+
})
|
|
23
|
+
const tracks = wrapper.findAll('.waveform-chart__track')
|
|
24
|
+
const first = geometry(tracks[0]!)
|
|
25
|
+
const last = geometry(tracks[2]!)
|
|
26
|
+
|
|
27
|
+
expect(tracks).toHaveLength(3)
|
|
28
|
+
expect(wrapper.findAll('.waveform-chart__track--empty')).toHaveLength(0)
|
|
29
|
+
expect(wrapper.findAll('.waveform-chart__grid-slot-placeholder')).toHaveLength(0)
|
|
30
|
+
expect(last.left).toBe(0)
|
|
31
|
+
expect(last.width).toBeGreaterThan(first.width * 1.8)
|
|
32
|
+
expect(last.top).toBeGreaterThan(first.top)
|
|
33
|
+
if (displayMode === 'independent') {
|
|
34
|
+
const overlays = wrapper.findAll('.waveform-chart__overlay--independent')
|
|
35
|
+
expect(overlays).toHaveLength(3)
|
|
36
|
+
expect(Number(overlays[2]?.attributes('width'))).toBe(last.width)
|
|
37
|
+
} else {
|
|
38
|
+
expect(wrapper.findAll('.waveform-chart__overlay--shared')).toHaveLength(1)
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
it('removes unused one-column rows and redistributes chart height', async () => {
|
|
44
|
+
const base = await mountSizedChart(gridSeries(3), {
|
|
45
|
+
displayMode: 'independent',
|
|
46
|
+
grid: { rowCount: 4, columnCount: 1 },
|
|
47
|
+
})
|
|
48
|
+
const filled = await mountSizedChart(gridSeries(3), {
|
|
49
|
+
displayMode: 'independent',
|
|
50
|
+
grid: { rowCount: 4, columnCount: 1, fillIncompleteLastRow: true },
|
|
51
|
+
})
|
|
52
|
+
const baseFirst = geometry(base.findAll('.waveform-chart__track')[0]!)
|
|
53
|
+
const filledTracks = filled.findAll('.waveform-chart__track')
|
|
54
|
+
const filledFirst = geometry(filledTracks[0]!)
|
|
55
|
+
const filledLast = geometry(filledTracks[2]!)
|
|
56
|
+
|
|
57
|
+
expect(filledTracks).toHaveLength(3)
|
|
58
|
+
expect(filledFirst.height).toBeGreaterThan(baseFirst.height)
|
|
59
|
+
expect(filledLast.top + filledLast.height).toBeGreaterThan(baseFirst.height * 3)
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
it('keeps the final two tracks evenly distributed in a two by three grid', async () => {
|
|
63
|
+
const wrapper = await mountSizedChart(gridSeries(5), {
|
|
64
|
+
displayMode: 'separated',
|
|
65
|
+
grid: { rowCount: 2, columnCount: 3, fillIncompleteLastRow: true },
|
|
66
|
+
})
|
|
67
|
+
const tracks = wrapper.findAll('.waveform-chart__track').map(geometry)
|
|
68
|
+
|
|
69
|
+
expect(tracks).toHaveLength(5)
|
|
70
|
+
expect(tracks[3]?.left).toBe(0)
|
|
71
|
+
expect(tracks[3]?.width).toBeCloseTo(tracks[4]?.width ?? 0)
|
|
72
|
+
expect(tracks[4]?.left).toBeGreaterThan((tracks[3]?.width ?? 0) + 1)
|
|
73
|
+
})
|
|
74
|
+
|
|
75
|
+
it('keeps full pages unchanged and fills a partial second page', async () => {
|
|
76
|
+
const data = gridSeries(5)
|
|
77
|
+
const standard = await mountSizedChart(data, {
|
|
78
|
+
displayMode: 'separated',
|
|
79
|
+
grid: { rowCount: 2, columnCount: 2 },
|
|
80
|
+
})
|
|
81
|
+
const filled = await mountSizedChart(data, {
|
|
82
|
+
displayMode: 'separated',
|
|
83
|
+
grid: { rowCount: 2, columnCount: 2, fillIncompleteLastRow: true },
|
|
84
|
+
})
|
|
85
|
+
const standardFirstPage = standard.findAll('.waveform-chart__track').map(geometry)
|
|
86
|
+
expect(filled.findAll('.waveform-chart__track').map(geometry)).toEqual(standardFirstPage)
|
|
87
|
+
|
|
88
|
+
await filled.get('.ant-pagination-next button').trigger('click')
|
|
89
|
+
await flushPromises()
|
|
90
|
+
const secondPage = filled.findAll('.waveform-chart__track').map(geometry)
|
|
91
|
+
expect(secondPage).toHaveLength(1)
|
|
92
|
+
expect(secondPage[0]?.left).toBe(0)
|
|
93
|
+
expect(secondPage[0]?.width).toBeGreaterThan(standardFirstPage[0]?.width ?? 0)
|
|
94
|
+
})
|
|
95
|
+
})
|