93 lines
3.1 KiB
Go
93 lines
3.1 KiB
Go
package creator_web_test
|
|
|
|
import (
|
|
"os"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestCreatorCabinetHasAuthenticatedOperationalAndLearningSurfaces(t *testing.T) {
|
|
page, err := os.ReadFile("../../cmd/creator-web/static/index.html")
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
markup := string(page)
|
|
for _, marker := range []string{
|
|
`<form id="login-form"`, `aria-labelledby="diagnostics-title"`, `data-page="operations"`,
|
|
`id="learning"`, `id="reflection-list"`, `id="skill-list"`, `id="settings"`,
|
|
`id="logout"`, `role="alert"`, `aria-live="polite"`,
|
|
} {
|
|
if !strings.Contains(markup, marker) {
|
|
t.Fatalf("cabinet missing %q", marker)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestCreatorCabinetRoutesSessionAndLearningThroughAuthenticatedAPI(t *testing.T) {
|
|
script, err := os.ReadFile("../../cmd/creator-web/static/assets/console.js")
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
code := string(script)
|
|
for _, marker := range []string{
|
|
`request("/api/session/current")`, `request("/api/learning/recent?limit=8")`,
|
|
`request("/api/advisory-policy")`, `request("/api/capabilities/cognitive-proposal/health")`, `request("/api/learning/recent?limit=1")`, `sessionStorage.getItem("domovoy.creator.session")`,
|
|
`if (response.status === 401`,
|
|
} {
|
|
if !strings.Contains(code, marker) {
|
|
t.Fatalf("console missing authenticated flow %q", marker)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestCreatorCabinetResponsiveAndReducedMotionRulesExist(t *testing.T) {
|
|
style, err := os.ReadFile("../../cmd/creator-web/static/assets/console.css")
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
css := string(style)
|
|
for _, marker := range []string{"@media (max-width: 680px)", "@media (prefers-reduced-motion: reduce)", ".learning-grid { grid-template-columns: 1fr; }"} {
|
|
if !strings.Contains(css, marker) {
|
|
t.Fatalf("console missing responsive rule %q", marker)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestCreatorCabinetExposesFleetAndExecutorTruthfulStatusSurfaces(t *testing.T) {
|
|
markupBytes, err := os.ReadFile("../../cmd/creator-web/static/index.html")
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
markup := string(markupBytes)
|
|
for _, marker := range []string{
|
|
`id="fleet-summary"`, `id="fleet-selected"`, `id="fleet-list"`,
|
|
`id="agent-worker-state"`, `id="agent-worker-message"`,
|
|
} {
|
|
if !strings.Contains(markup, marker) {
|
|
t.Fatalf("operations cabinet missing truthful status surface %q", marker)
|
|
}
|
|
}
|
|
|
|
serverBytes, err := os.ReadFile("../../cmd/creator-web/server.go")
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
server := string(serverBytes)
|
|
for _, marker := range []string{`r.URL.Path == "/api/fleet/readiness"`, `r.URL.Path == "/api/agent-worker/status"`} {
|
|
if !strings.Contains(server, marker) {
|
|
t.Fatalf("creator server missing authenticated status route %q", marker)
|
|
}
|
|
}
|
|
|
|
consoleBytes, err := os.ReadFile("../../cmd/creator-web/static/assets/console.js")
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
console := string(consoleBytes)
|
|
for _, marker := range []string{`request("/api/fleet/readiness")`, `request("/api/agent-worker/status")`, `result.selected_tier || "не выбран"`, `status.mode || "UNKNOWN"`} {
|
|
if !strings.Contains(console, marker) {
|
|
t.Fatalf("console missing truthful status rendering %q", marker)
|
|
}
|
|
}
|
|
}
|