Files
windmill/frontend/src/lib/components/scriptSettings.test.ts
T
0249bb94ac refactor: harmonize flow and script settings layout (#12013)
* refactor: harmonize flow and script settings layout

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* fix: keep the priority input open while it is edited

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* fix: keep settings rows open while edited and name the deploying user for non-admins

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* fix: write a setting before its row opens and show its real state while edited

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* fix: slide settings rows open to their full height

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* fix: remount a settings row's fields when its toggle turns it on

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* fix: put the AI prompt behind a settings toggle

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

* feat: summarize active runtime and permission settings on the metadata tab

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

* refactor: move the active settings chips into the settings header

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

* fix: bring back the active setting icons on the settings tabs

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

---------

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-authored-by: Ruben Fiszel <ruben@windmill.dev>
2026-10-27 01:24:09 +01:00

54 lines
1.7 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('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'
)
})
})