Files
new-api-custom/web/src/features/group-status/__tests__/adaptive-schedule.test.tsx
T

65 lines
1.8 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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()
})
})