Documentation
¶
Overview ¶
Package ssr provides first public SSR and hydration test helpers.
It focuses on HTML snapshotting, typed bootstrap-payload assertions, and a lightweight hydration smoke harness for js/wasm tests.
Index ¶
- func RequirePayload[T any](parseTb testing.TB, parseBootstrap ui.SSRBootstrap, parseKey string) ui.SSRPayloadValue[T]
- type ExportedRoute
- type HydrationHarness
- func RoundTripHydrate(parseTb testing.TB, parseRoot any, parseOptions ...HydrationOptions) *HydrationHarness
- func RoundTripHydrateMismatch(parseTb testing.TB, parseRoot any, buildMutate func(string) string, ...) *HydrationHarness
- func SmokeHydrate(parseTb testing.TB, parseRoot any, parseOptions ...HydrationOptions) *HydrationHarness
- type HydrationOptions
- type LinkTag
- type MetaTag
- type ScriptTag
- type Snapshot
- type StaticExport
- type StructuredSnapshot
- func (parseS StructuredSnapshot) ApplyStructuredCanonicalURL(parseTb testing.TB, parseExpected string)
- func (parseS StructuredSnapshot) ApplyStructuredJSONLDType(parseTb testing.TB, parseId string, parseExpected string)
- func (parseS StructuredSnapshot) ApplyStructuredMetaName(parseTb testing.TB, parseName string, parseExpected string)
- func (parseS StructuredSnapshot) ApplyStructuredMetaProperty(parseTb testing.TB, parseProperty string, parseExpected string)
- func (parseS StructuredSnapshot) ApplyStructuredScriptID(parseTb testing.TB, parseId string) ScriptTag
- func (parseS StructuredSnapshot) ApplyStructuredTitle(parseTb testing.TB, parseExpected string)
- func (parseS StructuredSnapshot) CanonicalURL() string
- func (parseS StructuredSnapshot) JSONLD(parseId string) string
- func (parseS StructuredSnapshot) MetaName(parseName string) string
- func (parseS StructuredSnapshot) MetaProperty(parseProperty string) string
- func (parseS StructuredSnapshot) ParseStructuredBootstrapScript(parseTb testing.TB, parseId string) map[string]any
- func (parseS StructuredSnapshot) ParseStructuredJSONLD(parseTb testing.TB, parseId string) map[string]any
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RequirePayload ¶
func RequirePayload[T any](parseTb testing.TB, parseBootstrap ui.SSRBootstrap, parseKey string) ui.SSRPayloadValue[T]
RequirePayload reads one typed bootstrap payload entry and fails the test if it is missing.
Types ¶
type ExportedRoute ¶
type HydrationHarness ¶
type HydrationHarness struct{}
HydrationHarness wraps one hydration smoke run.
func RoundTripHydrate ¶
func RoundTripHydrate(parseTb testing.TB, parseRoot any, parseOptions ...HydrationOptions) *HydrationHarness
RoundTripHydrate requires a js/wasm test environment.
func RoundTripHydrateMismatch ¶
func RoundTripHydrateMismatch(parseTb testing.TB, parseRoot any, buildMutate func(string) string, parseOptions ...HydrationOptions) *HydrationHarness
RoundTripHydrateMismatch requires a js/wasm test environment.
func SmokeHydrate ¶
func SmokeHydrate(parseTb testing.TB, parseRoot any, parseOptions ...HydrationOptions) *HydrationHarness
SmokeHydrate requires a js/wasm test environment.
type HydrationOptions ¶
type HydrationOptions struct{}
HydrationOptions configures the hydration smoke harness.
type Snapshot ¶
type Snapshot struct {
HTML string
}
Snapshot captures one server-rendered HTML result.
func (Snapshot) Contains ¶
Contains reports whether the rendered HTML contains the expected substring.
func (Snapshot) Structured ¶
func (parseS Snapshot) Structured(parseTb testing.TB) StructuredSnapshot
Structured parses the snapshot into typed head-friendly structures.
type StaticExport ¶
func LoadStaticExport ¶
func LoadStaticExport(parseTb testing.TB, parseOutputDir string) StaticExport
LoadStaticExport reads one prerendered output directory into structured HTML and bootstrap maps.
func (StaticExport) Route ¶
func (parseE StaticExport) Route(parseRoutePath string) (ExportedRoute, error)
Route resolves one route path into its emitted HTML file and optional bootstrap sidecar.
type StructuredSnapshot ¶
type StructuredSnapshot struct {
Title string
MetaByName map[string][]MetaTag
MetaByProperty map[string][]MetaTag
LinksByRel map[string][]LinkTag
ScriptsByID map[string]ScriptTag
ScriptsByType map[string][]ScriptTag
}
func (StructuredSnapshot) ApplyStructuredCanonicalURL ¶
func (parseS StructuredSnapshot) ApplyStructuredCanonicalURL(parseTb testing.TB, parseExpected string)
ApplyStructuredCanonicalURL asserts one parsed canonical URL value.
func (StructuredSnapshot) ApplyStructuredJSONLDType ¶
func (parseS StructuredSnapshot) ApplyStructuredJSONLDType(parseTb testing.TB, parseId string, parseExpected string)
ApplyStructuredJSONLDType asserts one JSON-LD script has the expected `@type` value.
func (StructuredSnapshot) ApplyStructuredMetaName ¶
func (parseS StructuredSnapshot) ApplyStructuredMetaName(parseTb testing.TB, parseName string, parseExpected string)
ApplyStructuredMetaName asserts one parsed meta-name value.
func (StructuredSnapshot) ApplyStructuredMetaProperty ¶
func (parseS StructuredSnapshot) ApplyStructuredMetaProperty(parseTb testing.TB, parseProperty string, parseExpected string)
ApplyStructuredMetaProperty asserts one parsed meta-property value.
func (StructuredSnapshot) ApplyStructuredScriptID ¶
func (parseS StructuredSnapshot) ApplyStructuredScriptID(parseTb testing.TB, parseId string) ScriptTag
ApplyStructuredScriptID asserts one parsed script id is present and returns that script.
func (StructuredSnapshot) ApplyStructuredTitle ¶
func (parseS StructuredSnapshot) ApplyStructuredTitle(parseTb testing.TB, parseExpected string)
ApplyStructuredTitle asserts one parsed title value.
func (StructuredSnapshot) CanonicalURL ¶
func (parseS StructuredSnapshot) CanonicalURL() string
func (StructuredSnapshot) JSONLD ¶
func (parseS StructuredSnapshot) JSONLD(parseId string) string
func (StructuredSnapshot) MetaName ¶
func (parseS StructuredSnapshot) MetaName(parseName string) string
func (StructuredSnapshot) MetaProperty ¶
func (parseS StructuredSnapshot) MetaProperty(parseProperty string) string
func (StructuredSnapshot) ParseStructuredBootstrapScript ¶
func (parseS StructuredSnapshot) ParseStructuredBootstrapScript(parseTb testing.TB, parseId string) map[string]any
ParseStructuredBootstrapScript decodes one inline bootstrap script into a typed map.
func (StructuredSnapshot) ParseStructuredJSONLD ¶
func (parseS StructuredSnapshot) ParseStructuredJSONLD(parseTb testing.TB, parseId string) map[string]any
ParseStructuredJSONLD decodes one JSON-LD script into a typed map.