Files
lanework/KanbanTests/BoardBackgroundFiltersTests.swift
T

69 lines
3.0 KiB
Swift

import SwiftUI
import Testing
@testable import Kanban
/// **`BoardBackgroundFilters`** — the Background tab's generated picker: the default-tone rule and
/// the pure filters → `FacetsRecipe` assembly, pinned the way the popover's other pure seams are
/// (`BoardInfoMetrics`, `BoardDiskFootprint` in `BoardInfoTabTests`). Everything else about the
/// carousel — the strip's layout, the placeholder chip, the apply gesture — is SwiftUI and
/// deliberately untested; `FacetsGeneratorTests` and `GeneratedBackgroundTests` already cover the
/// generator and the write path this feeds.
@Suite("Board popover ▸ Background tab filters")
struct BoardBackgroundFiltersTests {
@Test("Dark system appearance opens on Tone Dark, light opens on Tone Light")
func defaultToneFollowsTheSystem() {
#expect(BoardBackgroundFilters.defaultTone(colorScheme: .dark) == .dark)
#expect(BoardBackgroundFilters.defaultTone(colorScheme: .light) == .light)
}
@Test("The opening state is mono, medium, mid — only tone varies with the system")
func initialStateIsTheReviewedDefaults() {
let light = BoardBackgroundFilters.initial(colorScheme: .light)
#expect(light.tone == .light)
#expect(light.colors == .mono)
#expect(light.mesh == .medium)
#expect(light.saturation == .mid)
let dark = BoardBackgroundFilters.initial(colorScheme: .dark)
#expect(dark.tone == .dark)
#expect(dark.colors == .mono)
#expect(dark.mesh == .medium)
#expect(dark.saturation == .mid)
}
@Test("A hue and a seed assemble the exact recipe the filters describe")
func recipeAssemblesEveryAxis() {
let filters = BoardBackgroundFilters(tone: .dark, colors: .trio, mesh: .fine, saturation: .rich)
let recipe = filters.recipe(hue: .iris, seed: 0x5EED)
#expect(recipe.hue == .iris)
#expect(recipe.strategy == .trio)
#expect(recipe.density == .fine)
#expect(recipe.tone == .dark)
#expect(recipe.saturation == .rich)
#expect(recipe.seed == 0x5EED)
}
@Test("Two hues under the same filters and seed differ only in hue")
func onlyHueChangesAcrossTheWheel() {
let filters = BoardBackgroundFilters.initial(colorScheme: .light)
let sky = filters.recipe(hue: .sky, seed: 42)
let rose = filters.recipe(hue: .rose, seed: 42)
#expect(sky.hue == .sky)
#expect(rose.hue == .rose)
#expect(sky.strategy == rose.strategy)
#expect(sky.density == rose.density)
#expect(sky.tone == rose.tone)
#expect(sky.saturation == rose.saturation)
#expect(sky.seed == rose.seed)
}
@Test("The same filters and seed recipe identically — the preview/apply agreement the carousel depends on")
func sameInputsRecipeIdentically() {
let filters = BoardBackgroundFilters(tone: .light, colors: .duo, mesh: .coarse, saturation: .soft)
#expect(filters.recipe(hue: .forest, seed: 7) == filters.recipe(hue: .forest, seed: 7))
}
}