Files
lazyrun/internal/ui/main_window_test.go
oxpoe d6f6c69c5a Label jenis aplikasi dengan auto-detect (Go/AppImage/Electron/Script/Windows/Binary/PWA)
- internal/shortcut/kind.go: deteksi dari isi berkas - build info Go, magic
  AppImage, resources/*.asar untuk Electron, shebang untuk script, MZ untuk .exe
- .exe Windows kini boleh dipasang dan dijalankan lewat wine (Exec=wine <path>);
  kalau wine tidak terpasang, install ditolak dengan pesan jelas
- metadata menyimpan kind; chip jenis ditampilkan di setiap baris shortcut
  (data lama tetap tampil sebagai Executable/PWA)
- dialog menampilkan hasil deteksi setelah berkas dipilih, mis. 'winbox.exe - windows'
- README: bagian label otomatis + screenshot baru
2026-10-13 08:21:38 +07:00

66 lines
1.6 KiB
Go

package ui
import (
"testing"
"fyne.io/fyne/v2/test"
"lazyrun/internal/shortcut"
"lazyrun/internal/store"
)
func TestBuildMainWindow(t *testing.T) {
a := test.NewApp()
defer a.Quit()
ui, err := build(a, "test")
if err != nil {
t.Fatalf("build(): %v", err)
}
if ui.win.Content() == nil {
t.Fatal("window tanpa content")
}
// dialog harus bisa dibuka tanpa panic
ui.showExecutableDialog()
ui.showWebAppDialog()
ui.checkUpdates()
}
func TestMetaText(t *testing.T) {
sc := store.Shortcut{Type: store.TypeWebApp, URL: "https://example.com/x", Targets: store.Targets{Menu: true}}
if got := metaText(sc); got != "example.com" {
t.Errorf("metaText() = %q", got)
}
exe := store.Shortcut{Type: store.TypeExecutable, BinaryPath: "/home/u/.local/bin/winbox"}
if got := metaText(exe); got != "winbox" {
t.Errorf("metaText() = %q", got)
}
}
func TestKindLabel(t *testing.T) {
cases := map[string]string{
shortcut.KindGo: "Go",
shortcut.KindAppImage: "AppImage",
shortcut.KindElectron: "Electron",
shortcut.KindScript: "Script",
shortcut.KindWindows: "Windows",
shortcut.KindBinary: "Binary",
shortcut.KindPWA: "PWA",
}
for kind, want := range cases {
sc := store.Shortcut{Kind: kind, Type: store.TypeExecutable}
if got := kindLabel(sc); got != want {
t.Errorf("kindLabel(%q) = %q, mau %q", kind, got, want)
}
}
// data lama tanpa kind
if got := kindLabel(store.Shortcut{Type: store.TypeExecutable}); got != "Executable" {
t.Errorf("kindLabel(lama, executable) = %q", got)
}
if got := kindLabel(store.Shortcut{Type: store.TypeWebApp}); got != "PWA" {
t.Errorf("kindLabel(lama, webapp) = %q", got)
}
}