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 ¶
- func BuildAsyncGuardDenied(parseReason string) appRouter.AsyncGuardFunc
- func BuildGuardBlocked(parseReason string) appRouter.GuardFunc
- func BuildGuardRedirect(parsePath string) appRouter.GuardFunc
- type Fixture
- func (parseF *Fixture) AllByRole(parseRole string) []*render.QueryNode
- func (parseF *Fixture) ApplyByDescription(parseDescription string) *render.QueryNode
- func (parseF *Fixture) ApplyByLabel(parseLabel string) *render.QueryNode
- func (parseF *Fixture) ApplyByLiveRegion(parsePoliteness string, parseText string) *render.QueryNode
- func (parseF *Fixture) ApplyByRole(parseRole string, parseName string) *render.QueryNode
- func (parseF *Fixture) ByDescription(parseDescription string) *render.QueryNode
- func (parseF *Fixture) ByID(parseId string) *render.QueryNode
- func (parseF *Fixture) ByLabel(parseLabel string) *render.QueryNode
- func (parseF *Fixture) ByLiveRegion(parsePoliteness string, parseText string) *render.QueryNode
- func (parseF *Fixture) ByRole(parseRole string, parseName string) *render.QueryNode
- func (parseF *Fixture) ByText(parseText string) *render.QueryNode
- func (parseF *Fixture) ChangeByID(parseId string, parseValue string)
- func (parseF *Fixture) Cleanup()
- func (parseF *Fixture) ClickByID(parseId string)
- func (parseF *Fixture) DispatchByID(parseId string, parseProperty string, parseEvent render.Event)
- func (parseF *Fixture) InputByID(parseId string, parseValue string)
- func (parseF *Fixture) Inspect() appRouter.RouteInspection
- func (parseF *Fixture) Navigate(parsePath string)
- func (parseF *Fixture) Params() map[string]string
- func (parseF *Fixture) Path() string
- func (parseF *Fixture) Query() url.Values
- func (parseF *Fixture) Register(parsePath string, parseComponent interface{}, ...)
- func (parseF *Fixture) Render()
- func (parseF *Fixture) Replace(parsePath string)
- func (parseF *Fixture) Router() *appRouter.Router
- func (parseF *Fixture) SetPath(parsePath string)
- func (parseF *Fixture) SubmitByID(parseId string)
- func (parseF *Fixture) Text() string
- type LoaderAttempt
- type LoaderController
- func (parseC *LoaderController) AttemptCount() int
- func (parseC *LoaderController) Attempts() []LoaderAttempt
- func (parseC *LoaderController) Cancel()
- func (parseC *LoaderController) Loader() appRouter.LoaderFunc
- func (parseC *LoaderController) Pending() bool
- func (parseC *LoaderController) Reject(parseErr error)
- func (parseC *LoaderController) RejectCacheConflict(parseEntity string)
- func (parseC *LoaderController) RejectLoaderFailure(parsePath string, parseReason string)
- func (parseC *LoaderController) RejectOfflineReplay(parseEntity string, parseReason string)
- func (parseC *LoaderController) RejectRouteGuardFailure(parsePath string, parseReason string)
- func (parseC *LoaderController) Resolve(parseValue appRouter.Attrs)
- func (parseC *LoaderController) Started() <-chan int
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 ¶
BuildGuardBlocked returns a guard that always blocks navigation with reason.
func BuildGuardRedirect ¶
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 ¶
AllByRole delegates role collection queries to the rendered route fixture.
func (*Fixture) ApplyByDescription ¶
ApplyByDescription delegates description assertions to the rendered route fixture.
func (*Fixture) ApplyByLabel ¶
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 ¶
ApplyByRole delegates role assertions to the rendered route fixture.
func (*Fixture) ByDescription ¶
ByDescription delegates accessibility description queries to the rendered route fixture.
func (*Fixture) ByLabel ¶
ByLabel delegates accessibility label queries to the rendered route fixture.
func (*Fixture) ByLiveRegion ¶
ByLiveRegion delegates live-region queries to the rendered route fixture.
func (*Fixture) ChangeByID ¶
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) DispatchByID ¶
DispatchByID delegates synthetic event 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) 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 ¶
Replace performs replace-style router navigation and rerenders the current route.
func (*Fixture) SetPath ¶
SetPath updates the current browser location without treating it as a navigation action.
func (*Fixture) SubmitByID ¶
SubmitByID delegates submit dispatch to the rendered route fixture.
type LoaderAttempt ¶
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.