mirror of
https://tangled.org/evan.jarrett.net/at-container-registry
synced 2026-09-03 08:46:57 +00:00
105 lines
2.5 KiB
Go
105 lines
2.5 KiB
Go
package handlers_test
|
|
|
|
import (
|
|
"net/http"
|
|
"net/http/httptest"
|
|
"strings"
|
|
"testing"
|
|
|
|
"atcr.io/pkg/appview"
|
|
"atcr.io/pkg/appview/handlers"
|
|
)
|
|
|
|
func TestLearnMoreHandler_RendersPage(t *testing.T) {
|
|
templates, err := appview.Templates(nil)
|
|
if err != nil {
|
|
t.Fatalf("Failed to load templates: %v", err)
|
|
}
|
|
|
|
handler := &handlers.LearnMoreHandler{
|
|
BaseUIHandler: handlers.BaseUIHandler{
|
|
Templates: templates,
|
|
RegistryURL: "myregistry.example.com",
|
|
SiteURL: "myregistry.example.com",
|
|
},
|
|
}
|
|
|
|
req := httptest.NewRequest("GET", "/learn-more", nil)
|
|
rr := httptest.NewRecorder()
|
|
handler.ServeHTTP(rr, req)
|
|
|
|
if rr.Code != http.StatusOK {
|
|
t.Errorf("Expected status %d, got %d", http.StatusOK, rr.Code)
|
|
}
|
|
|
|
body := rr.Body.String()
|
|
|
|
// Verify registry URL is rendered
|
|
if !strings.Contains(body, "myregistry.example.com") {
|
|
t.Error("Expected body to contain registry URL 'myregistry.example.com'")
|
|
}
|
|
|
|
// Verify page title is present
|
|
if !strings.Contains(body, "Decentralized Container Registry") {
|
|
t.Error("Expected body to contain page title")
|
|
}
|
|
|
|
// Verify key sections are rendered
|
|
if !strings.Contains(body, "How It Works") {
|
|
t.Error("Expected body to contain 'How It Works' section")
|
|
}
|
|
|
|
if !strings.Contains(body, "Why Decentralized") {
|
|
t.Error("Expected body to contain 'Why Decentralized' section")
|
|
}
|
|
|
|
// Verify CTA links to /install
|
|
if !strings.Contains(body, `href="/install"`) {
|
|
t.Error("Expected body to contain link to /install")
|
|
}
|
|
}
|
|
|
|
func TestLearnMoreHandler_SEOMetadata(t *testing.T) {
|
|
templates, err := appview.Templates(nil)
|
|
if err != nil {
|
|
t.Fatalf("Failed to load templates: %v", err)
|
|
}
|
|
|
|
handler := &handlers.LearnMoreHandler{
|
|
BaseUIHandler: handlers.BaseUIHandler{
|
|
Templates: templates,
|
|
RegistryURL: "atcr.io",
|
|
SiteURL: "atcr.io",
|
|
},
|
|
}
|
|
|
|
req := httptest.NewRequest("GET", "/learn-more", nil)
|
|
rr := httptest.NewRecorder()
|
|
handler.ServeHTTP(rr, req)
|
|
|
|
if rr.Code != http.StatusOK {
|
|
t.Errorf("Expected status %d, got %d", http.StatusOK, rr.Code)
|
|
}
|
|
|
|
body := rr.Body.String()
|
|
|
|
// Verify canonical URL
|
|
if !strings.Contains(body, `rel="canonical"`) {
|
|
t.Error("Expected body to contain canonical link")
|
|
}
|
|
|
|
// Verify meta description
|
|
if !strings.Contains(body, `name="description"`) {
|
|
t.Error("Expected body to contain meta description")
|
|
}
|
|
|
|
// Verify Open Graph tags
|
|
if !strings.Contains(body, `property="og:title"`) {
|
|
t.Error("Expected body to contain og:title")
|
|
}
|
|
|
|
if !strings.Contains(body, `property="og:description"`) {
|
|
t.Error("Expected body to contain og:description")
|
|
}
|
|
}
|