Files
windmill/frontend/src/lib/components/scriptSettings.test.ts
T
Ruben FiszelandClaude Opus 5.5 3c5a5caf97 feat: inherited low priority for background flows and scripts (#12256)
* feat: add inherited low priority for background flows and scripts

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix: keep a low flow priority over step priorities and align the -1 boundary

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* docs: note the rolling-upgrade ordering and the renamed queue index

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* refactor: order low priority by stored values instead of a coalesce index

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix: keep a runnable's own priority when its caller has none

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix: do not pass a flow step's default priority on to the jobs it starts

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-05 23:26:04 +01:00

59 lines
1.9 KiB
TypeScript

import { describe, it, expect } from 'vitest'
import { getActiveScriptSettingsBadges } from './scriptSettings'
describe('getActiveScriptSettingsBadges', () => {
it('returns no badges for undefined or empty settings', () => {
expect(getActiveScriptSettingsBadges(undefined)).toEqual([])
expect(getActiveScriptSettingsBadges({})).toEqual([])
})
it('only surfaces settings that are actually active', () => {
const keys = getActiveScriptSettingsBadges({
concurrent_limit: 3,
concurrency_time_window_s: 60,
cache_ttl: 600,
timeout: 120,
priority: 50,
tag: 'gpu'
}).map((b) => b.key)
expect(keys).toEqual(['timeout', 'concurrency', 'cache', 'priority', 'tag'])
})
it('treats a zero/absent priority and non-positive debounce as inactive', () => {
const keys = getActiveScriptSettingsBadges({
priority: 0,
debounce_delay_s: 0
}).map((b) => b.key)
expect(keys).toEqual([])
})
it('surfaces a negative priority as low priority', () => {
const keys = getActiveScriptSettingsBadges({ priority: -100 }).map((b) => b.key)
expect(keys).toEqual(['low_priority'])
})
it('treats non-positive concurrency limits, timeouts and cache ttl as inactive (legacy zero rows)', () => {
const keys = getActiveScriptSettingsBadges({
concurrent_limit: 0,
timeout: 0,
cache_ttl: 0
}).map((b) => b.key)
expect(keys).toEqual([])
})
it('keeps delete_after_secs of 0 active (immediate deletion is a real setting)', () => {
const badge = getActiveScriptSettingsBadges({ delete_after_secs: 0 })
expect(badge.map((b) => b.key)).toEqual(['delete_after_use'])
expect(badge[0].detail).toContain('immediately')
})
it('pluralizes the concurrency detail correctly', () => {
expect(getActiveScriptSettingsBadges({ concurrent_limit: 1 })[0].detail).toContain(
'Max 1 execution'
)
expect(getActiveScriptSettingsBadges({ concurrent_limit: 2 })[0].detail).toContain(
'Max 2 executions'
)
})
})