Files
drover-go/internal/gui/embed_test.go
T
root b6619ef53b
Build / test (push) Failing after 30s
Build / build-windows (push) Has been skipped
internal/gui: Wails app with Classic React variant + theme toggle
- app.go: App struct with stub bindings (RunCheck/StartEngine/
  StopEngine/GetStatus/Version) — emits check:result, check:done,
  engine:status, stats:update events. Real backend lands in Phase 1.
- run.go: wails.Run() with frameless 480x640 fixed window, Classic
  dark bg matching theme.
- embed.go: //go:embed all:frontend/dist for the Vite build output.
- frontend/: Vite + React project derived from `wails init -t react`.
  Removed default template assets and wired Classic variant from
  docs/design/v2/.
  - components/Classic.jsx: variant 1 with custom title bar
    (drag region, sun/moon theme toggle, min/close hooked to
    Wails WindowMinimise/Quit).
  - components/shared.jsx: useDrover hook adapted to call Wails
    bindings and listen on backend events instead of mock SCENARIOS.
    Added IconSun + IconMoon for the title-bar toggle.
  - App.jsx: owns mode state, wraps setMode in
    document.startViewTransition so the title-bar toggle gives a
    circle-reveal sweep from the cursor.
  - style.css: clean reset (overflow hidden, no scrollbars, brand
    background) — replaces the wails-react-template defaults.
  - wailsjs/go/gui/App.js: hand-written bindings since our App
    struct lives in package gui rather than the standard top-level
    main; `wails generate module` would have written package main
    bindings here.
- build/: standard wails artifacts (icon, manifest); will be
  consumed by `wails build` once we wire it through CI.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-01 15:17:19 +03:00

55 lines
1.1 KiB
Go

package gui
import (
"io/fs"
"strings"
"testing"
)
// TestEmbed verifies that frontend/dist actually got embedded — easy to
// silently miss this and end up with a Wails window that 404s on every
// asset.
func TestEmbed(t *testing.T) {
sub, err := fs.Sub(Assets, "frontend/dist")
if err != nil {
t.Fatalf("fs.Sub: %v", err)
}
var files []string
fs.WalkDir(sub, ".", func(p string, d fs.DirEntry, err error) error {
if err != nil || d.IsDir() {
return err
}
files = append(files, p)
return nil
})
if len(files) == 0 {
t.Fatal("frontend/dist embed is empty — did you forget `npm run build`?")
}
if !sliceContains(files, "index.html") {
t.Fatalf("no index.html in embed; got %v", files)
}
hasJS := false
for _, f := range files {
if strings.HasSuffix(f, ".js") {
hasJS = true
break
}
}
if !hasJS {
t.Fatalf("no .js bundle in embed; got %v", files)
}
t.Logf("embed contains %d files (looks healthy):", len(files))
for _, f := range files {
t.Logf(" %s", f)
}
}
func sliceContains(xs []string, x string) bool {
for _, v := range xs {
if v == x {
return true
}
}
return false
}