- The strategy/preset lists were loaded once with failures swallowed, so a single failed first request left the strategy dropdown empty forever. They are now retried every 3s until populated. - Clearer collapse affordance: hover highlight, a hide/show hint, and a tooltip; Backtest and Parameter sweep start collapsed so the strategy selector and status are immediately visible. - Adds an integration test that the strategy dropdown is populated and the panel actually collapses.
49 lines
1.5 KiB
JavaScript
49 lines
1.5 KiB
JavaScript
import { mount } from '@vue/test-utils'
|
|
import { describe, expect, it } from 'vitest'
|
|
import StrategyPanel from './components/StrategyPanel.vue'
|
|
|
|
function mountPanel() {
|
|
return mount(StrategyPanel, {
|
|
props: {
|
|
strategies: [
|
|
{
|
|
key: 'sma_cross',
|
|
name: 'SMA Crossover',
|
|
description: 'test',
|
|
params: [{ name: 'fast', type: 'int', default: 10, description: '' }],
|
|
},
|
|
],
|
|
status: { running: false, symbol: 'BTC/USDT', timeframe: '5m', open_positions: 0 },
|
|
busy: false,
|
|
presets: [],
|
|
},
|
|
})
|
|
}
|
|
|
|
describe('StrategyPanel collapse', () => {
|
|
it('shows the strategy form by default', () => {
|
|
const wrapper = mountPanel()
|
|
expect(wrapper.find('select').exists()).toBe(true)
|
|
})
|
|
|
|
it('hides the form when the header is clicked', async () => {
|
|
const wrapper = mountPanel()
|
|
const header = wrapper.find('button')
|
|
expect(header.attributes('aria-expanded')).toBe('true')
|
|
|
|
await header.trigger('click')
|
|
|
|
expect(wrapper.find('button').attributes('aria-expanded')).toBe('false')
|
|
// The form container is v-show-hidden, so the select is no longer visible.
|
|
const hidden = wrapper.findAll('div').some((d) => d.element.style.display === 'none')
|
|
expect(hidden).toBe(true)
|
|
})
|
|
|
|
it('picks the first strategy so the dropdown is populated', () => {
|
|
const wrapper = mountPanel()
|
|
const select = wrapper.find('select')
|
|
expect(select.element.value).toBe('sma_cross')
|
|
expect(select.findAll('option')).toHaveLength(1)
|
|
})
|
|
})
|