testing/cross_backend/ws_endpoint.ts

Where a spawned backend's WebSocket endpoint is, and how the cross suites open a socket on it as one account's session.

The socket-driving cross suites take WsEndpointTarget as their endpoint options (flat, or nested as ws on a suite whose socket cases are optional), and open a socket on a fixture account's session through open_session_ws, so the cookie read, the missing-cookie assertion and the transport choice are written once. Sockets on another credential — a daemon token, a bearer, a session a case logged in on its own transport — and the raw-socket cases open their own way.

view source

Declarations
#

5 declarations

open_session_ws
#

testing/cross_backend/ws_endpoint.ts view source

(target: WsEndpointTarget, account: WsSessionAccount, options: OpenSessionWsOptions): Promise<WsTransportClient> import {open_session_ws} from '@fuzdev/fuz_app/testing/cross_backend/ws_endpoint.js';

Open a real-upgrade socket on target as account's session: its session cookie on the upgrade, target.origin (or base_url) as the Origin.

The cookie is the static one account.create_session_headers carries, not whatever fixture.transport's jar holds now, so a case that rotates the session through fixture.transport first upgrades on the stale cookie.

target

the backend's WebSocket endpoint

account

the account whose session the socket upgrades on

options

whether to wait for admission, plus transport extras

returns

Promise<WsTransportClient>

the open socket

throws

  • Error - if the account carries no session cookie, or the upgrade (or the admission heartbeat) fails

OpenSessionWsOptions
#

testing/cross_backend/ws_endpoint.ts view source

OpenSessionWsOptions import type {OpenSessionWsOptions} from '@fuzdev/fuz_app/testing/cross_backend/ws_endpoint.js';

Options for open_session_ws.

inheritance

extends: Pick< WsTransportOptions, 'default_timeout_ms' | 'on_request' | 'headers' >

admitted

Round-trip heartbeat before resolving, so the backend has admitted the connection (create_admitted_ws_transport) — needed by a case that waits for a push or relies on registration order. false resolves once the socket is open (create_ws_transport), for a case that only round-trips or counts its own requests.

type boolean

readonly

to_session_cookie
#

WsEndpointTarget
#

testing/cross_backend/ws_endpoint.ts view source

WsEndpointTarget import type {WsEndpointTarget} from '@fuzdev/fuz_app/testing/cross_backend/ws_endpoint.js';

Where a backend's WebSocket endpoint is.

base_url

Base URL the backend is reachable at (e.g. http://localhost:1178).

type string

readonly

ws_path

WebSocket endpoint path on the backend (e.g. /api/ws).

type string

readonly

origin?

Origin for a browser-context upgrade. Defaults to base_url.

type string

readonly

WsSessionAccount
#

testing/cross_backend/ws_endpoint.ts view source

WsSessionAccount import type {WsSessionAccount} from '@fuzdev/fuz_app/testing/cross_backend/ws_endpoint.js';

An account a session socket opens as — a fixture or a minted account.

create_session_headers

Build request headers carrying the account's session cookie.

type (extra?: Record<string, string> | undefined): Record<string, string>

readonly

extra?

type Record<string, string>
optional
returns Record<string, string>

Depends on
#

Imported by
#