routertest

package
v4.0.0 Latest Latest
Warning

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

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

Documentation

Overview

Package routertest provides a first public router-test harness for js/wasm tests.

It builds on testkit/render and the public router package so tests can set an initial path, navigate, inspect params and query state, and assert rendered route output without relying on repo-local router test helpers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildAsyncGuardDenied

func BuildAsyncGuardDenied(parseReason string) appRouter.AsyncGuardFunc

BuildAsyncGuardDenied returns an async guard that blocks with denied state.

func BuildGuardBlocked

func BuildGuardBlocked(parseReason string) appRouter.GuardFunc

BuildGuardBlocked returns a guard that always blocks navigation with reason.

func BuildGuardRedirect

func BuildGuardRedirect(parsePath string) appRouter.GuardFunc

BuildGuardRedirect returns a guard that always redirects navigation to path.

Types

type Fixture

type Fixture struct {
	// contains filtered or unexported fields
}

Fixture wraps one router plus a rendered route fixture.

func NewHash

func NewHash(parseTb testing.TB, parseOptions ...appRouter.RouterOptions) *Fixture

NewHash creates a hash-router test fixture.

func NewHistory

func NewHistory(parseTb testing.TB, parseOptions ...appRouter.RouterOptions) *Fixture

NewHistory creates a history-router test fixture.

func (*Fixture) AllByRole

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

AllByRole delegates role collection queries to the rendered route fixture.

func (*Fixture) ApplyByDescription

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

ApplyByDescription delegates description assertions to the rendered route fixture.

func (*Fixture) ApplyByLabel

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

ApplyByLabel delegates label assertions to the rendered route fixture.

func (*Fixture) ApplyByLiveRegion

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

ApplyByLiveRegion delegates live-region assertions to the rendered route fixture.

func (*Fixture) ApplyByRole

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

ApplyByRole delegates role assertions to the rendered route fixture.

func (*Fixture) ByDescription

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

ByDescription delegates accessibility description queries to the rendered route fixture.

func (*Fixture) ByID

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

ByID delegates to the rendered route fixture.

func (*Fixture) ByLabel

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

ByLabel delegates accessibility label queries to the rendered route fixture.

func (*Fixture) ByLiveRegion

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

ByLiveRegion delegates live-region queries to the rendered route fixture.

func (*Fixture) ByRole

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

ByRole delegates role-first route queries to the rendered route fixture.

func (*Fixture) ByText

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

ByText delegates to the rendered route fixture.

func (*Fixture) ChangeByID

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

ChangeByID delegates change dispatch to the rendered route fixture.

func (*Fixture) Cleanup

func (parseF *Fixture) Cleanup()

Cleanup releases the delegated fixture and restores browser globals.

func (*Fixture) ClickByID

func (parseF *Fixture) ClickByID(parseId string)

ClickByID delegates click dispatch to the rendered route fixture.

func (*Fixture) DispatchByID

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

DispatchByID delegates synthetic event dispatch to the rendered route fixture.

func (*Fixture) InputByID

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

InputByID delegates input dispatch to the rendered route fixture.

func (*Fixture) Inspect

func (parseF *Fixture) Inspect() appRouter.RouteInspection

Inspect returns the current public route inspection snapshot.

func (*Fixture) Navigate

func (parseF *Fixture) Navigate(parsePath string)

Navigate performs router navigation and rerenders the current route.

func (*Fixture) Params

func (parseF *Fixture) Params() map[string]string

Params returns the current route params.

func (*Fixture) Path

func (parseF *Fixture) Path() string

Path returns the current route path.

func (*Fixture) Query

func (parseF *Fixture) Query() url.Values

Query returns the current query values.

func (*Fixture) Register

func (parseF *Fixture) Register(parsePath string, parseComponent interface{}, parseOptions ...appRouter.Options)

Register adds a route to the underlying router.

func (*Fixture) Render

func (parseF *Fixture) Render()

Render renders the current route into the delegated render fixture.

func (*Fixture) Replace

func (parseF *Fixture) Replace(parsePath string)

Replace performs replace-style router navigation and rerenders the current route.

func (*Fixture) Router

func (parseF *Fixture) Router() *appRouter.Router

Router exposes the underlying router for advanced assertions.

func (*Fixture) SetPath

func (parseF *Fixture) SetPath(parsePath string)

SetPath updates the current browser location without treating it as a navigation action.

func (*Fixture) SubmitByID

func (parseF *Fixture) SubmitByID(parseId string)

SubmitByID delegates submit dispatch to the rendered route fixture.

func (*Fixture) Text

func (parseF *Fixture) Text() string

Text returns the full rendered route text.

type LoaderAttempt

type LoaderAttempt struct {
	Index     int
	Path      string
	Query     url.Values
	Params    map[string]string
	Cancelled bool
}

type LoaderController

type LoaderController struct {
	// contains filtered or unexported fields
}

LoaderController provides deterministic control over route-loader attempts in tests.

func NewLoaderController

func NewLoaderController() *LoaderController

NewLoaderController creates one route-loader controller.

func (*LoaderController) AttemptCount

func (parseC *LoaderController) AttemptCount() int

AttemptCount reports how many loader attempts have started.

func (*LoaderController) Attempts

func (parseC *LoaderController) Attempts() []LoaderAttempt

Attempts returns a snapshot of all started loader attempts.

func (*LoaderController) Cancel

func (parseC *LoaderController) Cancel()

Cancel completes the current loader attempt with context cancellation.

func (*LoaderController) Loader

func (parseC *LoaderController) Loader() appRouter.LoaderFunc

Loader returns a router.LoaderFunc that blocks until the controller resolves it.

func (*LoaderController) Pending

func (parseC *LoaderController) Pending() bool

Pending reports whether one loader attempt is currently stalled.

func (*LoaderController) Reject

func (parseC *LoaderController) Reject(parseErr error)

Reject completes the current loader attempt with an error.

func (*LoaderController) RejectCacheConflict

func (parseC *LoaderController) RejectCacheConflict(parseEntity string)

RejectCacheConflict completes the current loader attempt with a typed cache conflict failure.

func (*LoaderController) RejectLoaderFailure

func (parseC *LoaderController) RejectLoaderFailure(parsePath string, parseReason string)

RejectLoaderFailure completes the current loader attempt with a typed loader failure.

func (*LoaderController) RejectOfflineReplay

func (parseC *LoaderController) RejectOfflineReplay(parseEntity string, parseReason string)

RejectOfflineReplay completes the current loader attempt with a typed offline replay failure.

func (*LoaderController) RejectRouteGuardFailure

func (parseC *LoaderController) RejectRouteGuardFailure(parsePath string, parseReason string)

RejectRouteGuardFailure completes the current loader attempt with a typed guard failure.

func (*LoaderController) Resolve

func (parseC *LoaderController) Resolve(parseValue appRouter.Attrs)

Resolve completes the current loader attempt with a successful value.

func (*LoaderController) Started

func (parseC *LoaderController) Started() <-chan int

Started returns a channel that receives each started loader attempt index.

Jump to

Keyboard shortcuts

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