Files
pages/internal/store/mestionora_compatibility_test.go
T
Anya Tokugawa d5d21b7841
Build and publish container images / images (push) Successful in 9m34s
Release container images / release (push) Successful in 36s
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.
2026-11-01 15:23:31 +09:00

62 lines
2.7 KiB
Go

package store_test
import (
"context"
"reflect"
"strings"
"testing"
"pageswiki/internal/mestionora"
"pageswiki/internal/store"
)
func TestMestionoraStoreCompatibilityAndRequestIsolation(t *testing.T) {
st := searchStoreFixture(t)
domain := defaultDomainUUID(t, st)
object := insertSearchFilterPage(t, st, domain, "/docs/needle", "text/html", "needle.html", "<h1>Needle Guide</h1><p>needle body</p>", 1, 2000)
insertSearchFilterPage(t, st, domain, "/private/needle", "text/html", "secret.html", "<h1>Secret Needle</h1>", 1, 2000)
if _, err := st.DB.Exec(`INSERT INTO paths(domain_uuid,path,object_uuid,created_at) VALUES(?,'/private/alias',?,1)`, domain, object); err != nil {
t.Fatal(err)
}
engine := mestionora.NewSQLite(st.DB)
allow := func(p string) bool { return strings.HasPrefix(p, "/docs/") }
ctx := context.Background()
for _, options := range []store.SearchOptions{{}, {FileType: "html"}, {Extension: "html"}, {FromMS: searchFilterTime(1000), BeforeMS: searchFilterTime(3000)}} {
legacy, err := st.SearchPathsInDomainWithOptions(ctx, domain, "/", "needle", 20, allow, options)
if err != nil {
t.Fatal(err)
}
current, err := engine.SearchPathsInDomainWithOptions(ctx, domain, "/", "needle", 20, allow, options)
if err != nil || !reflect.DeepEqual(legacy, current) || len(current) != 1 || current[0].Path != "/docs/needle" {
t.Fatalf("incompatible/exposed results: %v %v", current, err)
}
}
legacy, err := st.SearchPathSuggestionsInDomain(ctx, domain, "/", "needle", 8, allow)
if err != nil {
t.Fatal(err)
}
current, err := engine.SearchPathSuggestionsInDomain(ctx, domain, "/", "needle", 8, allow)
if err != nil || !reflect.DeepEqual(legacy, current) || len(current) != 1 || current[0].Title != "Needle Guide" {
t.Fatalf("suggestion compatibility: %v %v", current, err)
}
for _, request := range []struct {
domain string
allowed func(string) bool
}{
{domain, nil}, {domain, func(string) bool { return false }}, {"other-domain", allow},
} {
results, err := engine.SearchPathsInDomainFiltered(ctx, request.domain, "/", "needle", 20, request.allowed)
if err != nil || len(results) != 0 {
t.Fatalf("prior request leaked: %v %v", results, err)
}
}
if store.ErrInvalidSearchOptions != mestionora.ErrInvalidSearchOptions || store.SearchCandidateLimit != mestionora.SearchCandidateLimit {
t.Fatal("compatibility identity changed")
}
// Alias method sets preserve City display/navigation projections too.
var city store.CitySearchResult = mestionora.CitySearchResult{Kind: "spot", Name: "home-undefined", Title: "Undefined", StreetTitle: "Home", PathPrefix: "/life/home/_undefined", NavigationPath: "/life/home"}
if city.DisplayTitle() != "Home" || city.ContentPath() != "/life/home" {
t.Fatal("City projection changed")
}
}