Extract Grammaratur, Dregarnuhr, Geduldh, Mestionora, Ordoschnellic, Schutzaria, Kunstzeal and Seheweit behind compatible application contracts. Include accumulated editor resilience, navigation and theme UX, remote CLI, storage/schema and DR groundwork, tests and design/operations documentation. Verified: uncached full Go suite; go vet ./...; race tests for all eight components; 11 targeted Chromium tests; Node suites; 19 Python CLI tests; reproducible editor build. No push, release tag or deployment in this checkpoint.
64 lines
1.9 KiB
Go
64 lines
1.9 KiB
Go
package server
|
|
|
|
import (
|
|
"context"
|
|
"net/http"
|
|
"net/http/httptest"
|
|
"os"
|
|
"os/exec"
|
|
"strings"
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
func TestBrowserAddressCommandsJS(t *testing.T) {
|
|
node, err := exec.LookPath("node")
|
|
if err != nil {
|
|
t.Skip("node required")
|
|
}
|
|
t.Chdir("../..")
|
|
if out, err := exec.Command(node, "--test", "internal/server/testdata/browser-address.test.cjs").CombinedOutput(); err != nil {
|
|
t.Fatalf("%v\n%s", err, out)
|
|
}
|
|
}
|
|
|
|
func TestPriorityNavigationChromium(t *testing.T) {
|
|
if os.Getenv("PAGESWIKI_BROWSER_TEST") != "1" {
|
|
t.Skip("opt-in Chromium")
|
|
}
|
|
for _, layout := range []string{"classic", "search", "directory"} {
|
|
t.Run(layout, func(t *testing.T) { priorityNavigationChromium(t, layout) })
|
|
}
|
|
}
|
|
|
|
func priorityNavigationChromium(t *testing.T, layout string) {
|
|
s, token, domain := configFixture(t)
|
|
s.mux.HandleFunc("/v/browser/", s.handleBrowser)
|
|
s.mux.HandleFunc("/e/", s.handleEditorRoute)
|
|
s.mux.HandleFunc("/", s.handleHome)
|
|
if err := s.store.SetConfigInDomain(domain, "home_layout", layout); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
script, err := os.ReadFile("internal/server/testdata/priority-navigation.js")
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
r.Host = "localhost"
|
|
r.Header.Set("Authorization", "Bearer "+token)
|
|
if r.URL.Path == "/fixture" {
|
|
w.Header().Set("Content-Type", "text/html; charset=utf-8")
|
|
_, _ = w.Write([]byte("<!doctype html><body><script>" + string(script) + "</script></body>"))
|
|
return
|
|
}
|
|
s.withAuthorization(s.mux).ServeHTTP(w, r)
|
|
}))
|
|
defer server.Close()
|
|
ctx, cancel := context.WithTimeout(context.Background(), 60*time.Second)
|
|
defer cancel()
|
|
target := strings.Replace(server.URL, "127.0.0.1", "localhost", 1) + "/fixture"
|
|
if out, err := exec.CommandContext(ctx, "node", "internal/server/testdata/vim-browser-smoke.mjs", target, t.TempDir()).CombinedOutput(); err != nil {
|
|
t.Fatalf("navigation: %v\n%s", err, out)
|
|
}
|
|
}
|