Documentation
¶
Overview ¶
Package render provides a first public component-fixture harness for js/wasm tests built on the framework's public UI surface.
The initial slice focuses on mounting a component tree into a controlled mock DOM fixture, rerendering it, and querying rendered output without reaching into repo-local runtime test helpers. On js/wasm builds the fixture runtime is process-global, so fixture-owning tests must run sequentially.
Index ¶
- Constants
- func BuildCacheConflictError(parseEntity string) error
- func BuildFailureError(parseCode string, parseMessage string) error
- func BuildHydrationMismatchError(parsePath string, parseReason string) error
- func BuildLoaderFailureError(parsePath string, parseReason string) error
- func BuildOfflineReplayError(parseEntity string, parseReason string) error
- func BuildRouteGuardFailureError(parsePath string, parseReason string) error
- func ParallelSafetyContract() string
- type DiagnosticSignal
- type Event
- type FailureError
- type Fixture
- func (parseF *Fixture) AllByRole(parseRole string) []*QueryNode
- func (parseF *Fixture) AllByTag(parseTag string) []*QueryNode
- func (parseF *Fixture) ApplyByDescription(parseDescription string) *QueryNode
- func (parseF *Fixture) ApplyByLabel(parseLabel string) *QueryNode
- func (parseF *Fixture) ApplyByLiveRegion(parsePoliteness string, parseText string) *QueryNode
- func (parseF *Fixture) ApplyByRole(parseRole string, parseName string) *QueryNode
- func (parseF *Fixture) ApplyDiagnosticCode(parseCode string) DiagnosticSignal
- func (parseF *Fixture) ApplyDiagnosticMessage(parseFragment string) DiagnosticSignal
- func (parseF *Fixture) ApplyLogCode(parseCode string) LogSignal
- func (parseF *Fixture) ApplyLogMessage(parseFragment string) LogSignal
- func (parseF *Fixture) ApplyRenderCountMax(parseComponent string, parseMax int) RenderCountSignal
- func (parseF *Fixture) ApplyRenderRerenderMax(parseComponent string, parseMax int) RenderCountSignal
- func (parseF *Fixture) ApplyWarningCountMax(parseMax int)
- func (parseF *Fixture) ApplyWarningNone()
- func (parseF *Fixture) BuildDiagnostics() []DiagnosticSignal
- func (parseF *Fixture) BuildLogs() []LogSignal
- func (parseF *Fixture) BuildOverlayBodyOverflow() string
- func (parseF *Fixture) BuildOverlayEscapeSurfaceID() string
- func (parseF *Fixture) BuildOverlayFocusSurfaceID() string
- func (parseF *Fixture) BuildOverlayOutsideSurfaceID() string
- func (parseF *Fixture) BuildOverlayPortalTargetID(parseSurfaceID string) string
- func (parseF *Fixture) BuildOverlayScrollLockActive() bool
- func (parseF *Fixture) BuildOverlaySurfaces() []OverlaySurface
- func (parseF *Fixture) BuildRenderCounts() []RenderCountSignal
- func (parseF *Fixture) BuildWarningDiagnostics() []DiagnosticSignal
- func (parseF *Fixture) BuildWarningLogs() []LogSignal
- func (parseF *Fixture) ByDescription(parseDescription string) *QueryNode
- func (parseF *Fixture) ByID(parseId string) *QueryNode
- func (parseF *Fixture) ByLabel(parseLabel string) *QueryNode
- func (parseF *Fixture) ByLiveRegion(parsePoliteness string, parseText string) *QueryNode
- func (parseF *Fixture) ByRole(parseRole string, parseName string) *QueryNode
- func (parseF *Fixture) ByText(parseText string) *QueryNode
- func (parseF *Fixture) ChangeByID(parseId string, parseValue string)
- func (parseF *Fixture) Cleanup()
- func (parseF *Fixture) ClickByID(parseId string)
- func (parseF *Fixture) Container() *QueryNode
- func (parseF *Fixture) DispatchByID(parseId string, parseProperty string, parseEvent Event)
- func (parseF *Fixture) Flush()
- func (parseF *Fixture) FlushTimers()
- func (parseF *Fixture) HandleOverlayOutsideClick(parseSurfaceID string) bool
- func (parseF *Fixture) InputByID(parseId string, parseValue string)
- func (parseF *Fixture) Render(parseRoot ui.Node)
- func (parseF *Fixture) Rerender(parseRoot ui.Node)
- func (parseF *Fixture) SeedHTML(parseMarkup string) SeededMarkup
- func (parseF *Fixture) Stabilize()
- func (parseF *Fixture) SubmitByID(parseId string)
- func (parseF *Fixture) Target() any
- func (parseF *Fixture) Text() string
- type LogSignal
- type Option
- type OverlaySurface
- type QueryNode
- func (parseN *QueryNode) Attr(parseName string) string
- func (parseN *QueryNode) Change(parseValue string)
- func (parseN *QueryNode) Children() []*QueryNode
- func (parseN *QueryNode) Click()
- func (parseN *QueryNode) Dispatch(parseProperty string, parseEvent Event)
- func (parseN *QueryNode) Exists() bool
- func (parseN *QueryNode) Input(parseValue string)
- func (parseN *QueryNode) Name() string
- func (parseN *QueryNode) NodeID() int
- func (parseN *QueryNode) Property(parseName string) any
- func (parseN *QueryNode) Submit()
- func (parseN *QueryNode) Tag() string
- func (parseN *QueryNode) Text() string
- type RenderCountSignal
- type ResourceAttempt
- type ResourceController
- func (parseC *ResourceController[T]) AttemptCount() int
- func (parseC *ResourceController[T]) Attempts() []ResourceAttempt
- func (parseC *ResourceController[T]) Await(parseCtx context.Context) (T, error)
- func (parseC *ResourceController[T]) Cancel()
- func (parseC *ResourceController[T]) Loader() func(context.Context) (T, error)
- func (parseC *ResourceController[T]) Pending() bool
- func (parseC *ResourceController[T]) Reject(parseErr error)
- func (parseC *ResourceController[T]) RejectCacheConflict(parseEntity string)
- func (parseC *ResourceController[T]) RejectOfflineReplay(parseEntity string, parseReason string)
- func (parseC *ResourceController[T]) Resolve(parseValue T)
- func (parseC *ResourceController[T]) Started() <-chan int
- type SeededMarkup
Constants ¶
const ( FailureCodeHydrationMismatch = "hydration_mismatch" FailureCodeLoaderFailure = "loader_failure" FailureCodeRouteGuardFailure = "route_guard_failure" FailureCodeCacheConflict = "cache_conflict" FailureCodeOfflineReplay = "offline_replay" )
Variables ¶
This section is empty.
Functions ¶
func BuildCacheConflictError ¶
BuildCacheConflictError constructs one cache-conflict failure error.
func BuildFailureError ¶
BuildFailureError constructs one typed failure-injection error.
func BuildHydrationMismatchError ¶
BuildHydrationMismatchError constructs one hydration mismatch failure error.
func BuildLoaderFailureError ¶
BuildLoaderFailureError constructs one loader failure error.
func BuildOfflineReplayError ¶
BuildOfflineReplayError constructs one offline-replay failure error.
func BuildRouteGuardFailureError ¶
BuildRouteGuardFailureError constructs one route-guard failure error.
func ParallelSafetyContract ¶
func ParallelSafetyContract() string
ParallelSafetyContract returns the explicit js/wasm fixture parallel-safety contract.
Types ¶
type DiagnosticSignal ¶
type DiagnosticSignal struct {
Source string
Severity string
Classification string
Code string
Message string
Count int
Path string
Recoverable bool
TopFrame string
Consequence string
ComponentStack []string
Fields map[string]string
}
DiagnosticSignal describes one runtime diagnostic entry exposed by the fixture.
type FailureError ¶
FailureError represents one deterministic failure-injection error payload.
func (FailureError) Error ¶
func (parseE FailureError) Error() string
Error returns the printable failure-injection error message.
type Fixture ¶
type Fixture struct {
// contains filtered or unexported fields
}
Fixture owns one mock DOM container, scheduler, and configured global runtime.
The current harness serializes fixture ownership because the runtime hook surface is global on js/wasm builds.
func (*Fixture) ApplyByDescription ¶
ApplyByDescription asserts one description query match and returns the node.
func (*Fixture) ApplyByLabel ¶
ApplyByLabel asserts one label query match and returns the node.
func (*Fixture) ApplyByLiveRegion ¶
ApplyByLiveRegion asserts one live-region query match and returns the node.
func (*Fixture) ApplyByRole ¶
ApplyByRole asserts one role query match and returns the node.
func (*Fixture) ApplyDiagnosticCode ¶
func (parseF *Fixture) ApplyDiagnosticCode(parseCode string) DiagnosticSignal
ApplyDiagnosticCode asserts that one diagnostic with the requested code exists.
func (*Fixture) ApplyDiagnosticMessage ¶
func (parseF *Fixture) ApplyDiagnosticMessage(parseFragment string) DiagnosticSignal
ApplyDiagnosticMessage asserts that one diagnostic message contains the provided fragment.
func (*Fixture) ApplyLogCode ¶
ApplyLogCode asserts that one buffered log with the requested code exists.
func (*Fixture) ApplyLogMessage ¶
ApplyLogMessage asserts that one buffered log message contains the provided fragment.
func (*Fixture) ApplyRenderCountMax ¶
func (parseF *Fixture) ApplyRenderCountMax(parseComponent string, parseMax int) RenderCountSignal
ApplyRenderCountMax asserts one component's render count does not exceed max.
func (*Fixture) ApplyRenderRerenderMax ¶
func (parseF *Fixture) ApplyRenderRerenderMax(parseComponent string, parseMax int) RenderCountSignal
ApplyRenderRerenderMax asserts one component's rerender count does not exceed max.
func (*Fixture) ApplyWarningCountMax ¶
ApplyWarningCountMax asserts warnings across diagnostics and logs do not exceed max.
func (*Fixture) ApplyWarningNone ¶
func (parseF *Fixture) ApplyWarningNone()
ApplyWarningNone asserts no warning diagnostics or warn-level logs were emitted.
func (*Fixture) BuildDiagnostics ¶
func (parseF *Fixture) BuildDiagnostics() []DiagnosticSignal
BuildDiagnostics returns structured runtime diagnostics captured for this fixture run.
func (*Fixture) BuildOverlayBodyOverflow ¶
BuildOverlayBodyOverflow reports the current browser document body overflow style.
func (*Fixture) BuildOverlayEscapeSurfaceID ¶
BuildOverlayEscapeSurfaceID returns the topmost escape-handling overlay surface id.
func (*Fixture) BuildOverlayFocusSurfaceID ¶
BuildOverlayFocusSurfaceID returns the topmost trap-focus owner overlay surface id.
func (*Fixture) BuildOverlayOutsideSurfaceID ¶
BuildOverlayOutsideSurfaceID returns the topmost outside-click-handling overlay surface id.
func (*Fixture) BuildOverlayPortalTargetID ¶
BuildOverlayPortalTargetID resolves one overlay surface to the nearest ancestor id.
func (*Fixture) BuildOverlayScrollLockActive ¶
BuildOverlayScrollLockActive reports whether overlay-driven scroll lock is active.
func (*Fixture) BuildOverlaySurfaces ¶
func (parseF *Fixture) BuildOverlaySurfaces() []OverlaySurface
BuildOverlaySurfaces returns all rendered overlay surfaces sorted by depth.
func (*Fixture) BuildRenderCounts ¶
func (parseF *Fixture) BuildRenderCounts() []RenderCountSignal
BuildRenderCounts returns structured component render-count signals from profiling snapshots.
func (*Fixture) BuildWarningDiagnostics ¶
func (parseF *Fixture) BuildWarningDiagnostics() []DiagnosticSignal
BuildWarningDiagnostics returns diagnostics whose severity is warning.
func (*Fixture) BuildWarningLogs ¶
BuildWarningLogs returns logs whose level is warn.
func (*Fixture) ByDescription ¶
ByDescription returns the first interactive node whose accessible description matches.
func (*Fixture) ByLabel ¶
ByLabel returns the first interactive node whose accessible label matches.
func (*Fixture) ByLiveRegion ¶
ByLiveRegion returns the first live-region node matching politeness and optional text.
func (*Fixture) ByRole ¶
ByRole returns the first node whose computed role matches, optionally filtered by accessible name.
func (*Fixture) ByText ¶
ByText returns the first node whose full text content matches the provided text.
func (*Fixture) ChangeByID ¶
ChangeByID updates the matched node value, invokes `onchange`, and settles the fixture.
func (*Fixture) Cleanup ¶
func (parseF *Fixture) Cleanup()
Cleanup releases fixture ownership and clears buffered diagnostics.
func (*Fixture) ClickByID ¶
ClickByID invokes the matched node's `onclick` handler and settles the fixture.
func (*Fixture) DispatchByID ¶
DispatchByID invokes one handler property on the matched node and settles the fixture.
func (*Fixture) Flush ¶
func (parseF *Fixture) Flush()
Flush drains queued scheduler work until the fixture settles.
func (*Fixture) FlushTimers ¶
func (parseF *Fixture) FlushTimers()
FlushTimers drains queued timeout work and any follow-up render work.
func (*Fixture) HandleOverlayOutsideClick ¶
HandleOverlayOutsideClick dispatches one outside-click dismissal through the overlay backdrop.
func (*Fixture) InputByID ¶
InputByID updates the matched node value, invokes `oninput`, and settles the fixture.
func (*Fixture) SeedHTML ¶
func (parseF *Fixture) SeedHTML(parseMarkup string) SeededMarkup
SeedHTML replaces the fixture container children with parsed server markup.
func (*Fixture) Stabilize ¶
func (parseF *Fixture) Stabilize()
Stabilize drains pending scheduled work until the fixture settles.
func (*Fixture) SubmitByID ¶
SubmitByID invokes the matched node's `onsubmit` handler and settles the fixture.
type LogSignal ¶
type LogSignal struct {
Domain string
Level string
Classification string
Code string
Message string
Timestamp string
CorrelationID string
Recoverable bool
TopFrame string
Consequence string
Fields map[string]string
}
LogSignal describes one buffered runtime log entry exposed by the fixture.
type Option ¶
type Option func(*config)
Option configures the render fixture.
func WithQueuedScheduler ¶
func WithQueuedScheduler() Option
WithQueuedScheduler configures the harness to queue work until Flush is called.
type OverlaySurface ¶
type OverlaySurface struct {
SurfaceID string
Kind string
Depth int
HandlesEscape bool
HandlesOutsideClick bool
TrapFocusOwner bool
IsModal bool
PortalTargetID string
}
OverlaySurface describes one rendered overlay surface snapshot.
type QueryNode ¶
type QueryNode struct {
// contains filtered or unexported fields
}
QueryNode wraps one matched rendered node.
func (*QueryNode) Change ¶
Change updates the current node value, invokes `onchange`, and settles the fixture.
func (*QueryNode) Click ¶
func (parseN *QueryNode) Click()
Click invokes the current node's `onclick` handler and settles the fixture.
func (*QueryNode) Dispatch ¶
Dispatch invokes one handler property on the current node and settles the fixture.
func (*QueryNode) Input ¶
Input updates the current node value, invokes `oninput`, and settles the fixture.
func (*QueryNode) NodeID ¶
NodeID returns the stable mock-DOM node id for identity-sensitive assertions.
type RenderCountSignal ¶
type RenderCountSignal struct {
Name string
Path string
RenderCount int
RerenderCount int
LastTrigger string
TotalRenderDurationNs int64
AverageRenderDurationNs int64
}
RenderCountSignal describes one component render-count profile entry.
type ResourceAttempt ¶
type ResourceController ¶
type ResourceController[T any] struct { // contains filtered or unexported fields }
ResourceController provides deterministic control over one async resource loader in tests.
func NewResourceController ¶
func NewResourceController[T any]() *ResourceController[T]
NewResourceController creates one async controller for fetch/resource tests.
func (*ResourceController[T]) AttemptCount ¶
func (parseC *ResourceController[T]) AttemptCount() int
AttemptCount reports how many attempts have started.
func (*ResourceController[T]) Attempts ¶
func (parseC *ResourceController[T]) Attempts() []ResourceAttempt
Attempts returns a snapshot of all started attempts.
func (*ResourceController[T]) Await ¶
func (parseC *ResourceController[T]) Await(parseCtx context.Context) (T, error)
Await blocks until the current attempt is resolved, rejected, or cancelled.
func (*ResourceController[T]) Cancel ¶
func (parseC *ResourceController[T]) Cancel()
Cancel completes the current pending attempt with context cancellation.
func (*ResourceController[T]) Loader ¶
func (parseC *ResourceController[T]) Loader() func(context.Context) (T, error)
Loader returns a loader function compatible with fetch.UseResource or fetch.UseCachedResource.
func (*ResourceController[T]) Pending ¶
func (parseC *ResourceController[T]) Pending() bool
Pending reports whether one attempt is currently stalled.
func (*ResourceController[T]) Reject ¶
func (parseC *ResourceController[T]) Reject(parseErr error)
Reject completes the current pending attempt with an error.
func (*ResourceController[T]) RejectCacheConflict ¶
func (parseC *ResourceController[T]) RejectCacheConflict(parseEntity string)
RejectCacheConflict completes the current pending attempt with a cache-conflict failure.
func (*ResourceController[T]) RejectOfflineReplay ¶
func (parseC *ResourceController[T]) RejectOfflineReplay(parseEntity string, parseReason string)
RejectOfflineReplay completes the current pending attempt with an offline-replay failure.
func (*ResourceController[T]) Resolve ¶
func (parseC *ResourceController[T]) Resolve(parseValue T)
Resolve completes the current pending attempt successfully.
func (*ResourceController[T]) Started ¶
func (parseC *ResourceController[T]) Started() <-chan int
Started returns a channel that receives each started attempt index.