package cli import ( "os" "path/filepath" "testing" ) func TestCLIPluginListEnableDisableAndDoctor(t *testing.T) { dataRoot := t.TempDir() // `plugin list` should succeed and include builtins + bundled wheel-invert. if code := Main([]string{"--data-root", dataRoot, "plugin", "list", "--json"}); code != 0 { t.Fatalf("plugin list exited %d", code) } // Enable and disable bundled wheel-invert plugin via CLI. if code := Main([]string{"--data-root", dataRoot, "plugin", "enable", "reims.input.wheel-invert"}); code != 0 { t.Fatalf("plugin enable wheel-invert exited %d", code) } if code := Main([]string{"--data-root", dataRoot, "plugin", "disable", "reims.input.wheel-invert"}); code != 0 { t.Fatalf("plugin disable wheel-invert exited %d", code) } // Builtin/bundled cannot be removed. if code := Main([]string{"--data-root", dataRoot, "plugin", "remove", "reims.input.wheel-invert"}); code == 0 { t.Fatal("expected removing bundled plugin to fail") } // Safe mode window flag round-trips cleanly. w, ok := ParseWindowArgs([]string{"--safe-mode"}) if !ok || !w.SafeMode { t.Fatalf("ParseWindowArgs(--safe-mode) = %+v, %v", w, ok) } // Dev link + doctor on a local directory. devDir := t.TempDir() _ = os.WriteFile(filepath.Join(devDir, "plugin.json"), []byte(`{ "schema": 1, "id": "dev.sample.theme", "version": "0.1.0", "name": {"en-US": "Dev Theme"}, "engines": {"pluginApi": "^1.0.0"} }`), 0o644) if code := Main([]string{"--data-root", dataRoot, "plugin", "link", devDir}); code != 0 { t.Fatalf("plugin link exited %d", code) } if code := Main([]string{"--data-root", dataRoot, "plugin", "doctor", devDir}); code != 0 { t.Fatalf("plugin doctor dir exited %d", code) } }