65 lines
1.8 KiB
TypeScript
65 lines
1.8 KiB
TypeScript
import { cleanup, render, screen } from '@testing-library/react'
|
||
import { t } from 'i18next'
|
||
import { afterEach, describe, expect, it } from 'vitest'
|
||
|
||
import { AdaptiveSchedule } from '../adaptive-schedule'
|
||
import { BenchmarkPanel } from '../detection-panel'
|
||
|
||
afterEach(cleanup)
|
||
|
||
describe('adaptive detection schedule', () => {
|
||
it('shows one interval for channels with the same cadence', () => {
|
||
render(<AdaptiveSchedule min={60} max={60} />)
|
||
expect(
|
||
screen.getByText(
|
||
t('Current interval: {{minutes}} minutes', { minutes: 60 }),
|
||
{ exact: false }
|
||
)
|
||
).toBeInTheDocument()
|
||
})
|
||
it('shows a range for channels with different cadences', () => {
|
||
render(<AdaptiveSchedule min={15} max={60} />)
|
||
expect(
|
||
screen.getByText(
|
||
t('Current intervals: {{min}}–{{max}} minutes', { min: 15, max: 60 }),
|
||
{ exact: false }
|
||
)
|
||
).toBeInTheDocument()
|
||
})
|
||
it('uses the initial interval when no schedule has been recorded', () => {
|
||
render(<AdaptiveSchedule />)
|
||
expect(
|
||
screen.getByText(
|
||
t('Current interval: {{minutes}} minutes', { minutes: 30 }),
|
||
{ exact: false }
|
||
)
|
||
).toBeInTheDocument()
|
||
})
|
||
it('renders benchmark schedule data instead of the old fixed frequency', () => {
|
||
render(
|
||
<BenchmarkPanel
|
||
data={{
|
||
channels: 2,
|
||
normal: 1,
|
||
degraded: 0,
|
||
unknown: 0,
|
||
failed: 0,
|
||
running: 0,
|
||
history: [],
|
||
interval_minutes: 15,
|
||
interval_max_minutes: 30,
|
||
}}
|
||
/>
|
||
)
|
||
expect(
|
||
screen.getByText(
|
||
t('Current intervals: {{min}}–{{max}} minutes', { min: 15, max: 30 }),
|
||
{ exact: false }
|
||
)
|
||
).toBeInTheDocument()
|
||
expect(
|
||
screen.queryByText(t('Every 30 minutes, one work per Astra channel.'))
|
||
).not.toBeInTheDocument()
|
||
})
|
||
})
|