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 any)
- func (parseF *Fixture) Rerender(parseRoot any)
- 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) 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
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{}
Fixture is the public render harness.
func New ¶
New requires a js/wasm test environment because interactive component hooks only use the real runtime on browser-targeted builds.
func (*Fixture) ApplyByDescription ¶
func (*Fixture) ApplyByLabel ¶
func (*Fixture) ApplyByLiveRegion ¶
func (*Fixture) ApplyByRole ¶
func (*Fixture) ApplyDiagnosticCode ¶
func (parseF *Fixture) ApplyDiagnosticCode(parseCode string) DiagnosticSignal
func (*Fixture) ApplyDiagnosticMessage ¶
func (parseF *Fixture) ApplyDiagnosticMessage(parseFragment string) DiagnosticSignal
func (*Fixture) ApplyLogCode ¶
func (*Fixture) ApplyLogMessage ¶
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
func (*Fixture) BuildOverlayBodyOverflow ¶
func (*Fixture) BuildOverlayEscapeSurfaceID ¶
func (*Fixture) BuildOverlayFocusSurfaceID ¶
func (*Fixture) BuildOverlayOutsideSurfaceID ¶
func (*Fixture) BuildOverlayPortalTargetID ¶
func (*Fixture) BuildOverlayScrollLockActive ¶
func (*Fixture) BuildOverlaySurfaces ¶
func (parseF *Fixture) BuildOverlaySurfaces() []OverlaySurface
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 ¶
func (*Fixture) ByLiveRegion ¶
func (*Fixture) ChangeByID ¶
func (*Fixture) DispatchByID ¶
func (*Fixture) FlushTimers ¶
func (parseF *Fixture) FlushTimers()
func (*Fixture) HandleOverlayOutsideClick ¶
func (*Fixture) SubmitByID ¶
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 scheduled work until Flush is called, instead of the default synchronous flush-on-render behavior. (Internally this clears the config's synchronous flag.)
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{}
QueryNode wraps one matched rendered node.
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.