render

package
v4.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 29, 2026 License: MIT Imports: 5 Imported by: 0

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

View Source
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

func BuildCacheConflictError(parseEntity string) error

BuildCacheConflictError constructs one cache-conflict failure error.

func BuildFailureError

func BuildFailureError(parseCode string, parseMessage string) error

BuildFailureError constructs one typed failure-injection error.

func BuildHydrationMismatchError

func BuildHydrationMismatchError(parsePath string, parseReason string) error

BuildHydrationMismatchError constructs one hydration mismatch failure error.

func BuildLoaderFailureError

func BuildLoaderFailureError(parsePath string, parseReason string) error

BuildLoaderFailureError constructs one loader failure error.

func BuildOfflineReplayError

func BuildOfflineReplayError(parseEntity string, parseReason string) error

BuildOfflineReplayError constructs one offline-replay failure error.

func BuildRouteGuardFailureError

func BuildRouteGuardFailureError(parsePath string, parseReason string) error

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 Event

type Event struct {
	Value   string
	Checked bool
	Key     string
	KeyCode int
}

Event describes one synthetic event payload for fixture dispatch helpers.

type FailureError

type FailureError struct {
	Code    string
	Message string
}

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

func New(parseTb testing.TB, parseOptions ...Option) *Fixture

New requires a js/wasm test environment because interactive component hooks only use the real runtime on browser-targeted builds.

func (*Fixture) AllByRole

func (parseF *Fixture) AllByRole(parseRole string) []*QueryNode

func (*Fixture) AllByTag

func (parseF *Fixture) AllByTag(parseTag string) []*QueryNode

func (*Fixture) ApplyByDescription

func (parseF *Fixture) ApplyByDescription(parseDescription string) *QueryNode

func (*Fixture) ApplyByLabel

func (parseF *Fixture) ApplyByLabel(parseLabel string) *QueryNode

func (*Fixture) ApplyByLiveRegion

func (parseF *Fixture) ApplyByLiveRegion(parsePoliteness string, parseText string) *QueryNode

func (*Fixture) ApplyByRole

func (parseF *Fixture) ApplyByRole(parseRole string, parseName string) *QueryNode

func (*Fixture) ApplyDiagnosticCode

func (parseF *Fixture) ApplyDiagnosticCode(parseCode string) DiagnosticSignal

func (*Fixture) ApplyDiagnosticMessage

func (parseF *Fixture) ApplyDiagnosticMessage(parseFragment string) DiagnosticSignal

func (*Fixture) ApplyLogCode

func (parseF *Fixture) ApplyLogCode(parseCode string) LogSignal

func (*Fixture) ApplyLogMessage

func (parseF *Fixture) ApplyLogMessage(parseFragment string) LogSignal

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

func (parseF *Fixture) ApplyWarningCountMax(parseMax int)

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) BuildLogs

func (parseF *Fixture) BuildLogs() []LogSignal

func (*Fixture) BuildOverlayBodyOverflow

func (parseF *Fixture) BuildOverlayBodyOverflow() string

func (*Fixture) BuildOverlayEscapeSurfaceID

func (parseF *Fixture) BuildOverlayEscapeSurfaceID() string

func (*Fixture) BuildOverlayFocusSurfaceID

func (parseF *Fixture) BuildOverlayFocusSurfaceID() string

func (*Fixture) BuildOverlayOutsideSurfaceID

func (parseF *Fixture) BuildOverlayOutsideSurfaceID() string

func (*Fixture) BuildOverlayPortalTargetID

func (parseF *Fixture) BuildOverlayPortalTargetID(parseSurfaceID string) string

func (*Fixture) BuildOverlayScrollLockActive

func (parseF *Fixture) BuildOverlayScrollLockActive() bool

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

func (parseF *Fixture) BuildWarningLogs() []LogSignal

BuildWarningLogs returns logs whose level is warn.

func (*Fixture) ByDescription

func (parseF *Fixture) ByDescription(parseDescription string) *QueryNode

func (*Fixture) ByID

func (parseF *Fixture) ByID(parseId string) *QueryNode

func (*Fixture) ByLabel

func (parseF *Fixture) ByLabel(parseLabel string) *QueryNode

func (*Fixture) ByLiveRegion

func (parseF *Fixture) ByLiveRegion(parsePoliteness string, parseText string) *QueryNode

func (*Fixture) ByRole

func (parseF *Fixture) ByRole(parseRole string, parseName string) *QueryNode

func (*Fixture) ByText

func (parseF *Fixture) ByText(parseText string) *QueryNode

func (*Fixture) ChangeByID

func (parseF *Fixture) ChangeByID(parseId string, parseValue string)

func (*Fixture) Cleanup

func (parseF *Fixture) Cleanup()

func (*Fixture) ClickByID

func (parseF *Fixture) ClickByID(parseId string)

func (*Fixture) Container

func (parseF *Fixture) Container() *QueryNode

func (*Fixture) DispatchByID

func (parseF *Fixture) DispatchByID(parseId string, parseProperty string, parseEvent Event)

func (*Fixture) Flush

func (parseF *Fixture) Flush()

func (*Fixture) FlushTimers

func (parseF *Fixture) FlushTimers()

func (*Fixture) HandleOverlayOutsideClick

func (parseF *Fixture) HandleOverlayOutsideClick(parseSurfaceID string) bool

func (*Fixture) InputByID

func (parseF *Fixture) InputByID(parseId string, parseValue string)

func (*Fixture) Render

func (parseF *Fixture) Render(parseRoot any)

func (*Fixture) Rerender

func (parseF *Fixture) Rerender(parseRoot any)

func (*Fixture) Stabilize

func (parseF *Fixture) Stabilize()

func (*Fixture) SubmitByID

func (parseF *Fixture) SubmitByID(parseId string)

func (*Fixture) Target

func (parseF *Fixture) Target() any

func (*Fixture) Text

func (parseF *Fixture) Text() string

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.

func (*QueryNode) Attr

func (parseN *QueryNode) Attr(parseName string) string

func (*QueryNode) Change

func (parseN *QueryNode) Change(parseValue string)

func (*QueryNode) Children

func (parseN *QueryNode) Children() []*QueryNode

func (*QueryNode) Click

func (parseN *QueryNode) Click()

func (*QueryNode) Dispatch

func (parseN *QueryNode) Dispatch(parseProperty string, parseEvent Event)

func (*QueryNode) Exists

func (parseN *QueryNode) Exists() bool

func (*QueryNode) Input

func (parseN *QueryNode) Input(parseValue string)

func (*QueryNode) Name

func (parseN *QueryNode) Name() string

func (*QueryNode) Property

func (parseN *QueryNode) Property(parseName string) any

func (*QueryNode) Submit

func (parseN *QueryNode) Submit()

func (*QueryNode) Tag

func (parseN *QueryNode) Tag() string

func (*QueryNode) Text

func (parseN *QueryNode) Text() string

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 ResourceAttempt struct {
	Index     int
	Cancelled bool
}

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL