mirror of
https://github.com/runkids/skillshare.git
synced 2026-11-18 18:04:17 +00:00
Allow users to globally disable interactive TUI without adding --no-tui to every command. The setting is stored in config.yaml as `tui: false`. Priority: --no-tui flag > config tui field > default (true). - Add Config.TUI *bool field + IsTUIEnabled() helper - Add centralized shouldLaunchTUI() replacing 9 scattered TTY checks - Add `skillshare tui` command (show/on/off) - Update JSON schema with tui boolean property - Clean up unused golang.org/x/term imports (4 files)
72 lines
1.6 KiB
Go
72 lines
1.6 KiB
Go
//go:build !online
|
|
|
|
package integration
|
|
|
|
import (
|
|
"os"
|
|
"strings"
|
|
"testing"
|
|
|
|
"skillshare/internal/testutil"
|
|
)
|
|
|
|
func TestTUI_ShowDefault(t *testing.T) {
|
|
sb := testutil.NewSandbox(t)
|
|
defer sb.Cleanup()
|
|
|
|
sb.WriteConfig("source: " + sb.SourcePath + "\ntargets: {}\n")
|
|
|
|
result := sb.RunCLI("tui")
|
|
result.AssertSuccess(t)
|
|
result.AssertAnyOutputContains(t, "on")
|
|
result.AssertAnyOutputContains(t, "default")
|
|
}
|
|
|
|
func TestTUI_Off(t *testing.T) {
|
|
sb := testutil.NewSandbox(t)
|
|
defer sb.Cleanup()
|
|
|
|
sb.WriteConfig("source: " + sb.SourcePath + "\ntargets: {}\n")
|
|
|
|
result := sb.RunCLI("tui", "off")
|
|
result.AssertSuccess(t)
|
|
result.AssertAnyOutputContains(t, "disabled")
|
|
|
|
// Verify config file has tui: false
|
|
data, err := os.ReadFile(sb.ConfigPath)
|
|
if err != nil {
|
|
t.Fatalf("read config: %v", err)
|
|
}
|
|
if !strings.Contains(string(data), "tui: false") {
|
|
t.Errorf("config should contain 'tui: false', got:\n%s", data)
|
|
}
|
|
}
|
|
|
|
func TestTUI_On(t *testing.T) {
|
|
sb := testutil.NewSandbox(t)
|
|
defer sb.Cleanup()
|
|
|
|
// Start with tui: false
|
|
sb.WriteConfig("source: " + sb.SourcePath + "\ntargets: {}\ntui: false\n")
|
|
|
|
result := sb.RunCLI("tui", "on")
|
|
result.AssertSuccess(t)
|
|
result.AssertAnyOutputContains(t, "enabled")
|
|
|
|
// Verify status shows on
|
|
result = sb.RunCLI("tui")
|
|
result.AssertSuccess(t)
|
|
result.AssertAnyOutputContains(t, "on")
|
|
}
|
|
|
|
func TestTUI_InvalidArg(t *testing.T) {
|
|
sb := testutil.NewSandbox(t)
|
|
defer sb.Cleanup()
|
|
|
|
sb.WriteConfig("source: " + sb.SourcePath + "\ntargets: {}\n")
|
|
|
|
result := sb.RunCLI("tui", "banana")
|
|
result.AssertFailure(t)
|
|
result.AssertAnyOutputContains(t, "unknown argument")
|
|
}
|