Refactor architecture into eight components and consolidate reliability work
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.
This commit is contained in:
1 parent
9dd425f765
commit
d5d21b7841
302 files changed
+20037
-3492
No files matched your search
@@ -0,0 +1,91 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"os"
|
||||
"os/exec"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestCommandCompletionReadACL(t *testing.T) {
|
||||
s, token, _ := searchServerFixture(t)
|
||||
s.mux.HandleFunc("/_/api/v1/path-picker", s.handlePathPickerAPI)
|
||||
w := configRequest(s, token, "GET", "/_/api/v1/path-picker?path=/docs&mode=children", nil)
|
||||
if w.Code != 200 || strings.Contains(w.Body.String(), "hidden") || !strings.Contains(w.Body.String(), "nebula guide?#%") {
|
||||
t.Fatalf("ACL completion: %d %s", w.Code, w.Body.String())
|
||||
}
|
||||
}
|
||||
|
||||
func TestCommandPathCompletion(t *testing.T) {
|
||||
s, token, domain := configFixture(t)
|
||||
s.mux.HandleFunc("/_/api/v1/path-picker", s.handlePathPickerAPI)
|
||||
createUserSpacePage(t, s, domain, "/manual", "<h1>Parent document and folder</h1>")
|
||||
for i := 0; i < 260; i++ {
|
||||
if _, err := s.store.CreatePageAtPathInDomain(domain, fmt.Sprintf("/manual/a%03d", i)); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
createUserSpacePage(t, s, domain, "/manual/日本語 #?", "plain")
|
||||
w := configRequest(s, token, "GET", "/_/api/v1/path-picker?path=/manual&mode=children&prefix=日本語", nil)
|
||||
var result struct {
|
||||
Path string `json:"path"`
|
||||
Entries []pathPickerEntry `json:"entries"`
|
||||
}
|
||||
if w.Code != 200 || json.Unmarshal(w.Body.Bytes(), &result) != nil || result.Path != "/manual" || len(result.Entries) != 1 || result.Entries[0].Name != "日本語 #?" {
|
||||
t.Fatalf("completion: %d %s", w.Code, w.Body.String())
|
||||
}
|
||||
w = configRequest(s, "", "GET", "/_/api/v1/path-picker?path=/manual&mode=children", nil)
|
||||
if w.Code == 200 {
|
||||
t.Fatal("anonymous API listed private paths")
|
||||
}
|
||||
}
|
||||
|
||||
func TestCommandAndHighlightChromium(t *testing.T) {
|
||||
if os.Getenv("PAGESWIKI_BROWSER_TEST") != "1" {
|
||||
t.Skip("opt-in Chromium")
|
||||
}
|
||||
s, token, domain, _ := editorFixture(t)
|
||||
s.mux.HandleFunc("/v/browser/", s.handleBrowser)
|
||||
s.mux.HandleFunc("/_/api/v1/path-picker", s.handlePathPickerAPI)
|
||||
s.mux.HandleFunc("/notes", s.handleSemanticRoute)
|
||||
s.mux.HandleFunc("/", s.handleHome)
|
||||
createUserSpacePage(t, s, domain, "/notes", `<h1>Code sample</h1><pre><code class="language-python"># comment
|
||||
def hello():
|
||||
return "<script>literal</script>"</code></pre>`)
|
||||
createUserSpacePage(t, s, domain, "/notes/alpha", "<h1>Alpha</h1>")
|
||||
createUserSpacePage(t, s, domain, "/notes/alpine", "<h1>Alpine</h1>")
|
||||
createUserSpacePage(t, s, domain, "/日本語 #?/child", "<h1>Unicode</h1>")
|
||||
script, err := os.ReadFile("internal/server/testdata/command-highlight.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 style='margin:0'><script>" + string(script) + "</script></body>"))
|
||||
return
|
||||
}
|
||||
s.withAuthorization(s.mux).ServeHTTP(w, r)
|
||||
}))
|
||||
defer server.Close()
|
||||
for _, width := range []string{"1440", "375"} {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 60*time.Second)
|
||||
shot := ""
|
||||
if base := os.Getenv("PAGESWIKI_COMMAND_SCREENSHOT"); base != "" {
|
||||
shot = base + "-" + width + ".png"
|
||||
}
|
||||
out, err := exec.CommandContext(ctx, "node", "internal/server/testdata/vim-browser-smoke.mjs", server.URL+"/fixture", t.TempDir(), shot, width, "950").CombinedOutput()
|
||||
cancel()
|
||||
if err != nil {
|
||||
t.Fatalf("%s: %v\n%s", width, err, out)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user