// Copyright (c) 2026 Storm Dragon // SPDX-License-Identifier: GPL-3.0-or-later package app import ( "context" "git.stormux.org/storm/fenrir/internal/command" "git.stormux.org/storm/fenrir/internal/config" "git.stormux.org/storm/fenrir/internal/input" "git.stormux.org/storm/fenrir/internal/presentation" "git.stormux.org/storm/fenrir/internal/screen" "reflect" "testing" ) func TestReviewNavigationContextSoundFallbackAndInterruption(t *testing.T) { for _, sound := range []bool{false, true} { for _, feedback := range []bool{false, true} { source := &fakeSource{snapshot: screen.Snapshot{Terminal: 2, Active: true, Rows: 2, Cols: 3, X: 2, Cells: []rune("abcÉ! ")}} voice, sounds := &fakeVoice{}, &fakeSounds{} keys := &fakeKeys{poll: func(_ bool, handle func(input.Decision)) error { voice.messages, sounds.cues = nil, nil handle(input.Decision{Command: command.NextChar, Interrupt: true}) handle(input.Decision{Command: command.NextChar, Interrupt: true}) handle(input.Decision{Command: command.LineStart, Interrupt: true}) handle(input.Decision{Command: command.Quit}) return nil }} settings := config.Defaults() settings.Reading.RaisePitchForCapitals = false settings.Presentation.Sound.Enabled = sound settings.Review.LineBreak = feedback if err := run(context.Background(), source, keys, voice, nil, RunOptions{Settings: settings, Sounds: sounds}); err != nil { t.Fatal(err) } want := []string{"É"} var wantCues []presentation.Cue if feedback { if sound { wantCues = []presentation.Cue{presentation.LineEnd} } else { want = append(want, "line break") } } want = append(want, "bang", "É", "beginning of line") if !reflect.DeepEqual(voice.messages, want) || !reflect.DeepEqual(sounds.cues, wantCues) || voice.interrupts != 3 { t.Fatalf("sound=%v feedback=%v: speech=%q cues=%v interrupts=%d", sound, feedback, voice.messages, sounds.cues, voice.interrupts) } } } }