Switch from Asuka to MyGo, keeping the API client and the feature set: - servers: saved servers, passwordless and password login, proxy, self-signed certificates, per-server device tokens (Keystore), connect form, instance list sheet with switch/disconnect - sessions: virtualized list, search, new session, rename/archive/delete, running indicator, event stream keeps it live - chat: pushed window with system back bar, streaming Markdown via ui/markdown, reasoning and tool rows with image previews, footer menu (read aloud via a Kotlin TTS plugin, copy, fork), user message menu (copy, revert, fork), context usage ring and detail sheet, attachments (photos/files via the document picker), permissions - release builds allow plain http:// LAN servers (Go's net/http dials directly, no cleartext manifest needed) - a local fork of MyGo (third_party/mygo) lowers the Android host's minSdk to 24 (Android 7.0); Go 1.27.4 via mise Version 0.3.0.
87 lines
3.0 KiB
Go
87 lines
3.0 KiB
Go
//go:build !js
|
|
|
|
package e2e
|
|
|
|
import (
|
|
"os"
|
|
"os/exec"
|
|
"path/filepath"
|
|
"runtime"
|
|
"strings"
|
|
"testing"
|
|
|
|
"github.com/egoist/mygo"
|
|
)
|
|
|
|
// TestRecentDocuments records a document the user opened and clears it
|
|
// again. On Linux the entry goes into the user's recently-used.xbel (GLib
|
|
// reads XDG_DATA_HOME once, so a temporary one would not be seen): the test
|
|
// removes its own entries, the only ones of its executable. Windows lists
|
|
// only files of the types the app opens, so the test registers one.
|
|
func TestRecentDocuments(t *testing.T) {
|
|
if _, ok := recentDocumentRecorded(""); !ok {
|
|
t.Skip("recent documents cannot be read back on " + runtime.GOOS)
|
|
}
|
|
if runtime.GOOS == "windows" {
|
|
registerFileType(t, ".mygorecent")
|
|
}
|
|
// The systems keep paths with symbolic links (macOS: /var is
|
|
// /private/var) and short names (Windows: RUNNER~1) resolved.
|
|
dir, err := filepath.EvalSymlinks(t.TempDir())
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
path := filepath.Join(dir, "recent document.mygorecent")
|
|
if err := os.WriteFile(path, []byte("recent"), 0o644); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
recorded := func() bool { r, _ := recentDocumentRecorded(path); return r }
|
|
defer mygo.App.ClearRecentDocuments()
|
|
|
|
if err := mygo.App.AddRecentDocument(path); err != nil {
|
|
t.Fatalf("AddRecentDocument: %v", err)
|
|
}
|
|
eventually(t, "the document to be recorded", recorded)
|
|
if err := mygo.App.ClearRecentDocuments(); err != nil {
|
|
t.Fatalf("ClearRecentDocuments: %v", err)
|
|
}
|
|
eventually(t, "the recent documents to be cleared", func() bool { return !recorded() })
|
|
}
|
|
|
|
// TestJumpListTasks commits the tasks of the jump list (Windows), then
|
|
// removes them. Elsewhere SetTasks does nothing.
|
|
func TestJumpListTasks(t *testing.T) {
|
|
tasks := []mygo.JumpListTask{
|
|
{Title: "New window", Description: "Open a new window", Args: []string{"mygo-e2e://new", "two words"}, WorkingDir: os.TempDir()},
|
|
{Title: "No arguments"},
|
|
}
|
|
if err := mygo.App.JumpList.SetTasks(tasks); err != nil {
|
|
t.Errorf("SetTasks: %v", err)
|
|
}
|
|
if err := mygo.App.JumpList.SetTasks(nil); err != nil {
|
|
t.Errorf("SetTasks(nil): %v", err)
|
|
}
|
|
}
|
|
|
|
// registerFileType makes the test executable the handler of the files with
|
|
// extension ext for the current user (Windows), as the installer does for
|
|
// the app's file associations, until the test ends.
|
|
func registerFileType(t *testing.T, ext string) {
|
|
exe, err := os.Executable()
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
reg := func(args ...string) {
|
|
if out, err := exec.Command("reg", args...).CombinedOutput(); err != nil {
|
|
t.Fatalf("reg %s: %v\n%s", strings.Join(args, " "), err, out)
|
|
}
|
|
}
|
|
const progID = "MyGo.E2E.RecentDocument"
|
|
reg("add", `HKCU\Software\Classes\`+ext+`\OpenWithProgids`, "/v", progID, "/t", "REG_NONE", "/f")
|
|
reg("add", `HKCU\Software\Classes\`+progID+`\shell\open\command`, "/ve", "/d", `"`+exe+`" "%1"`, "/f")
|
|
t.Cleanup(func() {
|
|
exec.Command("reg", "delete", `HKCU\Software\Classes\`+ext, "/f").Run()
|
|
exec.Command("reg", "delete", `HKCU\Software\Classes\`+progID, "/f").Run()
|
|
})
|
|
}
|